Wednesday, November 2, 2011

How to make space shooter game with ActionScript 3 and FlashDevelop - part 1

As I mentioned in this post (How to make flash games without the expensive Flash IDE) you can make flash games and earn money without buying the Flash IDE. Actually, its very easy and I prefer to make my games this way. Here I’ll show very basic example that is appropriate even for beginners.

What do you need for this tutorial?
FlashDevelop - http://www.flashdevelop.org
Flex SDK - http://opensource.adobe.com/wiki/display/flexsdk/Flex+SDK

The basics

Let’s begin. Create new AS3 project and name it as you like. I’ll use the name Shooter for it.
This is what will be created for you.
And this is the content of Main.as:
package
{
   import flash.display.*;
   import flash.events.*;
   
   public class Main extends Sprite
   {
       
       public function Main():void
       {
           if (stage) init();
           else addEventListener(Event.ADDED_TO_STAGE, init);
       }
       
       private function init(e:Event = null):void
       {
           removeEventListener(Event.ADDED_TO_STAGE, init);
           // entry point
       }
       
   }
   
}
Add
trace(“Hello World”);
as the last row of the init function:
private function init(e:Event = null):void
       {
           removeEventListener(Event.ADDED_TO_STAGE, init);
           // entry point
        trace(“Hello World”);
       }
Now build and run your project. If everything is done wright you must see “Hello World” at the output window.

Let’s make some changes. First lets change the size and the frame rate. Go to Project->properties and make these changes:

Now our game will be 500x500 and will run at 50 fps(most of the time).

How to make space shooter game with ActionScript 3 and FlashDevelop - part 2

No comments :

Post a Comment