From 9634e2c167c6cbe0126f5b4545eb05a7753727a3 Mon Sep 17 00:00:00 2001 From: oc Date: Wed, 5 Dec 2018 14:51:35 +0800 Subject: [PATCH] Hero move effect --- libs/control.js | 13 +++++++++++-- libs/core.js | 2 ++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/libs/control.js b/libs/control.js index c380fb3b..0c15502b 100644 --- a/libs/control.js +++ b/libs/control.js @@ -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 diff --git a/libs/core.js b/libs/core.js index f6cfe375..6d01ebb9 100644 --- a/libs/core.js +++ b/libs/core.js @@ -34,6 +34,8 @@ function core() { 'boxTime': null, 'animateTime': null, 'moveTime': null, + 'lastLegTime': null, + 'leftLeg': true, 'speed': null, 'weather': { 'time': null,