码迷,mamicode.com
首页 > 其他好文 > 详细

this.standing

时间:2015-10-29 10:53:30      阅读:102      评论:0      收藏:0      [点我收藏+]

标签:


this.standing水平走的时候是true,纵向有速度是false,斜面轻微纵向速度也true
 
 

   var accel = this.standing ? this.accelG: this.accelA;
   if (this.currentAnim === this.anims.run && !this.sounds.walk.looping) {
    this.sounds.walk.loop();
   }
   if (this.currentAnim !== this.anims.run && this.sounds.walk.looping) {
    this.sounds.walk.stopLoop();
   }
   if (this.standing && ig.input.pressed(‘jump‘)) {
    this.sounds.jump.play();
   }
   if (ig.input.state(‘left‘)) {
     
    this.accel.x = -accel;
    this.flip = true;
   } else if (ig.input.state(‘right‘)) {
    this.accel.x = accel;
    this.flip = false;
   } else if (!this.standing) {
    this.vel.x *= 0.9;
    this.accel.x *= 0.9;
    if (Math.abs(this.vel.x) < 5) {
     this.vel.x = 0;
    }
    if (Math.abs(this.accel.x) < 5) {
     this.accel.x = 0;
    }
   } else {
    this.accel.x = 0;
   }
   if (this.jumpMax && this.standing) {
    this.jumpMax = false;
   }
   if (ig.input.pressed(‘jump‘) && this.standing) {
    this.jumpMax = false;
    this.standing = false;
    Delay.delay(this, 0.35,
    function() {
     this.jumpMax = true;
    });
   }
   if (!this.jumpMax && !this.standing) {
    this.vel.y = -this.jump / 1.5;
   }
   if (!ig.input.state(‘jump‘)) {
    this.jumpMax = true;
   }
   if (this.vel.x !== 0 && (ig.input.state(‘right‘) || ig.input.state(‘left‘))) {
    this.currentAnim = this.anims.run;
   } else {
    this.currentAnim = this.anims.idle;
   }
   if (!this.standing && this.vel.y < 0) {
    this.currentAnim = this.anims.jump;
   } else if (!this.standing && this.vel.y > 0) {
    this.currentAnim = this.anims.fall;
   }
   this.currentAnim.flip.x = this.flip;
   ig.Entity.prototype.update.call(this);

this.standing

标签:

原文地址:http://www.cnblogs.com/batmannolove/p/4919455.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!