Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package
- {
- import org.flixel.FlxSprite;
- import pixelperfectoverlap.FlxSpriteEx;
- import org.flixel.FlxG;
- /**
- * ...
- * @author Kristian Macanga
- */
- public class Player extends FlxSpriteEx
- {
- private const GRAVITY:int = 200;
- protected var flm:int = 0;
- protected var name:String = "";
- protected var msg:String = "";
- protected var boost:Boolean = false;
- protected var pack:Boolean = false;
- protected var rightFace:int = 1;
- protected var ammo:int = 0;
- protected var backAmmo:int = 0;
- protected var canShoot:Boolean = true;
- protected var pHealth:int = 50;
- protected var life:int = 3;
- protected var char:int = 0;
- protected var jumpPower:int = 100;
- protected var runSpeed:int = 100;
- protected var swimSpeed:int = 100;
- protected var special:String = "";
- public function Player(costume:Class)
- {
- super(120, 0);
- loadGraphic(costume, true, true);
- setOrigin(0, 0);
- addAnimation("normal", [0]);
- addAnimation("jumping", [1]);
- addAnimation("midAir", [2]);
- addAnimation("falling", [3]);
- addAnimation("running", [4, 5, 6, 7, 8], 15, true);
- play("normal", true);
- Global.spriteLayer.add(this);
- acceleration.y = GRAVITY;
- cameraFollow();
- }
- private function setAnimation():void
- {
- if ( FlxG.keys.LEFT || FlxG.keys.A )
- {
- play("running", false);
- facing = LEFT;
- }
- else if ( FlxG.keys.RIGHT || FlxG.keys.D )
- {
- play("running", false);
- facing = RIGHT;
- }
- else
- {
- play("normal", true);
- }
- }
- private function cameraFollow():void
- {
- FlxG.follow(this, 0.1);
- FlxG.followBounds(x - FlxG.width / 8, y - FlxG.height / 8, x + FlxG.width / 8, y + FlxG.height / 8);
- }
- override public function update():void
- {
- super.update();
- setAnimation();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement