Created
May 26, 2015 12:56
-
-
Save ChangJoo-Park/270ef4129e337d9936a9 to your computer and use it in GitHub Desktop.
use FlxBullet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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