Cocos2d-x 3.1 PhysicsBody(Node) can't run RotateBy RotateTo action

Cocos2d-x 3.1 PhysicsBody(Node) can't run RotateBy RotateTo action

Using cocos2d-x 3.1 c++

//make a test box,this code comes from the test-cpp

Sprite* makeBox(Vec2 point, Size size, int color, PhysicsMaterial material)
    bool yellow = false;
    if (color == 0)
        yellow = CCRANDOM_0_1() > 0.5f;
        yellow = color == 1;
    auto box = yellow ? Sprite::create("YellowSquare.png") : Sprite::create("CyanSquare.png");
    auto body = PhysicsBody::createBox(size, material);
    box->setPosition(Vec2(point.x, point.y));
    return box;
// mainly code
    Sprite* pBox=makeBox(Vec2(100, 100), Size(50,50));
    pBox->setPosition(Vec2(300, 300));
   //    pBox->setRotation(150);//this will rotate the box,it is ok
    pBox->runAction(RotateTo::create(3, 360));//this action take no effect

I look into the source code ,but can’t get any thing to fix this.
Thanks for all your help…

Physics simulation constantly setting the angle to its world angle, that is why the rotation on Cocos sides were overwritten

If you want the functionality, make the sprite a child of the physics node, and rotate the sprite instead

I created an issue here:
And I will fix this soon……

This bug is marked as fixed. I’m still experiencing it on Cocos2d-JS v3.3. Any ideas?

You can do it this way

auto rotateBy= RotateBy::create(1, 360);
auto rotateByRev= RotateBy::create(1, -360);
bottomPipe->runAction(RepeatForever::create(Sequence::create(rotateBy, rotateByRev,nullptr)));