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;
}else
{
yellow = color == 1;
}
auto box = yellow ? Sprite::create("YellowSquare.png") : Sprite::create("CyanSquare.png");
box->setScaleX(size.width/100.0f);
box->setScaleY(size.height/100.0f);
auto body = PhysicsBody::createBox(size, material);
box->setPhysicsBody(body);
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
this->addChild(pBox);
I look into the source code ,but can’t get any thing to fix this.
so…
Thanks for all your help…