Guest User

Untitled

a guest
Jan 15th, 2019
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. void MyLayer::draw()
  2. {
  3. // super draw
  4. CCLayer::draw();
  5.  
  6. // Iterate through all nodes of this layer
  7. for ( CCNode* node = ??? )
  8. {
  9. // Make sure the node is a CCSprite
  10. if ( node == CCSprite ??? )
  11. {
  12. CCSprite* sprite = (CCSprite*) node;
  13. ccDrawRect( sprite->boundingBox() ??? );
  14. }
  15.  
  16. }
  17. }
  18.  
  19. //put this line at the top of your cpp file
  20. #define CC_VERIFY_TYPE(__OBJECT__,__CLASS_TYPE__) assert(dynamic_cast<__CLASS_TYPE__>(__OBJECT__))
  21.  
  22. //these lines in your code
  23. CCObject* child;
  24. CCARRAY_FOREACH(m_pChildren, child)
  25. {
  26. CC_VERIFY_TYPE(child,CCSprite*);
  27. CCSprite* sprite = (CCSprite*) child;
  28. CCSize s = sprite->boundingBox().size;
  29. ccDrawRect(sprite->boundingBox().origin, ccpAdd(sprite->boundingBox().origin, (ccp(s.width,s.height))));
  30.  
  31. }
Add Comment
Please, Sign In to add comment