CreativeApplications.Net reports innovation and catalogues projects, tools and platforms relevant to the intersection of art, media and technology. Read more here.

t f r

Search

Flixel 2 Tutorial [Flash, Tutorials, Games]

In this tutorial, I’ll explain how to develop a very simple Defender-style game using the open-source Flixel 2 game library for Flash. Flixel was written by Adam Saltsman and extracted from a couple of his own Flash games, including Gravity Hook, Fathom and Canabalt. There is also an iPhone version lurking around the corner, which will make Flixel even more useful.

Flixel is an AS3-only framework which means that we don’t need Adobe Flash CS4 at all. No movieclips, no timeline, no library and no high price tag. Instead, we will do everything with pure code and bitmap spritesheets.

Game demo:

Setting up the project

Before we start, you need to setup your working environment so you can compile AS3-only projects into SWF files using the free Flex SDK. For this tutorial I have used Flex SDK 4.0. If you work on a Mac I recommend using TextMate for editing the source code. Have a look at this tutorial for how to set it up for AS3 projects. If you work on Windows FlashDevelop is a popular choice and completely free. The Flixel wiki has a good tutorial on how to setup FlashDevelop for Flixel.

Next, download version 2.32 of the Flixel library from GitHub. Since new versions of Flixel are frequently released version 2.32 might not be latest one, but we can be sure the tutorial will work with this version of Flixel.

Now let’s set up the basic project directory structure. Create a project folder that contains the TextMate or FlashDevelop project file, a folder for all graphic and sound assets, a folder for all source files with the Main.as file at the root and a bin folder for the compiled SWF. Move the org folder from the Flixel library into the src folder. Create the subfolders de/pixelate/flixelprimer for the actual source files of the game.

You can find the complete source code for this tutorial on GitHub including the graphic and sound assets we will use for the tutorial.

Main.as will be the entry point for our game. Whenever it runs, it will execute the code in this class first. Make sure that you point the compiler to the Main.as file. (See links to the tutorials above on how to do this in TextMate or FlashDevelop.) When using Flixel we make the Main class a subclass of FlxGame, which is the heart of every Flixel game. The Main class imports the ActionScript files we need, sets up the screen size to 640×480 and starts the game with the PlayState.

[sourcecode language="as3"]package {
import org.flixel.*;
import de.pixelate.flixelprimer.*;

[SWF(width="640", height="480", backgroundColor="#ABCC7D")]
[Frame(factoryClass="Preloader")]

public class Main extends FlxGame
{
public function Main():void
{
super(640, 480, PlayState, 1);
}
}
}[/sourcecode]

The main class also points to the Preloader class, which will show a nice 8-bit style preloader bar when loading the game in the browser. The class looks like this:

[sourcecode language="as3"]package
{
import org.flixel.FlxPreloader;

public class Preloader extends FlxPreloader
{
public function Preloader():void
{
className = "Main";
super();
}
}
}[/sourcecode]

A Flixel game usually consists of different states which subclass FlxState. A common usage would be to have a state for the menu screen, one for the actual game and one for the highscore screen. In our case we will only use one state to keep things simple. Let’s add the scaffold for the play state. The create function will be called once PlayState is created by the main class. The update function is the main loop of the game which will be called every frame.

[sourcecode language="as3"]package de.pixelate.flixelprimer
{
import org.flixel.*;

public class PlayState extends FlxState
{
override public function create():void
{
super.create();
}

override public function update():void
{
super.update();
}
}
}[/sourcecode]

Adding the player sprite and controls

Now that we have a good scaffold for the game, let’s add a space ship for the player. Create a new class in src/de/pixelate/flixelprimer called Ship.as:

[sourcecode language="as3"]package de.pixelate.flixelprimer
{
import org.flixel.*;

public class Ship extends FlxSprite
{
[Embed(source="../../../../assets/png/Ship.png")]
private var ImgShip:Class;

public function Ship():void
{
super(50, 50, ImgShip);
}

override public function update():void
{
velocity.x = 0;
velocity.y = 0;

if(FlxG.keys.LEFT)
{
velocity.x = -250;
}
else if(FlxG.keys.RIGHT)
{
velocity.x = 250;
}

if(FlxG.keys.UP)
{
velocity.y = -250;
}
else if(FlxG.keys.DOWN)
{
velocity.y = 250;
}

super.update();
}
}
}[/sourcecode]

