Is there any alternative for CCMoveBy Action in cocos2d in iphone ??
If anybody know about this.. plz reply.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
An alternative to using actions to move sprites is to use simple physics. You can extend the CCSprite class to include an update method as well as ivars / properties to keep track of x and y velocity.
In the update method, move the sprite by velocity * dT in each direction.
Call the sprites update method in the update method of your game scene.
MovingSprite.h
MovingSprite.m
And add
[self scheduleUpdate];to the init method of your game layer. Then add an update method within the game layer where you call update for all moving sprites.Now you just need to add collision detection to check if the car collides with the sides of the track.