Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /******************************************8
- * Update
- ******************************************/
- update: function()
- {
- var idleSpeed = 120;
- var fastSpeed = 150;
- var backSpeed = 80;
- if( ig.input.state('upArrow') ){
- this.vel.y = -idleSpeed;
- this.accel.x = this.speed;
- this.currentAnim = this.anims.bankLeft;
- }
- else if ( ig.input.state('downArrow') ){
- this.vel.y = idleSpeed;
- this.accel.x = this.speed;
- this.currentAnim = this.anims.bankRight;
- }
- if( ig.input.state('leftArrow') ){
- this.vel.x = backSpeed;
- }
- else if( ig.input.state('rightArrow') ){
- this.vel.x = fastSpeed;
- }
- else{
- this.vel.x = idleSpeed;
- this.currentAnim = this.anims.idle;
- }
- // set the current animation, based on the player's speed
- //upArrow
- if( this.vel.y < 0 ) {
- this.currentAnim = this.anims.bankLeft;
- //downArrow
- }else if( this.vel.y > 20 ) {
- this.currentAnim = this.anims.bankRight;
- }else if (this.vel.y = 0){
- this.currentAnim = this.anims.idle
- }
- else if( this.vel.x > idleSpeed ) {
- //rightArrow
- this.currentAnim = this.anims.speedBurst;
- }else if(this.vel.x > idleSpeed){
- //leftArrow
- this.currentanim = this.anims.moveBack;
- }else{
- this.currentAnim = this.anims.idle;
- }
- this.currentAnim.flip.x = this.flip;
- // Shooting
- var isShooting = ig.input.state('shoot');
- if (isShooting && this.lastShootTimer.delta() > 0) {
- ig.game.spawnEntity(EntityBullet, this.pos.x + 44, this.pos.y +5, {flip:this.flip});
- this.lastShootTimer.set(0.09);
- }
- if (isShooting && !this.wasShooting) {
- this.wasShooting = true;
- }
- else if (this.wasShooting && !isShooting) {
- this.wasShooting = false;
- }
- // Movement
- this.parent();
- },
RAW Paste Data