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
|
||||
@ -598,9 +598,9 @@ setSwitch: fn(x: number, y: number, floorId?: string, name: string, value?: ?)
|
||||
setToolbarButton: fn(useButton?: bool)
|
||||
改变工具栏为按钮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)
|
||||
设置天气,不计入存档。如需长期生效请使用core.events._action_setWeather()函数
|
||||
|
||||
@ -2473,8 +2473,8 @@ var terndefs_f6783a0a_522d_417e_8407_94c67b692e50 = [
|
||||
"!type": "fn(index?: number, callback?: fn(data: ?))"
|
||||
},
|
||||
"setViewport": {
|
||||
"!doc": "设置视野范围<br/>x,y: 左上角相对大地图的像素坐标,不需要为32倍数",
|
||||
"!type": "fn(x?: number, y?: number)"
|
||||
"!doc": "设置视野范围<br/>px,py: 左上角相对大地图的像素坐标,不需要为32倍数",
|
||||
"!type": "fn(px?: number, py?: number)"
|
||||
},
|
||||
"chooseReplayFile": {
|
||||
"!doc": "选择录像文件",
|
||||
@ -2522,7 +2522,7 @@ var terndefs_f6783a0a_522d_417e_8407_94c67b692e50 = [
|
||||
},
|
||||
"moveViewport": {
|
||||
"!doc": "移动视野范围",
|
||||
"!type": "fn(steps?: ?, time?: number, callback?: fn())"
|
||||
"!type": "fn(x: number, y: number, time?: number, callback?: fn())"
|
||||
},
|
||||
"syncLoad": {
|
||||
"!doc": "从服务器加载存档",
|
||||
|
||||
@ -673,7 +673,7 @@ action
|
||||
| changeFloor_s
|
||||
| changePos_s
|
||||
| setViewport_s
|
||||
| moveViewport_s
|
||||
| setViewport_1_s
|
||||
| useItem_s
|
||||
| loadEquip_s
|
||||
| unloadEquip_s
|
||||
@ -1822,35 +1822,41 @@ return code;
|
||||
*/;
|
||||
|
||||
setViewport_s
|
||||
: '设置视角' '左上角坐标' 'x' PosString? ',' 'y' PosString? Newline
|
||||
: '设置视角' '左上角坐标' 'x' PosString? ',' 'y' PosString? '动画时间' Int '不等待执行完毕' Bool Newline
|
||||
|
||||
|
||||
/* setViewport_s
|
||||
tooltip : setViewport: 设置视角
|
||||
helpUrl : /_docs/#/instruction
|
||||
default : ["",""]
|
||||
default : ["","",0,false]
|
||||
selectPoint : ["PosString_0", "PosString_1"]
|
||||
colour : this.soundColor
|
||||
var loc = '';
|
||||
if (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;
|
||||
*/;
|
||||
|
||||
moveViewport_s
|
||||
: '移动视角' '动画时间' IntString '不等待执行完毕' Bool BGNL? StepString Newline
|
||||
setViewport_1_s
|
||||
: '设置视角' '增量坐标' 'dx' PosString? ',' 'dy' PosString? '动画时间' Int '不等待执行完毕' Bool Newline
|
||||
|
||||
|
||||
/* moveViewport_s
|
||||
tooltip : moveViewport:移动视角
|
||||
/* setViewport_1_s
|
||||
tooltip : setViewport: 设置视角
|
||||
helpUrl : /_docs/#/instruction
|
||||
default : [300,false,"上右3下2左"]
|
||||
default : ["0","0",0,false]
|
||||
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':'';
|
||||
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;
|
||||
*/;
|
||||
|
||||
|
||||
@ -461,13 +461,14 @@ ActionParser.prototype.parseAction = function() {
|
||||
data.name,animate_loc,data.alignWindow||false,data.async||false,this.next]);
|
||||
break;
|
||||
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||['',''];
|
||||
this.next = MotaActionBlocks['setViewport_s'].xmlText([
|
||||
data.loc[0],data.loc[1],this.next]);
|
||||
break;
|
||||
case "moveViewport": // 移动视角
|
||||
this.next = MotaActionBlocks['moveViewport_s'].xmlText([
|
||||
data.time,data.async||false,this.StepString(data.steps),this.next]);
|
||||
data.loc[0],data.loc[1],data.time||0,data.async||false,this.next]);
|
||||
}
|
||||
break;
|
||||
case "vibrate": // 画面震动
|
||||
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['animate_s'].xmlText(),
|
||||
MotaActionBlocks['setViewport_s'].xmlText(),
|
||||
MotaActionBlocks['moveViewport_s'].xmlText(),
|
||||
MotaActionBlocks['setViewport_1_s'].xmlText(),
|
||||
MotaActionBlocks['showStatusBar_s'].xmlText(),
|
||||
MotaActionBlocks['hideStatusBar_s'].xmlText(),
|
||||
MotaActionBlocks['showHero_s'].xmlText(),
|
||||
|
||||
@ -953,9 +953,9 @@ control.prototype.updateViewport = function() {
|
||||
}
|
||||
|
||||
////// 设置视野范围 //////
|
||||
control.prototype.setViewport = function (x, y) {
|
||||
core.bigmap.offsetX = core.clamp(x, 0, 32 * core.bigmap.width - core.__PIXELS__);
|
||||
core.bigmap.offsetY = core.clamp(y, 0, 32 * core.bigmap.height - core.__PIXELS__);
|
||||
control.prototype.setViewport = function (px, py) {
|
||||
core.bigmap.offsetX = core.clamp(px, 0, 32 * core.bigmap.width - core.__PIXELS__);
|
||||
core.bigmap.offsetY = core.clamp(py, 0, 32 * core.bigmap.height - core.__PIXELS__);
|
||||
this.updateViewport();
|
||||
// ------ hero层也需要!
|
||||
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) {
|
||||
time = time || core.values.moveSpeed;
|
||||
var step = 0, moveSteps = (steps||[]).filter(function (t) {
|
||||
return ['up','down','left','right'].indexOf(t)>=0;
|
||||
});
|
||||
control.prototype.moveViewport = function (x, y, time, callback) {
|
||||
time = time || 0;
|
||||
time /= Math.max(core.status.replay.speed, 1)
|
||||
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() {
|
||||
if (moveSteps.length==0) {
|
||||
core.setViewport(core.bigmap.offsetX + dx, core.bigmap.offsetY + dy);
|
||||
step--;
|
||||
if (step <= 0) {
|
||||
delete core.animateFrame.asyncId[animate];
|
||||
clearInterval(animate);
|
||||
core.setViewport(px, py);
|
||||
if (callback) callback();
|
||||
}
|
||||
else {
|
||||
if (core.control._moveViewport_moving(++step, moveSteps))
|
||||
step = 0;
|
||||
}
|
||||
}, time / 16 / core.status.replay.speed);
|
||||
}, per_time);
|
||||
|
||||
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坐标 //////
|
||||
control.prototype.nextX = function(n) {
|
||||
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) {
|
||||
if (data.loc == null) {
|
||||
core.drawHero();
|
||||
if (data.dxy != null) {
|
||||
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 {
|
||||
var loc = this.__action_getLoc(data.loc, x, y, prefix);
|
||||
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);
|
||||
console.log(data.loc);
|
||||
this.__action_doAsyncFunc(data.async, core.moveViewport, data.loc[0], data.loc[1], data.time);
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user