Skip to content

Instantly share code, notes, and snippets.

@ChangJoo-Park
Created May 26, 2015 12:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChangJoo-Park/270ef4129e337d9936a9 to your computer and use it in GitHub Desktop.
Save ChangJoo-Park/270ef4129e337d9936a9 to your computer and use it in GitHub Desktop.
use FlxBullet
package;
import flixel.FlxG;
import flixel.FlxState;
import flixel.addons.weapon.FlxBullet;
import flixel.addons.weapon.FlxWeapon;
import flixel.util.FlxColor;
/**
* A FlxState which can be used for the actual gameplay.
*/
class PlayState extends FlxState
{
private var _player:Player;
private var _bullet:FlxBullet;
private var _weapon:FlxWeapon;
/**
* Function that is called up when to state is created to set it up.
*/
override public function create():Void
{
super.create();
FlxG.camera.bgColor = 0xFFBADA55;
_player = new Player(0, 0);
add(_player);
_weapon = new FlxWeapon("Lazer", _player);
_weapon.makePixelBullet(50, 20, 20, FlxColor.HOT_PINK, 10, 0);
_weapon.setBulletDirection(FlxWeapon.BULLET_RIGHT, 20);
add(_weapon.group);
}
/**
* Function that is called when this state is destroyed - you might want to
* consider setting all objects this state uses to null to help garbage collection.
*/
override public function destroy():Void
{
super.destroy();
}
/**
* Function that is called once every frame.
*/
override public function update():Void
{
if(FlxG.keys.justPressed.A)
{
trace("A Key pressed");
_weapon.fire();
}
super.update();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment