void HelloWorld::Update(float dt)
{
action = MoveBy::create(dt,Vec2(2,this->getPositionY()));
_ball->runAction(action);
}
This is a fundamental question, shall I update my sprite just using setPositionX(this->getPositionX() + 2)
or I have to use MoveBy ? Both ways are not working.
In a scheduled update function, you should calculate the amount it moves manually and change the position using setPosition
(or setPositionX
and setPositionY
). You should not be using a MoveBy
in this way.
Are you seeing your update function being called? (i.e. put a CCLOG debug statement in there and see if you get it printed to the console).
How are you scheduling your update? If you’re using this->scheduleUpdate()
, then I believe your update function should be with a lowercase “u”.
Additionally, you should be calling the parent’s update function too.