您的位置:首页 > 其它

this.standing

2015-10-29 09:51 281 查看
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);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: