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);