Hero move effect

This commit is contained in:
oc 2018-12-05 14:51:35 +08:00
parent 7429ac3248
commit 9634e2c167
2 changed files with 13 additions and 2 deletions

View File

@ -59,6 +59,7 @@ control.prototype.setRequestAnimationFrame = function () {
core.animateFrame.boxTime = core.animateFrame.boxTime||timestamp;
core.animateFrame.animateTime = core.animateFrame.animateTime||timestamp;
core.animateFrame.moveTime = core.animateFrame.moveTime||timestamp;
core.animateFrame.lastLegTime = core.animateFrame.lastLegTime||timestamp;
core.animateFrame.weather.time = core.animateFrame.weather.time||timestamp;
// move time
@ -122,15 +123,23 @@ control.prototype.setRequestAnimationFrame = function () {
}
// Hero move
if (timestamp-core.animateFrame.moveTime>16 && core.isset(core.status.heroMoving) && core.status.heroMoving>0) {
if (core.isPlaying() && core.status.heroMoving>0) {
var x=core.getHeroLoc('x'), y=core.getHeroLoc('y'), direction = core.getHeroLoc('direction');
// 200ms换腿
if (timestamp - core.animateFrame.moveTime > (core.values.moveSpeed||100)) {
core.animateFrame.leftLeg = !core.animateFrame.leftLeg;
core.animateFrame.moveTime = timestamp;
}
core.drawHero(direction, x, y, core.animateFrame.leftLeg?'leftFoot':'rightFoot', 4*core.status.heroMoving);
/*
if (core.status.heroMoving<=4) {
core.drawHero(direction, x, y, 'leftFoot', 4*core.status.heroMoving);
}
else if (core.status.heroMoving<=8) {
core.drawHero(direction, x, y, 'rightFoot', 4*core.status.heroMoving);
}
core.animateFrame.moveTime = timestamp;
*/
}
// weather

View File

@ -34,6 +34,8 @@ function core() {
'boxTime': null,
'animateTime': null,
'moveTime': null,
'lastLegTime': null,
'leftLeg': true,
'speed': null,
'weather': {
'time': null,