FlxSprite is the main game object class in Flixel and handles basic physics and animation. The Ship class extends FlxSprite, draws the sprite at position x 50 and y 50 and sets the bitmap graphic for the ship which resides in the assets folder. The player controls are handled in the update function which is called by Flixel every frame. First the velocity is set back to zero. Then we check if the player is pressing the arrow keys and change the velocity accordingly. The super.update() call takes care of changing the position of the ship based on the current velocity.

Now we have to add the ship to the game stage. Add the following code to the create function in PlayState.as and declare _ship as a private variable above the function. We also set the background color of the game state to a nice monochrome green.

[sourcecode language="as3"]private var _ship: Ship;

override public function create():void
{
bgColor = 0xFFABCC7D;

_ship = new Ship();
add(_ship);

super.create();
}[/sourcecode]

Now compile the project and start the SWF in the Flash Player. Move the ship around with the arrow keys. The player input works well but the ship can move outside the screen. Let’s fix that. Add the following code into the update function in Ship.as where we make sure that the position of the ship is always within the screen dimensions. We also add a padding of 16 pixels to the if-condition to make it look nicer. Make sure to insert the code after the super.update() call.

[sourcecode language="as3"]if(x > FlxG.width-width-16)
{
x = FlxG.width-width-16;
}
else if(x < 16)
{
x = 16;
}

if(y > FlxG.height-height-16)
{
y = FlxG.height-height-16;
}
else if(y < 16)
{
y = 16;
}[/sourcecode]

Adding enemies

Next, let’s add some enemies. Create the file Alien.as inside src/de/pixelate/flixelprimer. The Alien class takes x and y as arguments in the constructor so we can easily position the sprite when creating it. We set the horizontal velocity to -200 which makes the alien move from right to left at a constant speed. In the update function we use a cosine function to move the alien up and down in a wave motion.

[sourcecode language="as3"]package de.pixelate.flixelprimer
{
import org.flixel.*;

public class Alien extends FlxSprite
{
[Embed(source="../../../../assets/png/Alien.png")]
private var ImgAlien:Class;

public function Alien(x: Number, y: Number):void
{
super(x, y, ImgAlien);
velocity.x = -200;
}

override public function update():void
{
velocity.y = Math.cos(x / 50) * 50;
super.update();
}
}
}[/sourcecode]

To spawn the aliens, we need to add some more code to the PlayState. First we add a FlxGroup for the alien sprites, a logical container which helps us to organize the collision detection between the player ship and aliens. Second we add a spawn timer which controls the interval when a new alien is spawned. The interval starts at 2.5 seconds and slowly becomes faster until it reaches it’s maximum of spawning a new alien every tenth second. Finally we add a function for spawning an alien at a random position at the right border of the screen.

[sourcecode language="as3"]package de.pixelate.flixelprimer
{
import org.flixel.*;

public class PlayState extends FlxState
{
private var _ship: Ship;
private var _aliens: FlxGroup;
private var _spawnTimer: Number;
private var _spawnInterval: Number = 2.5;

override public function create():void
{
bgColor = 0x0ABCC7D;

_ship = new Ship();
add(_ship);

_aliens = new FlxGroup();
add(_aliens);

resetSpawnTimer();

super.create();
}

override public function update():void
{
_spawnTimer -= FlxG.elapsed;

if(_spawnTimer < 0)
{
spawnAlien();
resetSpawnTimer();
}

super.update();
}

private function spawnAlien():void
{
var x: Number = FlxG.width;
var y: Number = Math.random() * (FlxG.height – 100) + 50;
_aliens.add(new Alien(x, y));
}

private function resetSpawnTimer():void
{
_spawnTimer = _spawnInterval;
_spawnInterval *= 0.95;
if(_spawnInterval < 0.1)
{
_spawnInterval = 0.1;
}
}
}
}[/sourcecode]

Adding bullets

Now let’s add bullets so the player can shoot to fight the aliens. Create a new class in src/de/pixelate/flixelprimer called Bullet.as. Nothing fancy here, except that we don’t use a bitmap graphic, but draw the bullet directly in the createGraphic() call.

[sourcecode language="as3"]package de.pixelate.flixelprimer
{
import org.flixel.*;

public class Bullet extends FlxSprite
{
public function Bullet(x: Number, y: Number):void
{
super(x, y);
createGraphic(16, 4, 0xFF597137);
velocity.x = 1000;
}
}
}[/sourcecode]

