O'Reilly logo

Learning iOS 8 Game Development Using Swift by Siddharth Shekar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Basic SpriteKit animation

To create the enemy animation, we first have to give the images to SpriteKit. Since we have to provide 1x and 2x images for each frame, we could create four image sets; name them enemy1, enemy2, enemy3, and enemy4; and then drag 1x and 2x for each set. Although it is absolutely possible to do it this way, it is highly tedious. There is an alternate, less tedious way of doing it. While naming each frame, for the 1x image of a frame you can add the numbers 1, 2, 3, and 4 at the end of the file to show the frame names. For the 2x version of a frame, you need to add @2x at the end to tell SpriteKit that this file is twice the size of the original version of the image. So, for the first frame, the 1x file will be enemy_1.png ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required