Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8613099
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:47:21+00:00 2026-06-12T04:47:21+00:00

In cocos2d-x, how can I display the bounding box for all sprites that are

  • 0

In cocos2d-x, how can I display the bounding box for all sprites that are children of this layer?

Here’s my starting point:

void MyLayer::draw()
{
    // super draw   
    CCLayer::draw();

    // Iterate through all nodes of this layer
    for ( CCNode* node = ??? )
    {
        // Make sure the node is a CCSprite
        if ( node == CCSprite ??? )
        {
            CCSprite* sprite = (CCSprite*) node;
            ccDrawRect( sprite->boundingBox() ??? );
        }

    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T04:47:22+00:00Added an answer on June 12, 2026 at 4:47 am
        //put this line at the top of your cpp file
        #define CC_VERIFY_TYPE(__OBJECT__,__CLASS_TYPE__) assert(dynamic_cast<__CLASS_TYPE__>(__OBJECT__))
    
        //these lines in your code
        CCObject* child;
        CCARRAY_FOREACH(m_pChildren, child)
        {
            CC_VERIFY_TYPE(child,CCSprite*);
            CCSprite* sprite = (CCSprite*) child;
            CCSize s = sprite->boundingBox().size;
            ccDrawRect(sprite->boundingBox().origin, ccpAdd(sprite->boundingBox().origin, (ccp(s.width,s.height))));
    
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've tried following this tutorial (http://www.raywenderlich.com/4666/how-to-create-a-hud-layer-with-cocos2d) however as you can probably tell I'm not
I am starting out Android Cocos2D from here . I see that a sprite
I'm trying to make an application in cocos2d that can be used on multiple
How can I set in cocos2d 1.1 the z-index to ccDrawPoly() to draw this
I want to send sms from cocos2d-x engine.If this engine can't send sms, does
I just started with cocos2D and came across something that looks like this ..
I understand that cocos2d it's really simple API, and that I can use it
I need to display webview in cocos2D game. I used this code. But it
I'm new to Cocos2d, but I can't seem to find the answer to this.
I got a interesting riddle here. My cocos2d project uses a UIView to display

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.