commit
87f2d7e886
@ -860,6 +860,7 @@ action
|
|||||||
| changePos_s
|
| changePos_s
|
||||||
| setViewport_s
|
| setViewport_s
|
||||||
| setViewport_1_s
|
| setViewport_1_s
|
||||||
|
| lockViewport_s
|
||||||
| useItem_s
|
| useItem_s
|
||||||
| loadEquip_s
|
| loadEquip_s
|
||||||
| unloadEquip_s
|
| unloadEquip_s
|
||||||
@ -2129,6 +2130,19 @@ var code = '{"type": "setViewport"'+loc+MoveMode_List_0+Int_0+Bool_0+'},\n';
|
|||||||
return code;
|
return code;
|
||||||
*/;
|
*/;
|
||||||
|
|
||||||
|
lockViewport_s
|
||||||
|
: '是否锁定视角' Bool Newline
|
||||||
|
|
||||||
|
/* lockViewport_s
|
||||||
|
tooltip : lockViewport: 是否锁定视角
|
||||||
|
helpUrl : /_docs/#/instruction
|
||||||
|
default : [false]
|
||||||
|
colour : this.soundColor
|
||||||
|
Bool_0 = Bool_0 ? (', "lock": true') : '';
|
||||||
|
var code = '{"type": "lockViewport"'+Bool_0+'},\n';
|
||||||
|
return code;
|
||||||
|
*/;
|
||||||
|
|
||||||
showImage_s
|
showImage_s
|
||||||
: '显示图片' '图片编号' NInt '图片' EvalString '翻转' Reverse_List BGNL?
|
: '显示图片' '图片编号' NInt '图片' EvalString '翻转' Reverse_List BGNL?
|
||||||
'绘制的起点像素' 'x' PosString 'y' PosString '不透明度' Number '时间' Int '不等待执行完毕' Bool Newline
|
'绘制的起点像素' 'x' PosString 'y' PosString '不透明度' Number '时间' Int '不等待执行完毕' Bool Newline
|
||||||
|
|||||||
@ -569,6 +569,10 @@ ActionParser.prototype.parseAction = function() {
|
|||||||
data.loc[0],data.loc[1],data.moveMode||'', data.time||0,data.async||false,this.next]);
|
data.loc[0],data.loc[1],data.moveMode||'', data.time||0,data.async||false,this.next]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case "lockViewport":
|
||||||
|
this.next = MotaActionBlocks['lockViewport_s'].xmlText([data.lock,
|
||||||
|
this.next]);
|
||||||
|
break;
|
||||||
case "vibrate": // 画面震动
|
case "vibrate": // 画面震动
|
||||||
this.next = MotaActionBlocks['vibrate_s'].xmlText([data.direction||'horizontal',
|
this.next = MotaActionBlocks['vibrate_s'].xmlText([data.direction||'horizontal',
|
||||||
data.time||0, data.speed, data.power, data.async||false, this.next]);
|
data.time||0, data.speed, data.power, data.async||false, this.next]);
|
||||||
|
|||||||
@ -209,6 +209,7 @@ editor_blocklyconfig=(function(){
|
|||||||
MotaActionBlocks['animate_1_s'].xmlText(),
|
MotaActionBlocks['animate_1_s'].xmlText(),
|
||||||
MotaActionBlocks['setViewport_s'].xmlText(),
|
MotaActionBlocks['setViewport_s'].xmlText(),
|
||||||
MotaActionBlocks['setViewport_1_s'].xmlText(),
|
MotaActionBlocks['setViewport_1_s'].xmlText(),
|
||||||
|
MotaActionBlocks['lockViewport_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(),
|
||||||
|
|||||||
103
libs/control.js
103
libs/control.js
@ -202,7 +202,12 @@ control.prototype._animationFrame_heroMoving = function (timestamp) {
|
|||||||
core.animateFrame.leftLeg = !core.animateFrame.leftLeg;
|
core.animateFrame.leftLeg = !core.animateFrame.leftLeg;
|
||||||
core.animateFrame.moveTime = timestamp;
|
core.animateFrame.moveTime = timestamp;
|
||||||
}
|
}
|
||||||
core.drawHero(core.animateFrame.leftLeg?'leftFoot':'rightFoot', 4*core.status.heroMoving);
|
var way = core.utils.scan2[core.getHeroLoc('direction')],
|
||||||
|
heroMoving = core.status.heroMoving;
|
||||||
|
core.drawHero(core.animateFrame.leftLeg ? 'leftFoot' : 'rightFoot', {
|
||||||
|
x: way.x * 4 * heroMoving,
|
||||||
|
y: way.y * 4 * heroMoving
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
control.prototype._animationFrame_weather = function (timestamp) {
|
control.prototype._animationFrame_weather = function (timestamp) {
|
||||||
@ -813,40 +818,81 @@ 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';
|
||||||
offset = offset || 0;
|
offset = offset || {};
|
||||||
|
offset.x = offset.x || 0;
|
||||||
|
offset.y = offset.y || 0;
|
||||||
|
|
||||||
var way = core.utils.scan2[direction];
|
var way = core.utils.scan2[direction];
|
||||||
var dx = way.x, dy = way.y, offsetX = dx * offset, offsetY = dy * offset;
|
var dx = way.x, dy = way.y;
|
||||||
core.bigmap.offsetX = core.clamp((x - core.__HALF_SIZE__) * 32 + offsetX, 0, 32*core.bigmap.width-core.__PIXELS__);
|
var offsetX = offset.x, offsetY = offset.y;
|
||||||
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.clearAutomaticRouteNode(x + dx, y + dy);
|
||||||
core.clearMap('hero');
|
core.clearMap('hero');
|
||||||
core.status.heroCenter.px = 32 * x + offsetX + 16;
|
core.status.heroCenter.px = 32 * x + offsetX + 16;
|
||||||
core.status.heroCenter.py = 32 * y + offsetY + 32 - core.material.icons.hero.height / 2;
|
core.status.heroCenter.py = 32 * y + offsetY + 32 - core.material.icons.hero.height / 2;
|
||||||
|
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
this._drawHero_updateViewport();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
control.prototype._drawHero_updateViewport = function () {
|
control.prototype._drawHero_updateViewport = function (x, y, offset) {
|
||||||
core.control.updateViewport();
|
|
||||||
core.setGameCanvasTranslate('hero', 0, 0);
|
core.setGameCanvasTranslate('hero', 0, 0);
|
||||||
|
if (flags.__lockViewport__) return;
|
||||||
|
var offsetX = offset.x, offsetY = offset.y;
|
||||||
|
var ox = (x - core.__HALF_SIZE__) * 32 + offsetX,
|
||||||
|
oy = (y - core.__HALF_SIZE__) * 32 + offsetY;
|
||||||
|
|
||||||
|
core.bigmap.offsetX = core.clamp(ox, 0, 32 * core.bigmap.width - core.__PIXELS__);
|
||||||
|
core.bigmap.offsetY = core.clamp(oy, 0, 32 * core.bigmap.height - core.__PIXELS__);
|
||||||
|
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, noGather) {
|
||||||
|
var heroIconArr = core.material.icons.hero, drawObjs = [], index = 0;
|
||||||
|
drawObjs.push({
|
||||||
|
"img": core.material.images.hero,
|
||||||
|
"width": core.material.icons.hero.width || 32,
|
||||||
|
"height": core.material.icons.hero.height,
|
||||||
|
"heroIcon": heroIconArr[direction],
|
||||||
|
"posx": x * 32 - core.bigmap.offsetX + offset.x,
|
||||||
|
"posy": y * 32 - core.bigmap.offsetY + offset.y,
|
||||||
|
"status": status,
|
||||||
|
"index": index++,
|
||||||
|
});
|
||||||
|
// 不重绘跟随者 比如说跳跃时……
|
||||||
|
if (!noGather) {
|
||||||
|
core.status.hero.followers.forEach(function(t) {
|
||||||
|
drawObjs.push({
|
||||||
|
"img": core.material.images.images[t.name],
|
||||||
|
"width": core.material.images.images[t.name].width / 4,
|
||||||
|
"height": core.material.images.images[t.name].height / 4,
|
||||||
|
"heroIcon": heroIconArr[t.direction],
|
||||||
|
"posx": 32 * t.x - core.bigmap.offsetX + (t.stop ? 0 : core.utils.scan2[t.direction].x * Math.abs(offset.x)),
|
||||||
|
"posy": 32 * t.y - core.bigmap.offsetY + (t.stop ? 0 : core.utils.scan2[t.direction].y * Math.abs(offset.y)),
|
||||||
|
"status": t.stop ? "stop" : status,
|
||||||
|
"index": index++
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return drawObjs.sort(function(a, b) {
|
||||||
|
return a.posy==b.posy?b.index-a.index:a.posy-b.posy;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
control.prototype.triggerHero = function (type, time, callback) {
|
control.prototype.triggerHero = function (type, time, callback) {
|
||||||
if (type == null) {
|
if (type == null) {
|
||||||
type = core.hasFlag('hideHero') ? 'show' : 'hide';
|
type = core.hasFlag('hideHero') ? 'show' : 'hide';
|
||||||
@ -887,35 +933,6 @@ control.prototype._triggerHero_animate = function (type, delta, callback) {
|
|||||||
core.animateFrame.asyncId[animate] = true;
|
core.animateFrame.asyncId[animate] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
control.prototype._drawHero_getDrawObjs = function (direction, x, y, status, offset) {
|
|
||||||
var heroIconArr = core.material.icons.hero, drawObjs = [], index = 0;
|
|
||||||
drawObjs.push({
|
|
||||||
"img": core.material.images.hero,
|
|
||||||
"width": core.material.icons.hero.width || 32,
|
|
||||||
"height": core.material.icons.hero.height,
|
|
||||||
"heroIcon": heroIconArr[direction],
|
|
||||||
"posx": x * 32 - core.bigmap.offsetX + core.utils.scan2[direction].x * offset,
|
|
||||||
"posy": y * 32 - core.bigmap.offsetY + core.utils.scan2[direction].y * offset,
|
|
||||||
"status": status,
|
|
||||||
"index": index++,
|
|
||||||
});
|
|
||||||
core.status.hero.followers.forEach(function (t) {
|
|
||||||
drawObjs.push({
|
|
||||||
"img": core.material.images.images[t.name],
|
|
||||||
"width": core.material.images.images[t.name].width/4,
|
|
||||||
"height": core.material.images.images[t.name].height/4,
|
|
||||||
"heroIcon": heroIconArr[t.direction],
|
|
||||||
"posx": 32*t.x - core.bigmap.offsetX + (t.stop?0:core.utils.scan2[t.direction].x*Math.abs(offset)),
|
|
||||||
"posy": 32*t.y - core.bigmap.offsetY + (t.stop?0:core.utils.scan2[t.direction].y*Math.abs(offset)),
|
|
||||||
"status": t.stop?"stop":status,
|
|
||||||
"index": index++
|
|
||||||
});
|
|
||||||
});
|
|
||||||
return drawObjs.sort(function(a, b) {
|
|
||||||
return a.posy==b.posy?b.index-a.index:a.posy-b.posy;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------ 画布、位置、阻激夹域,显伤 ------ //
|
// ------ 画布、位置、阻激夹域,显伤 ------ //
|
||||||
|
|
||||||
////// 设置画布偏移
|
////// 设置画布偏移
|
||||||
|
|||||||
@ -1527,6 +1527,11 @@ events.prototype._action_setViewport = function (data, x, y, prefix) {
|
|||||||
this.__action_doAsyncFunc(data.async, core.moveViewport, data.loc[0], data.loc[1], data.moveMode, data.time);
|
this.__action_doAsyncFunc(data.async, core.moveViewport, data.loc[0], data.loc[1], data.moveMode, data.time);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
events.prototype._action_lockViewport = function (data, x, y, prefix) {
|
||||||
|
flags.__lockViewport__ = data.lock;
|
||||||
|
core.doAction();
|
||||||
|
}
|
||||||
|
|
||||||
events.prototype._action_move = function (data, x, y, prefix) {
|
events.prototype._action_move = function (data, x, y, prefix) {
|
||||||
var loc = this.__action_getLoc(data.loc, x, y, prefix);
|
var loc = this.__action_getLoc(data.loc, x, y, prefix);
|
||||||
this.__action_doAsyncFunc(data.async, core.moveBlock, loc[0], loc[1], data.steps, data.time, data.keep);
|
this.__action_doAsyncFunc(data.async, core.moveBlock, loc[0], loc[1], data.steps, data.time, data.keep);
|
||||||
@ -3547,10 +3552,16 @@ events.prototype._eventMoveHero_moving = function (step, moveSteps) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (step <= 4) {
|
if (step <= 4) {
|
||||||
core.drawHero('leftFoot', 4 * o * step);
|
core.drawHero('leftFoot', {
|
||||||
|
x: 4 * o * step,
|
||||||
|
y: 4 * o * step
|
||||||
|
});
|
||||||
}
|
}
|
||||||
else if (step <= 8) {
|
else if (step <= 8) {
|
||||||
core.drawHero('rightFoot', 4 * o * step);
|
core.drawHero('rightFoot', {
|
||||||
|
x: 4 * o * step,
|
||||||
|
y: 4 * o * step
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if (step == 8) {
|
if (step == 8) {
|
||||||
core.setHeroLoc('x', x + o * core.utils.scan2[direction].x, true);
|
core.setHeroLoc('x', x + o * core.utils.scan2[direction].x, true);
|
||||||
@ -3595,14 +3606,13 @@ events.prototype._jumpHero_doJump = function (jumpInfo, callback) {
|
|||||||
events.prototype._jumpHero_jumping = function (jumpInfo) {
|
events.prototype._jumpHero_jumping = function (jumpInfo) {
|
||||||
core.clearMap('hero');
|
core.clearMap('hero');
|
||||||
core.maps.__updateJumpInfo(jumpInfo);
|
core.maps.__updateJumpInfo(jumpInfo);
|
||||||
|
var x = core.getHeroLoc('x'),
|
||||||
|
y = core.getHeroLoc('y');
|
||||||
var nowx = jumpInfo.px, nowy = jumpInfo.py, width = jumpInfo.width || 32, height = jumpInfo.height;
|
var nowx = jumpInfo.px, nowy = jumpInfo.py, width = jumpInfo.width || 32, height = jumpInfo.height;
|
||||||
core.bigmap.offsetX = core.clamp(nowx - 32*core.__HALF_SIZE__, 0, 32*core.bigmap.width-core.__PIXELS__);
|
core.drawHero(null, {
|
||||||
core.bigmap.offsetY = core.clamp(nowy - 32*core.__HALF_SIZE__, 0, 32*core.bigmap.height-core.__PIXELS__);
|
x: nowx - 32 * x,
|
||||||
core.control.updateViewport();
|
y: nowy - 32 * y
|
||||||
core.drawImage('hero', core.material.images.hero, jumpInfo.icon.stop, jumpInfo.icon.loc * height, width, height,
|
}, 0, true);
|
||||||
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) {
|
events.prototype._jumpHero_finished = function (animate, ex, ey, callback) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user