Reputation: 183
What is the best way of changing the image of my "Sprite" before/during/after an animation?
I display the image:
CALayer *am = [[CALayer alloc] init];
am.contents = img;
am.bounds = CGRectMake(150, 150, 46, 47);
[self.view.layer addSublayer:am];
[am setNeedsDisplay];
Say I have an animation that takes the sprite from location A to Location B, how would I change the image of the layer the second it hits Location B, or leaves Location A?
Thank you!!
Upvotes: 1
Views: 722
Reputation: 454
You can use sprite sheet or can follow this way of adding into plist file . http://www.raywenderlich.com/1271/how-to-use-animations-and-sprite-sheets-in-cocos2d
(without cocos2d) If you want to manually give frames then this tutorial is best. Provides with source code too, enjoy . http://mysterycoconut.com/blog/2011/01/cag1/
Upvotes: 1