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);
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);
相关文章推荐
- 地图json jquery
- libcurl 下载ftp服务器全部文件
- 这次GDC China 2015的总结与关卡设计教程的梳理
- 【黑马程序员】基本概念——Java复习笔记
- 喝酒之道、多喝不宜自毙自!
- C++中的volatile修饰符的作用
- bzoj4027: [HEOI2015]兔子与樱花
- win2012的VMQ好像是鸡肋
- mybatis例子及mybatis和spring整合
- 用python求解一元二次方程组
- Android 反编译
- Linux 软链接和硬链接的理解与学习
- 最好的科普著作《追寻记忆的痕迹》——神经与精神的历史和未来
- 更新游戏后还是那个storage的数据
- 包裹bug问题但是浏览器能玩
- 命令下运行jar包
- java保留2位小数
- c++文件读写
- 字节码
- apply方法和spray的dsl理解