Drawing bounding box of sprite without physicsWorld

Hello,
I search in the forum this topic and got this
https://discuss.cocos2d-x.org/t/box2d-debug-draw-with-coco2d/38254/2

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

    PhysicsWorld* physicsWorld = scene->getPhysicsWorld();
    physicsWorld->setDebugDrawMask(PhysicsWorld::DEBUGDRAW_ALL);

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

	#define CC_SPRITE_DEBUG_DRAW 1

But it is not working for me. Any suggestions?

thanks

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 ```
PhysicsWorld::DEBUGDRAW_ALL

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.