Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.lordned
- {
- import com.senocular.utils.KeyObject;
- import flash.display.Sprite;
- import flash.ui.Keyboard;
- import me.Utils;
- /**
- * ...
- * @author Matt "Lord Ned" Hoffman
- */
- public class Ramona extends MovieClipComponent
- {
- //Keyboard Input
- var key:KeyObject;
- //Player Movement Variables
- var playerSpeed:int;
- var playerIsMoving:Boolean;
- public function Ramona()
- {
- super();
- trace("Ramona created.");
- playerSpeed = 5;
- loops = false;
- key = new KeyObject(this.parent.stage);
- Engine.profiler.Register(this, "x");
- Engine.profiler.Register(this, "y");
- }
- override public function Update():void
- {
- /*trace("Scale: " + (y/100) + ", Clamped: " + Utils.Clamp((y / 100), 0.8, 1.2));
- scaleX = Utils.Clamp((y / 100), 0.9, 1.2);
- scaleY = Utils.Clamp((y / 100), 0.9, 1.2);*/
- if (key.isDown(Keyboard.LEFT))
- {
- if(currentLabel != "running")
- gotoAndPlay("running");
- loops = true;
- this.x -= playerSpeed;
- scaleX = -1;
- playerIsMoving = true;
- }
- else if (key.isDown(Keyboard.RIGHT))
- {
- loops = true;
- if(currentLabel != "running")
- gotoAndPlay("running");
- this.x += playerSpeed;
- this.scaleX = 1;
- playerIsMoving = true;
- }
- else
- {
- playerIsMoving = false;
- }
- if (key.isDown(Keyboard.UP))
- {
- this.y -= playerSpeed;
- }
- else if (key.isDown(Keyboard.DOWN))
- {
- this.y += playerSpeed;
- }
- if (key.isDown(Keyboard.SPACE))
- {
- gotoAndPlay("attack_hammer");
- loops = true;
- for (var i:int = 0; i < Engine.ComponentSprite.numChildren; i++)
- {
- if (hitTestObject(Engine.ComponentSprite.getChildAt(i)))
- {
- Component(Engine.ComponentSprite.getChildAt(i)).OnHit();
- }
- }
- }
- else
- {
- if ((currentLabel != "attack_hammer") && (currentLabel != "running"))
- {
- loops = false;
- gotoAndStop("default");
- }
- }
- trace("PlayerIsmoving: " + playerIsMoving);
- super.Update();
- }
- }
- }
Add Comment
Please, Sign In to add comment