Guest User

Untitled

a guest
Nov 23rd, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package sramana.sprites
  2. {
  3.     import zephyr.core.*;
  4.     import zephyr.traits.graphics.Animation;
  5.     import zephyr.traits.motion.LinearMotion;
  6.     import sramana.world.*;
  7.     import zephyr.utils.*;    
  8.      
  9.     public class Player extends Element
  10.     {
  11.         public var anim:Animation;
  12.         public var motion:LinearMotion;
  13.          
  14.         [Embed (source = 'graphics/player.png')] static public const WalkImage:Class;
  15.          
  16.         public function Player()
  17.         {
  18.             super(0, 0, 16, 32);
  19.             this.motion = new LinearMotion(this);
  20.             this.anim = new Animation(this);
  21.             this.anim.add('walk', Cached.bitmap(WalkImage), [0, 1, 2, 3, 4, 5, 6, 7], 10);
  22.             this.anim.play('walk');
  23.             this.motion.acceleration.y = 30;
  24.             this.update.add(playerMovement);
  25.         }
  26.        
  27.         public function playerMovement()
  28.         {
  29.             if (App.keys.pressed('LEFT'))
  30.             {
  31.                 this.motion.velocity.x = -50;
  32.                             }
  33.  
  34.             if (App.keys.pressed('RIGHT'))
  35.             {
  36.                 this.motion.velocity.x = 50;
  37.             }
  38.            
  39.             else this.motion.velocity.x = 0;
  40.        
  41.         }
  42.        
  43.        
  44.     }
  45. }
Add Comment
Please, Sign In to add comment