设置图块和角色移动速度

This commit is contained in:
ckcz123 2021-07-24 22:05:31 +08:00
parent ceffe0d3b5
commit ddaa596377
3 changed files with 62 additions and 32 deletions

View File

@ -2290,6 +2290,7 @@ tooltip : 移动方向
helpUrl : /_docs/#/instruction helpUrl : /_docs/#/instruction
default : ["up", 0] default : ["up", 0]
colour : this.subColor colour : this.subColor
if (Move_List_0 == 'speed' && Int_0 < 16) throw '设置的移动速度值不得小于16';
return ', "' + Move_List_0 + ':' + Int_0 + '"'; return ', "' + Move_List_0 + ':' + Int_0 + '"';
*/; */;
@ -3915,8 +3916,8 @@ Key_List
/*Key_List ['yellowKey','blueKey','redKey','greenKey','steelKey']*/; /*Key_List ['yellowKey','blueKey','redKey','greenKey','steelKey']*/;
Move_List Move_List
: '上'|'下'|'左'|'右'|'前'|'后'|'左上'|'左下'|'右上'|'右下' : '上'|'下'|'左'|'右'|'前'|'后'|'左上'|'左下'|'右上'|'右下'|'设置速度'
/*Move_List ['up','down','left','right','forward','backward','leftup','leftdown','rightup','rightdown']*/; /*Move_List ['up','down','left','right','forward','backward','leftup','leftdown','rightup','rightdown','speed']*/;
NameMap_List NameMap_List
: '确定'|'取消'|'操作失败'|'光标移动'|'打开界面'|'读档'|'存档'|'获得道具'|'回血'|'炸弹'|'飞行器'|'开关门'|'上下楼'|'跳跃'|'破墙镐'|'阻激夹域'|'穿脱装备' : '确定'|'取消'|'操作失败'|'光标移动'|'打开界面'|'读档'|'存档'|'获得道具'|'回血'|'炸弹'|'飞行器'|'开关门'|'上下楼'|'跳跃'|'破墙镐'|'阻激夹域'|'穿脱装备'

View File