As with the aliens we add a FlxGroup for the bullets and a spawn function as well. In the update function we check if the player just pressed the space key and fire a bullet if that is the case.

[sourcecode language="as3"]package de.pixelate.flixelprimer
{
import org.flixel.*;

public class PlayState extends FlxState
{
private var _ship: Ship;
private var _aliens: FlxGroup;
private var _bullets: FlxGroup;
private var _spawnTimer: Number;
private var _spawnInterval: Number = 2.5;

override public function create():void
{
bgColor = 0x0ABCC7D;

_ship = new Ship();
add(_ship);

_aliens = new FlxGroup();
add(_aliens);

_bullets = new FlxGroup();
add(_bullets);

resetSpawnTimer();

super.create();
}

override public function update():void
{
if(FlxG.keys.justPressed("SPACE") && _ship.dead == false)
{
spawnBullet(_ship.getBulletSpawnPosition());
}

_spawnTimer -= FlxG.elapsed;

if(_spawnTimer < 0)
{
spawnAlien();
resetSpawnTimer();
}

super.update();
}

private function spawnBullet(p: FlxPoint):void
{
var bullet: Bullet = new Bullet(p.x, p.y);
_bullets.add(bullet);
}

// …
}
}[/sourcecode]

Note that we also added a new function to Ship.as to get the correct spawn position for the bullet from the player’s ship:

[sourcecode language="as3"]public function getBulletSpawnPosition():FlxPoint
{
var p: FlxPoint = new FlxPoint(x + 36, y + 12);
return p;
}[/sourcecode]

Adding collision detection

The only thing missing to make our game playable is collision detection. We handle the collision in the beginning of the update function of PlayState. The first call checks if any sprite in the aliens group overlaps with any bullet sprite and calls the overlapAlienBullet callback if so. The second call checks for collisions between the aliens and the ship sprite.

[sourcecode language="as3"]FlxU.overlap(_aliens, _bullets, overlapAlienBullet);
FlxU.overlap(_aliens, _ship, overlapAlienShip);[/sourcecode]

In the callback functions we define what happens in case of a collision. When an alien sprite gets hit by a bullet, we destroy both the alien and the bullet sprite, increase the score counter and display the updated score on the screen. When the ship gets hit by an alien we also let the screen rumble a bit using the quake function and display a game over message.

[sourcecode language="as3"]private function overlapAlienBullet(alien: Alien, bullet: Bullet):void
{
alien.kill();
bullet.kill();
FlxG.score += 1;
_scoreText.text = FlxG.score.toString();
}

private function overlapAlienShip(alien: Alien, ship: Ship):void
{
ship.kill();
alien.kill();
FlxG.quake.start(0.02);

_gameOverText = new FlxText(0, FlxG.height / 2, FlxG.width,
"GAME OVER\nPRESS ENTER TO PLAY AGAIN");
_gameOverText.setFormat(null, 16, 0xFF597137, "center");
add(_gameOverText);
}[/sourcecode]

We also need to initialize the text fields. Add a private variable declaration for the text fields in PlayState:

[sourcecode language="as3"]private var _scoreText: FlxText;
private var _gameOverText: FlxText;[/sourcecode]

To allow the player to restart the game on game over we add the following code to the update function in the PlayState:

[sourcecode language="as3"]if(FlxG.keys.ENTER && _ship.dead)
{
FlxG.state = new PlayState();
}[/sourcecode]

Create the score text field in the create function in PlayState and set the FlxG.score variable to zero.

[sourcecode language="as3"]FlxG.score = 0;
_scoreText = new FlxText(10, 8, 200, "0");
_scoreText.setFormat(null, 32, 0xFF597137, "left");
add(_scoreText);[/sourcecode]

Adding sounds

The game is fully playable now. Let’s add some sounds to give the player a better feedback of the action. Define all references to the sound files in the header of PlayState.

[sourcecode language="as3"]public class PlayState extends FlxState
{
[Embed(source="../../../../assets/mp3/ExplosionShip.mp3")]
private var SoundExplosionShip:Class;
[Embed(source="../../../../assets/mp3/ExplosionAlien.mp3")]
private var SoundExplosionAlien:Class;
[Embed(source="../../../../assets/mp3/Bullet.mp3")]
private var SoundBullet:Class;

// …
}[/sourcecode]

We call the FlxG.play function to play the sounds in the according situations.

