setViewport动画时间
This commit is contained in:
parent
579a4363cc
commit
8348d1a2b3
@ -441,7 +441,7 @@ moveOneStep: fn(callback?: fn())
|
|||||||
每移动一格后执行的事件
|
每移动一格后执行的事件
|
||||||
【异步脚本,请勿在脚本中直接调用(而是使用对应的事件),否则可能导致录像出错】
|
【异步脚本,请勿在脚本中直接调用(而是使用对应的事件),否则可能导致录像出错】
|
||||||
|
|
||||||
moveViewport: fn(steps?: ?, time?: number, callback?: fn())
|
moveViewport: fn(x: number, y: number, time?: number, callback?: fn())
|
||||||
移动视野范围
|
移动视野范围
|
||||||
|
|
||||||
nearHero: fn(x: number, y: number, n?: number) -> bool
|
nearHero: fn(x: number, y: number, n?: number) -> bool
|
||||||
@ -598,9 +598,9 @@ setSwitch: fn(x: number, y: number, floorId?: string, name: string, value?: ?)
|
|||||||
setToolbarButton: fn(useButton?: bool)
|
setToolbarButton: fn(useButton?: bool)
|
||||||
改变工具栏为按钮1-8
|
改变工具栏为按钮1-8
|
||||||
|
|
||||||
setViewport: fn(x?: number, y?: number)
|
setViewport: fn(px?: number, py?: number)
|
||||||
设置视野范围
|
设置视野范围
|
||||||
x,y: 左上角相对大地图的像素坐标,不需要为32倍数
|
px,py: 左上角相对大地图的像素坐标,不需要为32倍数
|
||||||
|
|
||||||
setWeather: fn(type?: string, level?: number)
|
setWeather: fn(type?: string, level?: number)
|
||||||
设置天气,不计入存档。如需长期生效请使用core.events._action_setWeather()函数
|
设置天气,不计入存档。如需长期生效请使用core.events._action_setWeather()函数
|
||||||
|
|||||||
@ -2473,8 +2473,8 @@ var terndefs_f6783a0a_522d_417e_8407_94c67b692e50 = [
|
|||||||
"!type": "fn(index?: number, callback?: fn(data: ?))"
|
"!type": "fn(index?: number, callback?: fn(data: ?))"
|
||||||
},
|
},
|
||||||
"setViewport": {
|
"setViewport": {
|
||||||
"!doc": "设置视野范围<br/>x,y: 左上角相对大地图的像素坐标,不需要为32倍数",
|
"!doc": "设置视野范围<br/>px,py: 左上角相对大地图的像素坐标,不需要为32倍数",
|
||||||
"!type": "fn(x?: number, y?: number)"
|
"!type": "fn(px?: number, py?: number)"
|
||||||
},
|
},
|
||||||
"chooseReplayFile": {
|
"chooseReplayFile": {
|
||||||
"!doc": "选择录像文件",
|
"!doc": "选择录像文件",
|
||||||
@ -2522,7 +2522,7 @@ var terndefs_f6783a0a_522d_417e_8407_94c67b692e50 = [
|
|||||||
},
|
},
|
||||||
"moveViewport": {
|
"moveViewport": {
|
||||||
"!doc": "移动视野范围",
|
"!doc": "移动视野范围",
|
||||||
"!type": "fn(steps?: ?, time?: number, callback?: fn())"
|
"!type": "fn(x: number, y: number, time?: number, callback?: fn())"
|
||||||
},
|
},
|
||||||
"syncLoad": {
|
"syncLoad": {
|
||||||
"!doc": "从服务器加载存档",
|
"!doc": "从服务器加载存档",
|
||||||
|
|||||||
@ -673,7 +673,7 @@ action
|
|||||||
| changeFloor_s
|
| changeFloor_s
|
||||||
| changePos_s
|
| changePos_s
|
||||||
| setViewport_s
|
| setViewport_s
|
||||||
| moveViewport_s
|
| setViewport_1_s
|
||||||
| useItem_s
|
| useItem_s
|
||||||
| loadEquip_s
|
| loadEquip_s
|
||||||
| unloadEquip_s
|
| unloadEquip_s
|
||||||
@ -1822,35 +1822,41 @@ return code;
|
|||||||
*/;
|
*/;
|
||||||
|
|
||||||
setViewport_s
|
setViewport_s
|
||||||
: '设置视角' '左上角坐标' 'x' PosString? ',' 'y' PosString? Newline
|
: '设置视角' '左上角坐标' 'x' PosString? ',' 'y' PosString? '动画时间' Int '不等待执行完毕' Bool Newline
|
||||||
|
|
||||||
|
|
||||||
/* setViewport_s
|
/* setViewport_s
|
||||||
tooltip : setViewport: 设置视角
|
tooltip : setViewport: 设置视角
|
||||||
helpUrl : /_docs/#/instruction
|
helpUrl : /_docs/#/instruction
|
||||||
default : ["",""]
|
default : ["","",0,false]
|
||||||
selectPoint : ["PosString_0", "PosString_1"]
|
selectPoint : ["PosString_0", "PosString_1"]
|
||||||
colour : this.soundColor
|
colour : this.soundColor
|
||||||
var loc = '';
|
var loc = '';
|
||||||
if (PosString_0 && PosString_1) {
|
if (PosString_0 && PosString_1) {
|
||||||
loc = ', "loc": ['+PosString_0+','+PosString_1+']';
|
loc = ', "loc": ['+PosString_0+','+PosString_1+']';
|
||||||
}
|
}
|
||||||
var code = '{"type": "setViewport"'+loc+'},\n';
|
Int_0 = Int_0 ?(', "time": '+Int_0):'';
|
||||||
|
Bool_0 = Bool_0?', "async": true':'';
|
||||||
|
var code = '{"type": "setViewport"'+loc+Int_0+Bool_0+'},\n';
|
||||||
return code;
|
return code;
|
||||||
*/;
|
*/;
|
||||||
|
|
||||||
moveViewport_s
|
setViewport_1_s
|
||||||
: '移动视角' '动画时间' IntString '不等待执行完毕' Bool BGNL? StepString Newline
|
: '设置视角' '增量坐标' 'dx' PosString? ',' 'dy' PosString? '动画时间' Int '不等待执行完毕' Bool Newline
|
||||||
|
|
||||||
|
|
||||||
/* moveViewport_s
|
/* setViewport_1_s
|
||||||
tooltip : moveViewport:移动视角
|
tooltip : setViewport: 设置视角
|
||||||
helpUrl : /_docs/#/instruction
|
helpUrl : /_docs/#/instruction
|
||||||
default : [300,false,"上右3下2左"]
|
default : ["0","0",0,false]
|
||||||
colour : this.soundColor
|
colour : this.soundColor
|
||||||
IntString_0 = IntString_0 ?(', "time": '+IntString_0):'';
|
var loc = '';
|
||||||
|
if (PosString_0 && PosString_1) {
|
||||||
|
loc = ', "dxy": ['+PosString_0+','+PosString_1+']';
|
||||||
|
}
|
||||||
|
Int_0 = Int_0 ?(', "time": '+Int_0):'';
|
||||||
Bool_0 = Bool_0?', "async": true':'';
|
Bool_0 = Bool_0?', "async": true':'';
|
||||||
var code = '{"type": "moveViewport"'+IntString_0+Bool_0+', "steps": '+JSON.stringify(StepString_0)+'},\n';
|
var code = '{"type": "setViewport"'+loc+Int_0+Bool_0+'},\n';
|
||||||
return code;
|
return code;
|
||||||
*/;
|
*/;
|
||||||
|
|
||||||
|
|||||||
@ -461,13 +461,14 @@ ActionParser.prototype.parseAction = function() {
|
|||||||
data.name,animate_loc,data.alignWindow||false,data.async||false,this.next]);
|
data.name,animate_loc,data.alignWindow||false,data.async||false,this.next]);
|
||||||
break;
|
break;
|
||||||
case "setViewport": // 设置视角
|
case "setViewport": // 设置视角
|
||||||
|
if (data.dxy) {
|
||||||
|
this.next = MotaActionBlocks['setViewport_1_s'].xmlText([
|
||||||
|
data.dxy[0],data.dxy[1],data.time||0,data.async||false,this.next]);
|
||||||
|
} else {
|
||||||
data.loc = data.loc||['',''];
|
data.loc = data.loc||['',''];
|
||||||
this.next = MotaActionBlocks['setViewport_s'].xmlText([
|
this.next = MotaActionBlocks['setViewport_s'].xmlText([
|
||||||
data.loc[0],data.loc[1],this.next]);
|
data.loc[0],data.loc[1],data.time||0,data.async||false,this.next]);
|
||||||
break;
|
}
|
||||||
case "moveViewport": // 移动视角
|
|
||||||
this.next = MotaActionBlocks['moveViewport_s'].xmlText([
|
|
||||||
data.time,data.async||false,this.StepString(data.steps),this.next]);
|
|
||||||
break;
|
break;
|
||||||
case "vibrate": // 画面震动
|
case "vibrate": // 画面震动
|
||||||
this.next = MotaActionBlocks['vibrate_s'].xmlText([data.time||0, data.async||false, this.next]);
|
this.next = MotaActionBlocks['vibrate_s'].xmlText([data.time||0, data.async||false, this.next]);
|
||||||
|
|||||||
@ -186,7 +186,7 @@ editor_blocklyconfig=(function(){
|
|||||||
MotaActionBlocks['vibrate_s'].xmlText(),
|
MotaActionBlocks['vibrate_s'].xmlText(),
|
||||||
MotaActionBlocks['animate_s'].xmlText(),
|
MotaActionBlocks['animate_s'].xmlText(),
|
||||||
MotaActionBlocks['setViewport_s'].xmlText(),
|
MotaActionBlocks['setViewport_s'].xmlText(),
|
||||||
MotaActionBlocks['moveViewport_s'].xmlText(),
|
MotaActionBlocks['setViewport_1_s'].xmlText(),
|
||||||
MotaActionBlocks['showStatusBar_s'].xmlText(),
|
MotaActionBlocks['showStatusBar_s'].xmlText(),
|
||||||
MotaActionBlocks['hideStatusBar_s'].xmlText(),
|
MotaActionBlocks['hideStatusBar_s'].xmlText(),
|
||||||
MotaActionBlocks['showHero_s'].xmlText(),
|
MotaActionBlocks['showHero_s'].xmlText(),
|
||||||
|
|||||||
@ -953,9 +953,9 @@ control.prototype.updateViewport = function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
////// 设置视野范围 //////
|
////// 设置视野范围 //////
|
||||||
control.prototype.setViewport = function (x, y) {
|
control.prototype.setViewport = function (px, py) {
|
||||||
core.bigmap.offsetX = core.clamp(x, 0, 32 * core.bigmap.width - core.__PIXELS__);
|
core.bigmap.offsetX = core.clamp(px, 0, 32 * core.bigmap.width - core.__PIXELS__);
|
||||||
core.bigmap.offsetY = core.clamp(y, 0, 32 * core.bigmap.height - core.__PIXELS__);
|
core.bigmap.offsetY = core.clamp(py, 0, 32 * core.bigmap.height - core.__PIXELS__);
|
||||||
this.updateViewport();
|
this.updateViewport();
|
||||||
// ------ hero层也需要!
|
// ------ hero层也需要!
|
||||||
var hero_x = core.clamp((core.getHeroLoc('x') - core.__HALF_SIZE__) * 32, 0, 32*core.bigmap.width-core.__PIXELS__);
|
var hero_x = core.clamp((core.getHeroLoc('x') - core.__HALF_SIZE__) * 32, 0, 32*core.bigmap.width-core.__PIXELS__);
|
||||||
@ -964,36 +964,33 @@ control.prototype.setViewport = function (x, y) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
////// 移动视野范围 //////
|
////// 移动视野范围 //////
|
||||||
control.prototype.moveViewport = function (steps, time, callback) {
|
control.prototype.moveViewport = function (x, y, time, callback) {
|
||||||
time = time || core.values.moveSpeed;
|
time = time || 0;
|
||||||
var step = 0, moveSteps = (steps||[]).filter(function (t) {
|
time /= Math.max(core.status.replay.speed, 1)
|
||||||
return ['up','down','left','right'].indexOf(t)>=0;
|
var per_time = 10, step = parseInt(time / per_time);
|
||||||
});
|
if (step <= 0) {
|
||||||
|
this.setViewport(32 * x, 32 * y);
|
||||||
|
if (callback) callback();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var px = core.clamp(32 * x, 0, 32 * core.bigmap.width - core.__PIXELS__);
|
||||||
|
var py = core.clamp(32 * y, 0, 32 * core.bigmap.width - core.__PIXELS__);
|
||||||
|
var dx = (px - core.bigmap.offsetX) / step, dy = (py - core.bigmap.offsetY) / step;
|
||||||
|
|
||||||
var animate=window.setInterval(function() {
|
var animate=window.setInterval(function() {
|
||||||
if (moveSteps.length==0) {
|
core.setViewport(core.bigmap.offsetX + dx, core.bigmap.offsetY + dy);
|
||||||
|
step--;
|
||||||
|
if (step <= 0) {
|
||||||
delete core.animateFrame.asyncId[animate];
|
delete core.animateFrame.asyncId[animate];
|
||||||
clearInterval(animate);
|
clearInterval(animate);
|
||||||
|
core.setViewport(px, py);
|
||||||
if (callback) callback();
|
if (callback) callback();
|
||||||
}
|
}
|
||||||
else {
|
}, per_time);
|
||||||
if (core.control._moveViewport_moving(++step, moveSteps))
|
|
||||||
step = 0;
|
|
||||||
}
|
|
||||||
}, time / 16 / core.status.replay.speed);
|
|
||||||
|
|
||||||
core.animateFrame.asyncId[animate] = true;
|
core.animateFrame.asyncId[animate] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
control.prototype._moveViewport_moving = function (step, moveSteps) {
|
|
||||||
var direction = moveSteps[0], scan = core.utils.scan[direction];
|
|
||||||
core.setViewport(core.bigmap.offsetX + 2 * scan.x, core.bigmap.offsetY + 2 * scan.y);
|
|
||||||
if (step == 16) {
|
|
||||||
moveSteps.shift();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
////// 获得勇士面对位置的x坐标 //////
|
////// 获得勇士面对位置的x坐标 //////
|
||||||
control.prototype.nextX = function(n) {
|
control.prototype.nextX = function(n) {
|
||||||
if (n == null) n = 1;
|
if (n == null) n = 1;
|
||||||
|
|||||||
@ -1426,18 +1426,15 @@ events.prototype._action_animate = function (data, x, y, prefix) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
events.prototype._action_setViewport = function (data, x, y, prefix) {
|
events.prototype._action_setViewport = function (data, x, y, prefix) {
|
||||||
if (data.loc == null) {
|
if (data.dxy != null) {
|
||||||
core.drawHero();
|
data.loc = [core.bigmap.offsetX / 32 + (core.calValue(data.dxy[0], prefix) || 0), core.bigmap.offsetY / 32 + (core.calValue(data.dxy[1], prefix) || 0)];
|
||||||
|
} else if (data.loc == null) {
|
||||||
|
data.loc = [core.getHeroLoc('x') - core.__HALF_SIZE__, core.getHeroLoc('y') - core.__HALF_SIZE__];
|
||||||
|
} else {
|
||||||
|
data.loc = this.__action_getLoc(data.loc, x, y, prefix);
|
||||||
}
|
}
|
||||||
else {
|
console.log(data.loc);
|
||||||
var loc = this.__action_getLoc(data.loc, x, y, prefix);
|
this.__action_doAsyncFunc(data.async, core.moveViewport, data.loc[0], data.loc[1], data.time);
|
||||||
core.setViewport(32 * loc[0], 32 * loc[1]);
|
|
||||||
}
|
|
||||||
core.doAction();
|
|
||||||
}
|
|
||||||
|
|
||||||
events.prototype._action_moveViewport = function (data, x, y, prefix) {
|
|
||||||
this.__action_doAsyncFunc(data.async, core.moveViewport, data.steps, data.time);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
events.prototype._action_move = function (data, x, y, prefix) {
|
events.prototype._action_move = function (data, x, y, prefix) {
|
||||||
|
|||||||
6
runtime.d.ts
vendored
6
runtime.d.ts
vendored
@ -632,12 +632,12 @@ declare class control {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置视野范围
|
* 设置视野范围
|
||||||
* x,y: 左上角相对大地图的像素坐标,不需要为32倍数
|
* px,py: 左上角相对大地图的像素坐标,不需要为32倍数
|
||||||
*/
|
*/
|
||||||
setViewport(x?: number, y?: number): void
|
setViewport(px?: number, py?: number): void
|
||||||
|
|
||||||
/** 移动视野范围 */
|
/** 移动视野范围 */
|
||||||
moveViewport(steps?: any, time?: number, callback?: () => any): void
|
moveViewport(x: number, y: number, time?: number, callback?: () => any): void
|
||||||
|
|
||||||
/** 更新跟随者坐标 */
|
/** 更新跟随者坐标 */
|
||||||
updateFollowers(): void
|
updateFollowers(): void
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user