Can you show me how to enable debug draw for Box2D? if I Want to change the shape or combine other shapes I wanted to add debugdrawing to see the outline of my body to know if it matches with my sprite.
Also AISUKAUNTA how you call vinova B2DebugDraw. How you call it? Because as I see it is other call with other b2world. How you call it to your HelloWorld class to enable the drawing?
Just import B2DebugDraw. Other tutorial examples of Box2D debugging is out of date and not compatible with Cocos2d-x 3.0 which is why I had such a hard time to enable it.
All you have to do is follow the readme notes on his github.
Mr Aisukaunta
I just import B2DebugDraw.h but I get nothing in my sprites. Can you explained a little bit about the comments what modifications I have to make to my box2dworld to HelloWorldScene.cpp so as to draw something? It is very confusing
vinova comments are
Just create a new instance of B2DebugDrawLayer, then add it to your CCLayer just as a normal CCNode.
I have created a no of sprites and added them to the scene with the same reference and now, how can i remove them
Now, i want to remove all those, even the ones with out any reference. How can i achieve that.
With out using removeChildBytag(); or without using tags.
void Science::onBallMovement(cocos2d::Ref* pSender){
auto sp = (Sprite*)pSender;
v1 = sp->getPosition();
if (v1 == v2) {
return;
}
if(v1!=v2) {
if (sp->getTag()==1) {
s = Sprite::create("Dot.png");
}
if (sp->getTag()==2) {
s = Sprite::create("BlueDot.png");
}
s->setPosition(v1);
s->autorelease();
this->addChild(s);
}
v2 = v1;
}
void Science::update(float delta){
if (setting) {
this->onBallMovement(spr);
this->onBallMovement(spr1);
}
}
By overriding the update method of node class, i am calling the above repeatedly and based on the current position of my sprite which moves randomly, i am creating a tracker of path. But now, i want to remove it based on the user selection, how can i do it?
Doesn’t that simulated throw (simulateTrajectory)'s world->step also changes the position of the original ball too? world->step should normally affect everything in the physics world??