[sourcecode language="as3"]// In spawnBullet()
FlxG.play(SoundBullet);

// In overlapAlienBullet()
FlxG.play(SoundExplosionAlien);

// In overlapAlienShip()
FlxG.play(SoundExplosionShip);[/sourcecode]

Adding explosions

Finally we add some particle explosions when the ship or an alien is destroyed using the FlxEmitter class. We want to use the same explosion for the ship and the aliens so we move the explosion code into a reusable function.

[sourcecode language="as3"]private function createEmitter():FlxEmitter
{
var emitter:FlxEmitter = new FlxEmitter();
emitter.delay = 1;
emitter.gravity = 0;
emitter.maxRotation = 0;
emitter.setXSpeed(-500, 500);
emitter.setYSpeed(-500, 500);
var particles: int = 10;
for(var i: int = 0; i < particles; i++)
{
var particle:FlxSprite = new FlxSprite();
particle.createGraphic(2, 2, 0xFF597137);
particle.exists = false;
emitter.add(particle);
}
emitter.start();
add(emitter);
return emitter;
}[/sourcecode]

In the collision callback functions we create the emitter for the explosion and place it at the position of the ship or alien using emitter.at().

[sourcecode language="as3"]// In overlapAlienBullet()
var emitter:FlxEmitter = createEmitter();
emitter.at(alien);

// In overlapAlienShip()
var emitter:FlxEmitter = createEmitter();
emitter.at(ship);[/sourcecode]

Now you have a simple game in Flixel that should help you getting started building your own ideas. If you have any questions, leave a comment or have a look at the Flixel forums and the wiki.