@ -3150,9 +3150,11 @@ events.prototype.eventMoveHero = function(steps, time, callback) {
var step = 0, moveSteps = (steps||[]).map(function (t) { var step = 0, moveSteps = (steps||[]).map(function (t) {
return [t.split(':')[0], parseInt(t.split(':')[1]||"1")]; return [t.split(':')[0], parseInt(t.split(':')[1]||"1")];
}).filter(function (t) { }).filter(function (t) {
return ['up','down','left','right','forward','backward','leftup','leftdown','rightup','rightdown'].indexOf(t[0])>=0; return ['up','down','left','right','forward','backward','leftup','leftdown','rightup','rightdown','speed'].indexOf(t[0])>=0
&& !(t[0] == 'speed' && t[1] < 16);
}); });
core.status.heroMoving = -1; core.status.heroMoving = -1;
var _run = function () {
var animate=window.setInterval(function() { var animate=window.setInterval(function() {
if (moveSteps.length==0) { if (moveSteps.length==0) {
delete core.animateFrame.asyncId[animate]; delete core.animateFrame.asyncId[animate];
@ -3162,12 +3164,21 @@ events.prototype.eventMoveHero = function(steps, time, callback) {
if (callback) callback(); if (callback) callback();
} }
else { else {
if (core.events._eventMoveHero_moving(++step, moveSteps)) if (step == 0 && moveSteps[0][0] == 'speed' && moveSteps[0][1] >= 16) {
time = moveSteps[0][1];
moveSteps.shift();
clearInterval(animate);
delete core.animateFrame.asyncId[animate];
_run();
}
else if (core.events._eventMoveHero_moving(++step, moveSteps))
step = 0; step = 0;
} }
}, core.status.replay.speed == 24 ? 1 : time / 8 / core.status.replay.speed); }, core.status.replay.speed == 24 ? 1 : time / 8 / core.status.replay.speed);
core.animateFrame.asyncId[animate] = true; core.animateFrame.asyncId[animate] = true;
}
_run();
} }
events.prototype._eventMoveHero_moving = function (step, moveSteps) { events.prototype._eventMoveHero_moving = function (step, moveSteps) {

View File

@ -2247,7 +2247,8 @@ maps.prototype.moveBlock = function (x, y, steps, time, keep, callback) {
var moveSteps = (steps||[]).map(function (t) { var moveSteps = (steps||[]).map(function (t) {
return [t.split(':')[0], parseInt(t.split(':')[1]||"1")]; return [t.split(':')[0], parseInt(t.split(':')[1]||"1")];
}).filter(function (t) { }).filter(function (t) {
return ['up','down','left','right','forward','backward','leftup','leftdown','rightup','rightdown'].indexOf(t[0])>=0; return ['up','down','left','right','forward','backward','leftup','leftdown','rightup','rightdown','speed'].indexOf(t[0])>=0
&& !(t[0] == 'speed' && t[1] < 16)
}); });
var canvases = this._initDetachedBlock(blockInfo, x, y, block.event.animate !== false); var canvases = this._initDetachedBlock(blockInfo, x, y, block.event.animate !== false);
this._moveDetachedBlock(blockInfo, 32 * x, 32 * y, 1, canvases); this._moveDetachedBlock(blockInfo, 32 * x, 32 * y, 1, canvases);
@ -2261,6 +2262,7 @@ maps.prototype.moveBlock = function (x, y, steps, time, keep, callback) {
maps.prototype._moveBlock_doMove = function (blockInfo, canvases, moveInfo, callback) { maps.prototype._moveBlock_doMove = function (blockInfo, canvases, moveInfo, callback) {
var animateTotal = core.icons._getAnimateFrames(blockInfo.cls), animateTime = 0; var animateTotal = core.icons._getAnimateFrames(blockInfo.cls), animateTime = 0;
var _run = function () {
var animate = window.setInterval(function () { var animate = window.setInterval(function () {
if (blockInfo.cls != 'tileset') { if (blockInfo.cls != 'tileset') {
animateTime += moveInfo.per_time; animateTime += moveInfo.per_time;
@ -2269,13 +2271,29 @@ maps.prototype._moveBlock_doMove = function (blockInfo, canvases, moveInfo, call
blockInfo.posX = (blockInfo.posX + 1) % animateTotal; blockInfo.posX = (blockInfo.posX + 1) % animateTotal;
} }
} }
if (moveInfo.moveSteps.length != 0) if (moveInfo.moveSteps.length != 0) {
core.maps._moveBlock_moving(blockInfo, canvases, moveInfo); if (core.maps._moveBlock_updateSpeed(moveInfo)) {
clearInterval(animate);
delete core.animateFrame.asyncId[animate];
_run();
}
else core.maps._moveBlock_moving(blockInfo, canvases, moveInfo);
}
else else
core.maps._moveJumpBlock_finished(blockInfo, canvases, moveInfo, animate, callback); core.maps._moveJumpBlock_finished(blockInfo, canvases, moveInfo, animate, callback);
}, moveInfo.per_time); }, moveInfo.per_time);
core.animateFrame.asyncId[animate] = true; core.animateFrame.asyncId[animate] = true;
}
_run();
}
maps.prototype._moveBlock_updateSpeed = function (moveInfo) {
if (moveInfo.step == 0 && moveInfo.moveSteps[0][0] == 'speed' && moveInfo.moveSteps[0][1] >= 16) {
moveInfo.per_time = moveInfo.moveSteps[0][1] / 16 / core.status.replay.speed;
moveInfo.moveSteps.shift();
return true;
}
return false;
} }
maps.prototype._moveBlock_updateDirection = function (blockInfo, moveInfo) { maps.prototype._moveBlock_updateDirection = function (blockInfo, moveInfo) {