Space Shooter Episode I
The game is a sidescroller where the player controls a spaceship that fights off hordes of invading aliens.
Space shooter – the first steps
The goal of the Space Shooter episode series is to show developers how to create a 2D game for bada platform using cocos2d-x framework. The game is a sidescroller where the player controls a spaceship that fights off hordes of invading aliens. The first episode will have the spaceship hanging in space with aliens flying through the screen. The player controls the ship using a touch sensor. The game will have a menu scene and a game scene. If the ship hits an alien, the game will return to the menu scene. To run the game you need to extract the downloaded application to the previously set cocos2d-x framework directory and import the application.
How to load animations
To move sprites around the screen you can use actions like CCMoveTo, but they won’t be animated, e.g. the image will stay the same. You need to prepare animation frames, put them on a sprite sheet and describe in a .plist file. Frames of animation are described like normal sprites, but it’s of course a good idea to add the frame number to the name, e.g. “<key>shipEngineNormal2.png</key>”. The framework will load consecutive frames based on the description file, so you don’t have to worry about cutting frames from the spritesheet. However, you need to implement animation changes based on user interaction and synchronize move actions with animation.
The base class for animated game objects is AnimatedObject. It has the addAnimation() method that loads a particular animation to the sharedAnimationCache which allows retrieving the animation later using its name. The method takes AnimationProperties as the parameter, which contains information about animation name, frames count and delay between frames.