Update control.js

This commit is contained in:
qweasz687 2021-08-10 15:56:08 +08:00 committed by GitHub
parent f642c2a11b
commit 24af8595a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -801,7 +801,7 @@ control.prototype.tryMoveDirectly = function (destX, destY) {
} }
////// 绘制勇士 ////// ////// 绘制勇士 //////
control.prototype.drawHero = function (status, offset, frame) { control.prototype.drawHero = function (status, offset, frame, noGather) {
if (!core.isPlaying() || !core.status.floorId || core.status.gameOver) return; if (!core.isPlaying() || !core.status.floorId || core.status.gameOver) return;
var x = core.getHeroLoc('x'), y = core.getHeroLoc('y'), direction = core.getHeroLoc('direction'); var x = core.getHeroLoc('x'), y = core.getHeroLoc('y'), direction = core.getHeroLoc('direction');
status = status || 'stop'; status = status || 'stop';
@ -820,7 +820,7 @@ control.prototype.drawHero = function (status, offset, frame) {
this._drawHero_updateViewport(x, y, offset); this._drawHero_updateViewport(x, y, offset);
if (!core.hasFlag('hideHero')) { if (!core.hasFlag('hideHero')) {
this._drawHero_draw(direction, x, y, status, offset, frame); this._drawHero_draw(direction, x, y, status, offset, frame, noGather);
} }
} }
@ -836,15 +836,15 @@ control.prototype._drawHero_updateViewport = function (x, y, offset) {
core.control.updateViewport(); core.control.updateViewport();
} }
control.prototype._drawHero_draw = function (direction, x, y, status, offset, frame) { control.prototype._drawHero_draw = function (direction, x, y, status, offset, frame, noGather) {
this._drawHero_getDrawObjs(direction, x, y, status, offset).forEach(function (block) { this._drawHero_getDrawObjs(direction, x, y, status, offset, noGather).forEach(function (block) {
core.drawImage('hero', block.img, (block.heroIcon[block.status] + (frame || 0))%4*block.width, core.drawImage('hero', block.img, (block.heroIcon[block.status] + (frame || 0))%4*block.width,
block.heroIcon.loc * block.height, block.width, block.height, block.heroIcon.loc * block.height, block.width, block.height,
block.posx+(32-block.width)/2, block.posy+32-block.height, block.width, block.height); block.posx+(32-block.width)/2, block.posy+32-block.height, block.width, block.height);
}); });
} }
control.prototype._drawHero_getDrawObjs = function (direction, x, y, status, offset) { control.prototype._drawHero_getDrawObjs = function (direction, x, y, status, offset, noGather) {
var heroIconArr = core.material.icons.hero, drawObjs = [], index = 0; var heroIconArr = core.material.icons.hero, drawObjs = [], index = 0;
drawObjs.push({ drawObjs.push({
"img": core.material.images.hero, "img": core.material.images.hero,
@ -856,6 +856,8 @@ control.prototype._drawHero_getDrawObjs = function (direction, x, y, status, off
"status": status, "status": status,
"index": index++, "index": index++,
}); });
// 不重绘跟随者 比如说跳跃时……
if (!noGather) {
core.status.hero.followers.forEach(function(t) { core.status.hero.followers.forEach(function(t) {
drawObjs.push({ drawObjs.push({
"img": core.material.images.images[t.name], "img": core.material.images.images[t.name],
@ -868,6 +870,7 @@ control.prototype._drawHero_getDrawObjs = function (direction, x, y, status, off
"index": index++ "index": index++
}); });
}); });
}
return drawObjs.sort(function(a, b) { return drawObjs.sort(function(a, b) {
return a.posy==b.posy?b.index-a.index:a.posy-b.posy; return a.posy==b.posy?b.index-a.index:a.posy-b.posy;
}); });