Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package sramana.sprites
- {
- import zephyr.core.*;
- import zephyr.traits.graphics.Animation;
- import zephyr.traits.motion.LinearMotion;
- import sramana.world.*;
- import zephyr.utils.*;
- public class Player extends Element
- {
- public var anim:Animation;
- public var motion:LinearMotion;
- [Embed (source = 'graphics/player.png')] static public const WalkImage:Class;
- public function Player()
- {
- super(0, 0, 16, 32);
- this.motion = new LinearMotion(this);
- this.anim = new Animation(this);
- this.anim.add('walk', Cached.bitmap(WalkImage), [0, 1, 2, 3, 4, 5, 6, 7], 10);
- this.anim.play('walk');
- this.motion.acceleration.y = 30;
- this.update.add(playerMovement);
- }
- public function playerMovement()
- {
- if (App.keys.pressed('LEFT'))
- {
- this.motion.velocity.x = -50;
- }
- if (App.keys.pressed('RIGHT'))
- {
- this.motion.velocity.x = 50;
- }
- else this.motion.velocity.x = 0;
- }
- }
- }
Add Comment
Please, Sign In to add comment