Hi, im creating an app similar to doodle jump where my main sprite has a negative acceleration and a positive velocity whenever it touches the platforms, and i want to animate the sprite as it hits the platform, but i have no idea how to go about doing that. Can anyone give me some suggestions?
Also, in cocos2d i have a case statement to display the different platforms, but i want one of these cases to have a different value for the velocity of the sprite, so how would i go about doing that?
you can use this to animate a sprite
id animation = [MoveBy actionWithDuration:2.0 position:ccp(-100, 0)]; // Make the animation MoveBy tells the sprite to move "so many pixels" from it's current position
[sprite runAction: animation]; // Tell the stickman to do the animation
though i am looking for animate a spirte sheet (having two images 1 at 0,100 and toher at 10,100)
Those are all good answers, but thats not exactly what im looking for. Let me try it another way:
I initialized an AtlasSprite in my (id) init, which is my main sprite
Then in (void) jump, i want to take that same sprite, but i want to animate it with an array of images. The images i want to animate it with are called 2.png, 3.png, 4.png, and 5.png. Here is some code:
- (void)jump {
one_vel.y = 550.0f;
//This is where i want to animate "one" with an array of images called //2.png, 3.png, 4.png, and 5.png
//Also, how would i declare the atlas sprite used above in (void) jump?
}
i ran into another problem also. In the code below i have initialized 3 platforms, and this code works, but i want to add a special feature to the case 2 platform. I want to make an if statement saying that if my sprite touches it, the sprite's velocity will be different, but i tried all the ways i can think of and have no idea how to continue.
- (void)initPlatform {
CGRect rect;
switch(random()%3) {
case 0: rect = CGRectMake(633,83,64,13); break;
case 1: rect = CGRectMake(633,139,65,14); break;
case 2: rect = CGRectMake(725,80,78,16); break;