setGravityEnable didn't work on cocos2dx 3.2

I’m a starter of learning cocos2dx, so I did this program for practice. Here’s the code:

The bird stays remain the same position. It didn’t go up or down. Can any guys help me solve it?
Thank you!

Your physics is probably not doing anything right now (btw, you only need to set gravity enabled once). Rotation works because you are rotating the sprite, not the physics body. Check this thread Physics update problem

Thank you KJS. I found the point where I didn’t create the scene with initwithPhysics, and set the gravity.
Thank you so much!

I can do it in two ways. But in this way:

I can’t find Scene::initWithPhysics() in any of the APIs, but it works. When I change it to Scene::initWithPhysics(), the program stopped when this scene created.

try usingcreateWithPhysics() instead of create()

playScene is also a layer, sorry for the mistake. It can’t createWithPhysics. And I also have another problem.

I used createScene() in other scene to replace to this scene, but it never run init() after createScene(). As the same way of creating other scenes without physics, where they work well.

it’s a bit difficult to understand what you are after, perhaps you could call init() manually then for your scene? It’s hard to say how your code is organized without seeing it all. Try taking another look at the thread I linked earlier to this thread, maybe it will help.