Related Posts with Thumbnails


  • http://ha.reesun.me/ Harry Harrison

    It might be worth giving mine a shout if anyone out there prefers to use Xcode? > http://wiki.github.com/AdamAtomic/flixel/using-

  • http://www.pixelate.de Pixelate

    If you would like to create a similar type of game using Unity, check out Alec Holowka's great tutorial: http://infiniteammo.ca/schpooter/

  • http://twitter.com/thomers thomers

    great tutorial, thanks – got me a jumpstart into flixel (and AS3-coding, actually), much appreciated!

    found 2 minor typos/extra semicolons: “i <;” and “else if(x <; 16)”

    plus, of course createEmitter should be put into PlayState.

    thanks again!

  • http://www.pixelate.de Pixelate

    Thomas, I'm glad you like the tutorial. We fixed the typos, thanks for the hint!

  • http://www.moustachemovement.com Wilson

    hi, thanks for the great tutorial im still learning when i can bits of programming here and there. This helped me a lot and i sued your game as a template for a little experience. I run a music blog and from time to time post a mix. This time i made it a bit different and though of a kind of interactive mix where you could play along with the songs so i used your tutorial as a template and out of that came this :) http://www.bigo.de.tp/

    Sorry for the long comment
    cheers !

  • http://www.moustachemovement.com Wilson

    lol sorry about the bas english and the typo i meant used not sued !

  • http://www.pixelate.de Pixelate

    Thanks for your comment, Wilson! I'm glad you found the tutorial helpful.

  • TheHanna

    Hey, this is a great tutorial so far! Unfortunately, my keyboard input isn't work. I've double checked my code several times, and it just doesn't seem to be working. I'm using FlashDevelop, flixel v2.34, and Flex SDK 4.0.0.14159.

  • http://www.pixelate.de Pixelate

    @TheHanna: Could you download the complete source from GitHub and check if that is working for you?

  • davidjmcclelland

    I had same issue as TheHanna. Downloading PlayState and commenting the parts I hadn't made classes for yet (bullets) worked. Thanks for a tut that works on latest code – much appreciated.

  • smokeythebare

    I had a problem with key input when I was supposed to run it the first time. I went through the code over and over to make sure I didn't mess it up. I didn't mess it up, but when I added “super.update();” to the “PlayState.as” “update” function. All of a sudden, everything works! :D I hope this helps you all.

  • http://www.pixelate.de Pixelate

    @smokeythebare: Yes, that was the problem. Thanks for pointing that out! I updated the code, so it should work now right away.

  • Thomas

    Seriously, your syntax highlighter keeps popping up flash debug errors when i hover over the code elements.

    Other than that, this tutorial is really, really great!

  • twincannon

    Super win tutorial. Was pulling my hair out trying to find a tutorial that worked with the newer versions of flixel and this one does the job perfectly and succinctly. Thanks so much!

  • http://www.pixelate.de Pixelate

    Thanks twincannon – I'm glad the tutorial was helpful for you.

  • http://cargamesflash.com mark

    great tutorial, thank you!

  • MercureSlime

    Super turorial. However, when I try my games, when sounds should play, the flash debugger pop up :

    “[Fault] exception, information=TypeError: Error #1034: Type Coercion failed: cannot convert PlayState_SoundBullet@2e56b81 to flash.media.Sound.
    Fault, loadEmbedded() at FlxSound.as:100″

    Any idea?

  • http://www.pixelate.de Pixelate

    MercureSlime, can you get it to work using the complete source code from GitHub (http://github.com/pixelate/flixel_primer)?

  • MercureSlime

    When I click on the link i got a cat/octopus saying “That page doesn't exist!”

  • http://www.pixelate.de Pixelate

    Sorry, try this link instead:
    http://github.com/pixelate/flixel_primer/archiv

  • MercureSlime

    Yes, it works perfectly. I found the problem:

    When I tried to add my mp3 in the code, i used the “Insert Into Document” function of FlashDevelop and it produced this code :
    [Embed(source='../assets/ExplosionAlien.mp3', mimeType='application/octet-stream')]

    The second part of the code seems to be the origin of the exception. After watching your code, I wrote :
    [Embed(source='../assets/ExplosionAlien.mp3')]

    And now it works!

    Thank you for the help!

    (ps : your games are awesome! especially 'Understanding Games' which give me the same feeling I had reading 'The Invisible Art')

  • http://www.pixelate.de Pixelate

    Great you got it working! Thanks for the kind words – I'm glad to hear you like Understanding Games.

  • Vraf

    I just followed your tutorial. Got it working with FlashBuilder in roughly 2 hours… I'm still proud :)
    Thank you so much for sharing !

  • http://www.pixelate.de Pixelate

    Vraf, I'm glad you made it through the tutorial and found it helpful.

  • Vancext

    Really loved the tutorial — wonderful starting place to jump into flixel. Glad it was here. :) I do have a question though. There seems to be a bug where the player can't fire if they are simultaneously holding left and either up or down (moving up-left or down-left.) Any clue what this might be due to? Tried to track it down with no success.

  • http://www.pixelate.de Pixelate

    Hi Vancext. I can't reproduce the bug you are describing. Can you try to download the complete source from http://github.com/pixelate/flixel_primer and see if this works for you?

  • Teo

    @Vancext: The problem you described is a certain limitation with most PS/2 keyboards that cannot get some simultaneous key presses like SPACE and LEFT ARROW at the same time. Instead of buying a new keyboard, you can map the shoot key to something like “X”.

    Try this in your PlayState.as on the update() function :

    REPLACE

    if(FlxG.keys.justPressed(“SPACE”) && _ship.dead == false)
    {
    spawnBullet(_ship.getBulletSpawnPosition());
    }

    WITH THIS

    if(FlxG.keys.justPressed(“X”) && _ship.dead == false)
    {
    spawnBullet(_ship.getBulletSpawnPosition());
    }

    … and you should be fine ;)

  • Vancext

    That was it. Sweet! Thanks Teo. :)

  • http://www.lindicible.com Raphaël

    Thank you for this really clear and good tutorial.
    Just a suggestion about the spawn timer, perhaps you use a solution like this:

    private var _spawnTimer:Number = 0;
    private var _spawnInterval:Number = 60;

    in the update method :
    if (_spawnTimer % _spawnInterval == 0) {
    spawnEnemy();
    }
    _spawnTimer ++;

    this should allow you to use differents interval values to generate other enemies or weapons.

    Sorry for my english…

  • Jake

    Woot! This is superbly helpful.

  • http://www.facebook.com/steve.pettit Steve Pettit

    i feel kinda dumb but i am hung up in the beginning with the Embed(source for the sprites. its just the directory list to the PNG that flixel is making but doesn't exist yet correct? i just go to properties on that folder and copy and paste the directory line to where that file will be but it doesn't work. flash develop says it can't resolve/transcode it.

  • Jake

    Do you have a png stored at that location, Steve? (I just made my own, and put them in a folder right under source called “images”, so my embed looked like

    [Embed(source="/images/Ship.png")]

  • Pingback: Flex, Flixel and Xcode « stackofboxes

  • OmegaStorm

    I'm new to Flixel/AS3 myself and your tutorial was very helpful. I decided to keep adding to it and wrote up a tutorial (as a direct continuation of yours) to show how to do what I did. It's my first tutorial and I hope I didn't leave anything out. Let me know what you think.

    http://www.omegastormproductions.com/uber-flash

  • http://www.pixelate.de Pixelate

    Nice addition to the tutorial, Omega. I like the power upgrades!

  • JB Tellez

    Fantastic tutorial Andreas, Flixel should put you on their payroll ;)

    The tutorial game suffers from a known bug in the Flash player. When the bullet audio plays you’ll see a brief “hiccup” in the enemies’ graphics, as long as a previous bullet sound is not still playing. This Flash bug is related to a sound playing when no other sounds are already playing. The workaround is to always have some audio playing. Either background music or a snippet of silence. Something like FlxG.playMusic(SoundOfSilence); should do the trick.

  • http://www.pixelate.de Pixelate

    JB, thanks for the nice words and for sharing the sound trick!

  • MercWorks

    This was awesome, the only Flixel 2 tutorial I could even find! Thanks a million!

  • Guest

    Great tutorial, very straight forward and to the point, yet clear and thorough. Thank you very much!

  • Martin

    Thanks, nice tutorial, followed every step, except could not make the preloader working some problem with Flixel (or my software) not your code.

  • http://carlcravens.myopenid.com/ Carl Cravens

    Thank you. This tutorial was really helpful in getting off the ground.

    I’m an experienced pro systems-level developer, but new to ActionScript and Flixel. By explaining each piece from the ground up, this got me going in just a few hours. Which is really great, because I’m preparing to teach my 10-year-old son to write games in Flash, and I think this tutorial is a great foundation to help me explain it to him. (The children’s “learning” platforms just don’t cut it; they ultimately are about demonstrating concepts, but if the collision detection is flaky, that’s okay… they aren’t meant to write real-time games. But what 10-year-old boy wants to write anything *but* a game!?)

    I had no trouble building using Linux and the Flex 4 SDK compiler.

    Adding bits and pieces to this in the last day has been very educational. I’m recycling aliens and bullets that have left the screen or been killed, and have added smartbombs with a graphical display of remaining bombs (a dot for each bomb instead of a number). That took some figuring out and was pretty educational.

  • http://www.pixelate.de Pixelate

    Carl, thanks for your nice comment! I got into programming as a kid because I loved games and wanted to make my own games. It’s great to see that the tutorial is helpful for you wanting to teach your son.

  • Ramsar

    Great tutorial! And, unfortunately, to my knowledge the only up-to-date tutorial on flixel. Many thanks!

  • Heavybolter

    Thank you so much; all of the other tutorials are out of date so this really helped a lot :)

  • http://www.pixelate.de Pixelate

    Cool, I’m glad you guys found it useful.

  • Pinchbeck

    Thank you so much for this great tutorial!
    I’m still having a question in mind: the performance. Don’t we have to kill the aliens and bullets outside the canvas, so that the garbage collector is able to collect them?
    Cheers!

  • http://www.pixelate.de Pixelate

    @Pinchbeck: Since this is a primer for Flixel, the code is not optimized for performance. Check out the Flash Game Dojo article on Memory Management for more info on optimization in Flixel: http://flashgamedojo.com/wiki/index.php?title=Memory_Management_(Flixel)

  • Dj_bigmadphsychobastard

    Excellent tutorial , great starting point. I used it in FlashBuilder and some things are a little different but mostly the same.

    One small bug(?) though, on both my version of the finished tutorial and your one at the end of this page, when you hold the ‘UP’ and ‘LEFT’ keys at the same time to move diagonally back and up, you cannot shoot…

  • http://www.pixelate.de Pixelate

    @Dj_bigmadphsychobastard: This might be a limitation of your keyboard. See comment from Teo above.

  • Franth

    Thank you so much for this useful tutorial! It has really help me to begin with flixer and AS3. I have a question (a very silly one, I guess) and I was wondering if maybe you could help me: I’ve been trying to modify your code so the aliens shot bullets from time to time. And because I want the aliens to be able to shot the bullets simoultaneously, I thought the way to do it was to spawn the bullets not in PlayState.Update() but in Alien.Update(). The thing is that I can’t add the line code “add (_bullets)” in Alien.Update(). Would you (or anyone) be so kind to explain me the reason and suggest me a solution? Thanks!