In this section, we will discuss how to animate a sprite. We will change our custom sprite class to make the character animate. This can be done by providing Cocos2d with a number of images and asking it to cycle through these images to create the animation.
To animate the sprites, we will add four frames of animation that we will apply to the
hero sprite class and cycle through the images using the
repeatForever action. In the next section, we will cover the actions in detail.
Resources folder for this chapter, there will be normal,
ipadhd versions of the frames for
hero. We will import all the files into the project.
Hero.m file, we will change the
initWithFilename function, as ...