Drawing bounding box of sprite without physicsWorld

I search in the forum this topic and got this

In the physics engine it is very easy. You just do something like:

    PhysicsWorld* physicsWorld = scene->getPhysicsWorld();

Isn’t that possible in a Non physical world without going into a “convoluted” solution as in the above?
I am sure it must be quite easy, but I don’t see any info about it. Older posts said to use this


But it is not working for me. Any suggestions?


Have you attempted to debug your application to figure out why it’s not drawing the bounding box? The code that handles this isn’t complex, so whatever is causing it not to work should be obvious if you step into it with a debugger.

I have tried a code like this

	Rect aabb = GameGlobals::playerSprite->getBoundingBox();
	DrawNode* drawNode = DrawNode::create();
	drawNode->drawRect(aabb.origin, aabb.origin + aabb.size, Color4F(1, 0, 0, 1));
	this->addChild(drawNode, 100);

and it does work, but my question is a normal scene has a macro already like ```

I’m not sure I understand what you mean. What does that code have anything to do with CC_SPRITE_DEBUG_DRAW?

When you enable CC_SPRITE_DEBUG_DRAW, it will enable a bit of code in the cocos2d::Sprite class, where it adds a DrawNode to handle the drawing of the boundary box. That’s what you should be looking at. Make sure you clean and re-build the project.

That has nothing to do with it, and just because the physics implementation has that, doesn’t mean the Sprite implementation should too.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.