From c42c419afce9f03f52e45f004d6f54acba0b8c7a Mon Sep 17 00:00:00 2001 From: ckcz123 Date: Thu, 26 Dec 2019 16:18:45 +0800 Subject: [PATCH] drawHeroAnimate --- libs/control.js | 10 +++------- libs/core.js | 1 + libs/events.js | 2 ++ 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/libs/control.js b/libs/control.js index 4fbf1ba9..faf63818 100644 --- a/libs/control.js +++ b/libs/control.js @@ -170,13 +170,7 @@ control.prototype._animationFrame_animate = function (timestamp) { }); core.status.animateObjs.forEach(function (obj) { if (obj.hero) { - // calculate position - var x = core.getHeroLoc('x'), y = core.getHeroLoc('y'), direction = core.getHeroLoc('direction'); - var offset = 4 * core.status.heroMoving; - if (offset < 0) offset = 0; - var way = core.utils.scan[direction]; - var centerX = 32 * x + way.x * offset + 16, centerY = 32 * y + way.y * offset + 16; - core.maps._drawAnimateFrame(obj.animate, centerX, centerY, obj.index++); + core.maps._drawAnimateFrame(obj.animate, core.status.heroCenter.px, core.status.heroCenter.py, obj.index++); } else { core.maps._drawAnimateFrame(obj.animate, obj.centerX, obj.centerY, obj.index++); } @@ -816,6 +810,8 @@ control.prototype.drawHero = function (status, offset) { core.bigmap.offsetY = core.clamp((y - core.__HALF_SIZE__) * 32 + offsetY, 0, 32*core.bigmap.height-core.__PIXELS__); core.clearAutomaticRouteNode(x+dx, y+dy); core.clearMap('hero'); + core.status.heroCenter.px = 32 * x + offsetX + 16; + core.status.heroCenter.py = 32 * y + offsetY + 32 - core.material.icons.hero.height / 2; if (!core.hasFlag('hideHero')) { this._drawHero_getDrawObjs(direction, x, y, status, offset).forEach(function (block) { diff --git a/libs/core.js b/libs/core.js index aacb8b92..72f8a34a 100644 --- a/libs/core.js +++ b/libs/core.js @@ -116,6 +116,7 @@ function core() { // 勇士属性 'hero': {}, + 'heroCenter': {'px': null, 'py': null}, // 当前地图 'floorId': null, diff --git a/libs/events.js b/libs/events.js index 1b84542b..51f57286 100644 --- a/libs/events.js +++ b/libs/events.js @@ -2700,6 +2700,8 @@ events.prototype._jumpHero_jumping = function (jumpInfo) { core.control.updateViewport(); core.drawImage('hero', core.material.images.hero, jumpInfo.icon.stop, jumpInfo.icon.loc * height, width, height, nowx + (32 - width) / 2 - core.bigmap.offsetX, nowy + 32-height - core.bigmap.offsetY, width, height); + core.status.heroCenter.px = nowx + 16; + core.status.heroCenter.py = nowy + 32 - height / 2; } events.prototype._jumpHero_finished = function (animate, ex, ey, callback) {