I’m using cocos2d-x version 3.3 and I’m using the integrated physics on it.
I init a DrawNode and set physicsBody on it then use ApplyImpulse but it doesn’t work.
Here is my code snippet:
Hi…
Code seems to be fine to me… I though never tried it using DrawNode but I’ve played around a lot with sprites and physics bodies with integrated physics engine.
Can you try few things… to check exactly where is the problem…
Replace the 2 lines
by simply
auto ball = Sprite::create(“someSmallBall.png”); // Give it some sprite…
// You may change 15 in your statements to the ball->getContentSize.width()/2
and check whether this works…
if this also doesnot works then problem is something else…
Hi catch_up,
Thanks for answer my question
After compare with some other code, I realize that the function applyImpulse can work. But the problem is I used Material Default for my object, so it seems like not move… When I tried to change material values, it worked perfectly!
Did u change the density?
Earlier I was trying to suggest you to give some mass to the body then I thought first lets check whether even simple thing is working or not
Good that it worked