Wednesday, June 1, 2022
HomeGame DevelopmentDrawing bounding field of sprite with out physicsWorld - cocos2d-x

Drawing bounding field of sprite with out physicsWorld – cocos2d-x


Hi there,
I search within the discussion board this matter and obtained this
https://talk about.cocos2d-x.org/t/box2d-debug-draw-with-coco2d/38254/2

Within the physics engine it is extremely simple. You simply do one thing like:

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

Isn’t that potential in a Non bodily world with out going right into a “convoluted” answer as within the above?
I’m certain it should be fairly simple, however I don’t see any information about it. Older posts stated to make use of this

	#outline CC_SPRITE_DEBUG_DRAW 1

However it’s not working for me. Any recommendations?

thanks


Have you ever tried to debug your software to determine why it’s not drawing the bounding field? The code that handles this isn’t complicated, so no matter is inflicting it to not work must be apparent in case you step into it with a debugger.

I’ve tried a code like this

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

and it does work, however my query is a traditional scene has a macro already like “`
PhysicsWorld::DEBUGDRAW_ALL

I’m unsure I perceive what you imply. What does that code have something to do with CC_SPRITE_DEBUG_DRAW?

Whenever you allow CC_SPRITE_DEBUG_DRAW, it is going to allow a little bit of code within the cocos2d::Sprite class, the place it provides a DrawNode to deal with the drawing of the boundary field. That’s what you have to be taking a look at. Be sure to clear and re-build the undertaking.

That has nothing to do with it, and simply because the physics implementation has that, doesn’t imply the Sprite implementation ought to too.

This matter was routinely closed 24 hours after the final reply. New replies are not allowed.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments