Subscribe to this Blog

Creating a Flash Shooter game like SkyForce: Part 1

By admin • Aug 24th, 2008 • Category: Tutorials


If you haven’t already played Sky Force then I suggest you try it outhere. It’s a fantastically addictive shooter game that I was hooked onto for a couple of weeks at a stretch. Although some people think that the days of shooter games is over, I am one of those who believes that humans can never get enough of blood, blasts and bullets.

Anyways once you play Sky Force or any other overhead shooter games (as I like to call them) you will find the most noticeable is the scrolling background it has. In this part of the tutorial I’ll be adding a continuous scrolling background that has two elements in it.

Here are the symbols I’ll use for this part of the tutorial.

SYMBOLS:

back1: This is the first of the background images I’ll be using. I’ve simply resized it and put it in a movieclip.

back2: This is simply an vertically inverted image of back1.

ship: Every shooter needs a ship. Here is the ship.

In this part of the tutorial I’ll be covering the actionscript for only the scrolling background. The coding is AS2, but I’ve made it in such a segmented way that its going to be easy to convert it to AS3 by simply pulling out the function.

  1. stop();
  2. motionspeed = 1;
  3. _root.attachMovie("back1", "back1", _root.getNextHighestDepth(), {_x:250, _y:0});
  4. _root.attachMovie("back2", "back2", _root.getNextHighestDepth(), {_x:250, _y:-400});
  5. _root.attachMovie("ship", "ship", _root.getNextHighestDepth(), {_x:250, _y:200});
  6. ship.onEnterFrame = function() {
  7. _root.mover();
  8. };
  9. function mover() {
  10. back1._y += motionspeed;
  11. back2._y += motionspeed;
  12. if (back1._y>=400) {
  13. back1._y = -400;
  14. }
  15. if (back2._y>=400) {
  16. back2._y = -400;
  17. }
  18. }

Line by line explanation of the code

2. “motionspeed” is a variable that decides how fast the background scrolls.

3-5. I’ve put in the various movieclips on stage. “back1” is exactly on the screen while “back2” is just above it.

6. This is the onEnterFrame function for the ship movieclip. I will be using this function as the base for calling all other functions.

7. Just as I said… I called a function called “mover”.

9. Function “mover” is a function that scrolls the background. I’ve made a separate function as it can be used in other places.

10, 11. Both the background movieclips are scrolled down by the amount specified by motionspeed.

12-17. If either of the backgrounds scrolls down to the bottom of the screen, I put it back up so it becomes a continous loop.

And here’s the result:

You can download the source files here.

If you liked this post, Buy me some beer (or coffee)

Tagged as: , , ,

admin is An engineering student from India. Enjoying his life both in the real world and in cyberspace
Email this author | All posts by admin

7 Responses »

  1. Hello , I agree with this article, just sometimes I read so fast everything and I miss things that after read them again, I can understand it better.. ;). Your g a Flash Shooter game like SkyForce: Part 1 | Its Not Another Gaming Site Blog Stumbled up and Bookmarked, so I keep updated on every article you write from now now on flash games.

  2. The code listed above doesn’t work.. at lines 12 and 15, it says “gt”, That caused errors, so i downlaoded your source and used your script. Arn’t i smart?

    For people with the same problem, i replaced lines 12 and 15 with …

    12 : if (back1._y>=400) {
    15: if (back2._y>=400) {

    That made the movie work.

    But then another problem, My ship moves about 5 cm off from the clips, which i must say, are moving along perfectly.

    Might wanna post on how to fix :D

  3. if your ship is too far left, replace line 5 with this

    _root.attachMovie(”ship”, “ship”, _root.getNextHighestDepth(), {_x:600, _y:200});

  4. I guess this happened due to the script i used to put the code onto the site. Thanks for pointing it out.

  5. I invite you to play 100’s shooting games at my shooting non-profit site - http://www.arcademag.net - i’m a fan of those old shooting games…

  6. Niiice post thanks so much for this useful info ! not always we can see like this ;)

  7. I think your blog need a new wordpress template. Downalod it from http://templates.wordpressguru.in, The site has nice and unique wordpress templates.

Leave a Reply