Basic two frame animated tank

  • 10 favourites

Attached Files

The following files have been attached to this tutorial:



Download now 111.42 KB


2,301 visits, 4,166 views


I wanted to build a tank game but I only wanted to have a very small number of animations. As the tank is fairly small in size with the full game coming in at less than 200k I figured I could make the animation simple, yet I wanted it to be convincing.

So I modeled my tank in three images using Illustrator. You can use Inkscape or any other vector program if you wish. I created the Body animation frame one, frame two and a turret as well.

I placed the two body images into two frames of a sprite animation and set the settings as in the image here:

I created a simple bullet sprite and set it so that it was small enough to look like it would fit into the barrel of the tank.

I made three layers, The background Layer and placed a scalable image of some bricks onto it, then sized it to the project window size. I locked that layer and left it alone. I Then created a layer for the game itself and placed the tank sprite and the turret sprite onto the layer. I gave the tank body the Car behavior and the confined to layout behavior as well. I created a HUD layer but did not end up using it. Just habit I guess. Here is the layout.

From here I programmed the tank to respond to the keys and I pinned the turret to the tank body. Then I set the keys to control the turret. The trick was to set the two frames so that they animated only when the tank was moving. For that I used the "car is moving" action on the tank body. It is in the Car section of the Tank object, it uses two commands in the one event. The first is set animation to "moving" (play from beginning) This means when the tank is in motion either forward or backwards the animation will play between the two frames. I set the animation speed to 5 in the second action.

To get the animation to stop when the tank is not moving I duplicated the event and right clicked on the car is moving event. Then I selected the dropdown button marked Invert and set the animation setting in the action to Stop animation. This way when the tank is sitting in one spot it stops the animation between the two frames.

The turret is just pinned onto the tank body and I set the A is down command to rotate the turret 3 degrees counter clockwise and the D button to rotate the turret 3 degrees clockwise when they are down. I added the spawn object action to the turret and set the spawn point to the end of the barrel. As the bullet has the bullet action it spawns and moves out straight ahead where ever the barrel is pointing. I have the full event sheet here.

The .capx file and playable demo of the animation can be found on the arcade here: Link to my Arcade example

I hope you find this to be useful. I tried to locate tutorials for animating tank treads and could not find any. There may be a better way to do it, but this seems simple enough for me.

Thanks for reading and enjoy.




Download now 111.42 KB

  • Order by
Want to leave a comment? Login or Register an account!