V1.4.1
This commit is contained in:
parent
fa5aece101
commit
c0fcbea201
1
animates/jianji.animate
Normal file
1
animates/jianji.animate
Normal file
File diff suppressed because one or more lines are too long
@ -419,13 +419,38 @@ revisit常常使用在一些商人之类的地方,当用户购买物品后不
|
||||
]
|
||||
```
|
||||
|
||||
### setBlock:设置某个图块
|
||||
|
||||
我们可以采用 `{"type": "setBlock"}` 来改变某个地图块。
|
||||
|
||||
``` js
|
||||
"x,y": [ // 实际执行的事件列表
|
||||
{"type": "setBlock", "floorId": "MT1", "loc": [3,3], "number": 233}, // 将MT1层的(3,3)点变成数字233
|
||||
{"type": "setBlock", "loc": [2,1], "number": 121}, // 省略floorId则默认为本层
|
||||
{"type": "setBlock", "number": 57}, // loc也可省略,默认为当前点
|
||||
]
|
||||
```
|
||||
|
||||
floorId为可选的,表示要更改的目标楼层。如果忽略此项,则默认为当前楼层。
|
||||
|
||||
loc为可选的,表示要更改地图块的坐标。如果忽略此项,则默认为当前事件点。
|
||||
|
||||
number为**要更改到的数字**,有关“数字”的定义详见参见[素材的机制](personalization#素材的机制)。
|
||||
|
||||
图块更改后:
|
||||
|
||||
- 其启用/禁用状态不会发生任何改变。原来是启用还是启用,原来是禁用还是禁用。
|
||||
- 可通行状态遵循覆盖原则,即**取该图块的默认noPass属性,如果剧本的events中定义该点的noPass则覆盖**。
|
||||
- 其触发器(trigger)亦采用覆盖原则,即**取该图块的默认触发器(例如怪物是battle,道具是getItem,门是openDoor),如果剧本的events中定义了该点的trigger则覆盖**。
|
||||
|
||||
### update: 立刻更新状态栏和地图显伤
|
||||
|
||||
当我们在上面调用show事件,显示一个怪物后,该怪物将不会有显伤显示。如果你需要刷新状态栏和地图显伤,只需要简单地调用 `{"type": "update"}` 即可。
|
||||
如果你需要刷新状态栏和地图显伤,只需要简单地调用 `{"type": "update"}` 即可。
|
||||
|
||||
### sleep: 等待多少毫秒
|
||||
|
||||
等价于RMXP中的"等待x帧",不过是以毫秒来计算。
|
||||
|
||||
基本写法:`{"type": "sleep", "time": xxx}` ,其中xxx为指定的毫秒数。
|
||||
|
||||
``` js
|
||||
|
||||
58
libs/core.js
58
libs/core.js
@ -591,6 +591,7 @@ core.prototype.loadAnimates = function (callback) {
|
||||
|
||||
data.ratio = content.ratio;
|
||||
data.images = [];
|
||||
data.images_rev = [];
|
||||
content.bitmaps.forEach(function (t2) {
|
||||
if (!core.isset(t2) || t2=="") {
|
||||
data.images.push(null);
|
||||
@ -615,7 +616,9 @@ core.prototype.loadAnimates = function (callback) {
|
||||
'x': t3[1],
|
||||
'y': t3[2],
|
||||
'zoom': t3[3],
|
||||
'opacity': t3[4]
|
||||
'opacity': t3[4],
|
||||
'mirror': t3[5]||0,
|
||||
'angle': t3[6]||0,
|
||||
})
|
||||
})
|
||||
data.frames.push(info);
|
||||
@ -1687,15 +1690,21 @@ core.prototype.automaticRoute = function (destX, destY) {
|
||||
f=f%169;
|
||||
var nowX = parseInt(f / 13), nowY = f % 13;
|
||||
var nowIsArrow = false, nowId, nowBlock = core.getBlock(nowX,nowY);
|
||||
/*
|
||||
if (nowBlock!=null){
|
||||
nowId = nowBlock.block.event.id;
|
||||
nowIsArrow = nowId.slice(0, 5).toLowerCase() == 'arrow';
|
||||
}
|
||||
*/
|
||||
for (var direction in scan) {
|
||||
/*
|
||||
if(nowIsArrow){
|
||||
var nowArrow = nowId.slice(5).toLowerCase();
|
||||
if (direction != nowArrow) continue;
|
||||
}
|
||||
*/
|
||||
if (!core.canMoveHero(nowX, nowY, direction))
|
||||
continue;
|
||||
|
||||
var nx = nowX + scan[direction].x;
|
||||
var ny = nowY + scan[direction].y;
|
||||
@ -1711,12 +1720,14 @@ core.prototype.automaticRoute = function (destX, destY) {
|
||||
var nextId, nextBlock = core.getBlock(nx,ny);
|
||||
if (nextBlock!=null){
|
||||
nextId = nextBlock.block.event.id;
|
||||
/*
|
||||
// 遇到单向箭头处理
|
||||
var isArrow = nextId.slice(0, 5).toLowerCase() == 'arrow';
|
||||
if(isArrow){
|
||||
var nextArrow = nextId.slice(5).toLowerCase();
|
||||
if ( (scan[direction].x + scan[nextArrow].x) == 0 && (scan[direction].y + scan[nextArrow].y) == 0 ) continue;
|
||||
}
|
||||
*/
|
||||
// 绕过亮灯(因为只有一次通行机会很宝贵)
|
||||
if(nextId == "light") deepAdd=100;
|
||||
// 绕过路障
|
||||
@ -1925,9 +1936,18 @@ core.prototype.turnHero = function() {
|
||||
}
|
||||
|
||||
////// 勇士能否前往某方向 //////
|
||||
core.prototype.canMoveHero = function() {
|
||||
var direction = core.getHeroLoc('direction');
|
||||
var nowBlock = core.getBlock(core.getHeroLoc('x'),core.getHeroLoc('y'));
|
||||
core.prototype.canMoveHero = function(x,y,direction,floorId) {
|
||||
if (!core.isset(x)) x=core.getHeroLoc('x');
|
||||
if (!core.isset(y)) y=core.getHeroLoc('y');
|
||||
if (!core.isset(direction)) direction=core.getHeroLoc('direction');
|
||||
if (!core.isset(floorId)) floorId=core.status.floorId;
|
||||
|
||||
// 检查当前块的cannotMove
|
||||
var cannotMove = core.floors[floorId].cannotMove[x+","+y];
|
||||
if (core.isset(cannotMove) && cannotMove instanceof Array && cannotMove.indexOf(direction)>=0)
|
||||
return false;
|
||||
|
||||
var nowBlock = core.getBlock(x,y,floorId);
|
||||
if (nowBlock!=null){
|
||||
nowId = nowBlock.block.event.id;
|
||||
var nowIsArrow = nowId.slice(0, 5).toLowerCase() == 'arrow';
|
||||
@ -1944,7 +1964,7 @@ core.prototype.canMoveHero = function() {
|
||||
'down': {'x': 0, 'y': 1},
|
||||
'right': {'x': 1, 'y': 0}
|
||||
};
|
||||
var nextBlock = core.getBlock(core.nextX(),core.nextY());
|
||||
var nextBlock = core.getBlock(x+scan[direction].x,y+scan[direction].y);
|
||||
if (nextBlock!=null){
|
||||
nextId = nextBlock.block.event.id;
|
||||
// 遇到单向箭头处理
|
||||
@ -1991,6 +2011,8 @@ core.prototype.canMoveDirectly = function (destX,destY) {
|
||||
|
||||
////// 让勇士开始移动 //////
|
||||
core.prototype.moveHero = function (direction, callback) {
|
||||
// 如果正在移动,直接return
|
||||
if (core.status.heroMoving>0) return;
|
||||
if (core.isset(direction))
|
||||
core.setHeroLoc('direction', direction);
|
||||
if (!core.isset(callback)) { // 如果不存在回调函数,则使用heroMoveTrigger
|
||||
@ -2978,6 +3000,7 @@ core.prototype.showBlock = function(x, y, floodId) {
|
||||
// core.setGlobalAnimate(core.values.animateSpeed);
|
||||
core.syncGlobalAnimate();
|
||||
}
|
||||
core.updateStatusBar();
|
||||
}
|
||||
}
|
||||
|
||||
@ -3160,7 +3183,22 @@ core.prototype.drawAnimate = function (name, x, y, callback) {
|
||||
var realWidth = image.width * ratio * t.zoom / 100;
|
||||
var realHeight = image.height * ratio * t.zoom / 100;
|
||||
core.setAlpha('animate', t.opacity / 255);
|
||||
core.canvas.animate.drawImage(image, centerX+t.x-realWidth/2, centerY+t.y-realHeight/2, realWidth, realHeight);
|
||||
|
||||
var cx = centerX+t.x, cy=centerY+t.y;
|
||||
|
||||
if (!t.mirror && !t.angle) {
|
||||
core.canvas.animate.drawImage(image, cx-realWidth/2, cy-realHeight/2, realWidth, realHeight);
|
||||
}
|
||||
else {
|
||||
core.saveCanvas('animate');
|
||||
core.canvas.animate.translate(cx,cy);
|
||||
if (t.angle)
|
||||
core.canvas.animate.rotate(-t.angle*Math.PI/180);
|
||||
if (t.mirror)
|
||||
core.canvas.animate.scale(-1,1);
|
||||
core.canvas.animate.drawImage(image, -realWidth/2, -realHeight/2, realWidth, realHeight);
|
||||
core.loadCanvas('animate');
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@ -3464,13 +3502,13 @@ core.prototype.setWeather = function (type, level) {
|
||||
|
||||
// 当前天气:则忽略
|
||||
if (type==core.animateFrame.weather.type &&
|
||||
(!core.isset(level) || 16*level==core.animateFrame.weather.level)) {
|
||||
(!core.isset(level) || 20*level==core.animateFrame.weather.level)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!core.isset(level)) level=5;
|
||||
if (level<1) level=1; if (level>10) level=10;
|
||||
level *= 16;
|
||||
level *= 20;
|
||||
|
||||
core.clearMap('weather', 0, 0, 416, 416)
|
||||
core.animateFrame.weather.type = type;
|
||||
@ -3483,7 +3521,7 @@ core.prototype.setWeather = function (type, level) {
|
||||
core.animateFrame.weather.nodes.push({
|
||||
'x': Math.random()*416,
|
||||
'y': Math.random()*416,
|
||||
'l': Math.random() * 1.2,
|
||||
'l': Math.random() * 2.5,
|
||||
'xs': -4 + Math.random() * 4 + 2,
|
||||
'ys': Math.random() * 10 + 10
|
||||
})
|
||||
@ -3494,7 +3532,7 @@ core.prototype.setWeather = function (type, level) {
|
||||
core.animateFrame.weather.nodes.push({
|
||||
'x': Math.random()*416,
|
||||
'y': Math.random()*416,
|
||||
'r': Math.random() * 4 + 1,
|
||||
'r': Math.random() * 5 + 1,
|
||||
'd': Math.random() * level,
|
||||
})
|
||||
}
|
||||
|
||||
@ -159,6 +159,7 @@ data.prototype.init = function() {
|
||||
"bombFourDirections": true, // 使用炸弹是否四个方向都会炸;如果false则只炸面前的怪物(即和圣锤等价)
|
||||
"bigKeyIsBox": false, // 如果此项为true,则视为钥匙盒,红黄蓝钥匙+1;若为false,则视为大黄门钥匙
|
||||
"equipment": false, // 剑和盾是否直接作为装备。如果此项为true,则作为装备,需要在道具栏使用,否则将直接加属性。
|
||||
"enableDeleteItem": true, // 是否允许删除(丢弃)道具
|
||||
/****** 怪物相关 ******/
|
||||
"enableNegativeDamage": true, // 是否支持负伤害(回血)
|
||||
"hatredDecrease": true, // 是否在和仇恨怪战斗后减一半的仇恨值,此项为false则和仇恨怪不会扣减仇恨值。
|
||||
|
||||
@ -334,6 +334,33 @@ events.prototype.doAction = function() {
|
||||
}
|
||||
else this.doAction();
|
||||
break;
|
||||
case "setBlock": // 设置某图块
|
||||
{
|
||||
if (core.isset(data.loc)) {
|
||||
x=data.loc[0];
|
||||
y=data.loc[1];
|
||||
}
|
||||
var floorId = data.floorId||core.status.floorId;
|
||||
var originBlock=core.getBlock(x,y,toId,false);
|
||||
var block = core.maps.getBlock(x,y,data.number);
|
||||
core.maps.addInfo(block);
|
||||
core.maps.addEvent(block,x,y,core.floors[floorId].events[x+","+y]);
|
||||
core.maps.addChangeFloor(block,x,y,core.floors[floorId].changeFloor[x+","+y]);
|
||||
if (core.isset(block.event)) {
|
||||
if (originBlock==null) {
|
||||
core.status.maps[floorId].blocks.push(block);
|
||||
}
|
||||
else {
|
||||
originBlock.block.id = data.number;
|
||||
originBlock.block.event = block.event;
|
||||
}
|
||||
core.drawMap(floorId);
|
||||
core.drawHero(core.getHeroLoc('direction'), core.getHeroLoc('x'), core.getHeroLoc('y'), 'stop');
|
||||
core.updateStatusBar();
|
||||
}
|
||||
this.doAction();
|
||||
break;
|
||||
}
|
||||
case "animate": // 显示动画
|
||||
if (core.isset(data.loc)) {
|
||||
if (data.loc == 'hero') {
|
||||
@ -1302,6 +1329,18 @@ events.prototype.clickToolbox = function(x,y) {
|
||||
core.ui.closePanel();
|
||||
return;
|
||||
}
|
||||
if (x>=10 && x<=12 && y<=1) {
|
||||
if (!core.isset(core.status.event.data)) return;
|
||||
if (!core.flags.enableDeleteItem) {
|
||||
core.drawTip("不支持删除道具!");
|
||||
return;
|
||||
}
|
||||
core.removeItem(core.status.event.data);
|
||||
core.status.event.data = null;
|
||||
core.ui.drawToolbox();
|
||||
return;
|
||||
}
|
||||
|
||||
var index=0;
|
||||
if (y==4||y==5||y==9||y==10) index=parseInt(x/2);
|
||||
else index=6+parseInt(x/2);
|
||||
@ -1406,6 +1445,19 @@ events.prototype.keyUpToolbox = function (keycode) {
|
||||
this.clickToolboxIndex(core.status.event.selection);
|
||||
return;
|
||||
}
|
||||
|
||||
if (keycode==46) { // delete
|
||||
if (!core.isset(core.status.event.data)) return;
|
||||
if (!core.flags.enableDeleteItem) {
|
||||
core.drawTip("不支持删除道具!");
|
||||
return;
|
||||
}
|
||||
core.removeItem(core.status.event.data);
|
||||
core.status.event.data = null;
|
||||
core.ui.drawToolbox();
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
////// 存读档界面时的点击操作 //////
|
||||
|
||||
@ -32,6 +32,11 @@ main.floors.MT0 = {
|
||||
},
|
||||
"afterOpenDoor": { // 开完门后可能触发的事件列表
|
||||
|
||||
}
|
||||
},
|
||||
"cannotMove": { // 每个图块不可通行的方向
|
||||
// 可以在这里定义每个点不能前往哪个方向,例如悬崖边不能跳下去
|
||||
// "x,y": ["up", "left"], // (x,y)点不能往上和左走
|
||||
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@ -109,7 +109,12 @@ main.floors.sample0 = {
|
||||
},
|
||||
"afterOpenDoor": { // 开完门后可能触发的事件列表
|
||||
"11,12": ["你开了一个绿门,触发了一个afterOpenDoor事件"]
|
||||
}
|
||||
},
|
||||
"cannotMove": { // 每个图块不可通行的方向
|
||||
// 可以在这里定义每个点不能前往哪个方向,例如悬崖边不能跳下去
|
||||
// "x,y": ["up", "left"], // (x,y)点不能往上和左走
|
||||
|
||||
},
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -321,6 +321,11 @@ main.floors.sample1 = {
|
||||
},
|
||||
"afterOpenDoor": { // 开完门后可能触发的事件列表
|
||||
|
||||
}
|
||||
},
|
||||
"cannotMove": { // 每个图块不可通行的方向
|
||||
// 可以在这里定义每个点不能前往哪个方向,例如悬崖边不能跳下去
|
||||
// "x,y": ["up", "left"], // (x,y)点不能往上和左走
|
||||
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@ -401,6 +401,11 @@ main.floors.sample2 = {
|
||||
},
|
||||
"afterOpenDoor": { // 开完门后可能触发的事件列表
|
||||
|
||||
}
|
||||
},
|
||||
"cannotMove": { // 每个图块不可通行的方向
|
||||
// 可以在这里定义每个点不能前往哪个方向,例如悬崖边不能跳下去
|
||||
// "x,y": ["up", "left"], // (x,y)点不能往上和左走
|
||||
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
47
libs/maps.js
47
libs/maps.js
@ -14,27 +14,7 @@ maps.prototype.loadFloor = function (floorId, map) {
|
||||
for (var i = 0; i < 13; i++) {
|
||||
for (var j = 0; j < 13; j++) {
|
||||
var block = this.getBlock(j, i, map[i][j]);
|
||||
if (core.isset(block.event)) {
|
||||
if (block.event.cls == 'enemys' && block.event.trigger==undefined) {
|
||||
block.event.trigger = 'battle';
|
||||
}
|
||||
if (block.event.cls == 'items' && block.event.trigger==undefined) {
|
||||
block.event.trigger = 'getItem';
|
||||
}
|
||||
if (block.event.noPass == undefined) {
|
||||
if (block.event.cls=='enemys' || block.event.cls=='terrains' || block.event.cls=='npcs') {
|
||||
block.event.noPass = true;
|
||||
}
|
||||
}
|
||||
if (block.event.animate == undefined) {
|
||||
if (block.event.cls=='enemys' || block.event.cls=='npcs') {
|
||||
block.event.animate = 2;
|
||||
}
|
||||
if (block.event.cls == 'animates') {
|
||||
block.event.animate = 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.addInfo(block);
|
||||
this.addEvent(block,j,i,floor.events[j+","+i])
|
||||
this.addChangeFloor(block,j,i,floor.changeFloor[j+","+i]);
|
||||
if (core.isset(block.event)) blocks.push(block);
|
||||
@ -257,6 +237,31 @@ maps.prototype.getBlock = function (x, y, id) {
|
||||
return tmp;
|
||||
}
|
||||
|
||||
////// 添加一些信息到block上 //////
|
||||
maps.prototype.addInfo = function (block) {
|
||||
if (core.isset(block.event)) {
|
||||
if (block.event.cls == 'enemys' && block.event.trigger==undefined) {
|
||||
block.event.trigger = 'battle';
|
||||
}
|
||||
if (block.event.cls == 'items' && block.event.trigger==undefined) {
|
||||
block.event.trigger = 'getItem';
|
||||
}
|
||||
if (block.event.noPass == undefined) {
|
||||
if (block.event.cls=='enemys' || block.event.cls=='terrains' || block.event.cls=='npcs') {
|
||||
block.event.noPass = true;
|
||||
}
|
||||
}
|
||||
if (block.event.animate == undefined) {
|
||||
if (block.event.cls=='enemys' || block.event.cls=='npcs') {
|
||||
block.event.animate = 2;
|
||||
}
|
||||
if (block.event.cls == 'animates') {
|
||||
block.event.animate = 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////// 向该楼层添加剧本的自定义事件 //////
|
||||
maps.prototype.addEvent = function (block, x, y, event) {
|
||||
if (!core.isset(event)) return;
|
||||
|
||||
@ -481,7 +481,7 @@ ui.prototype.drawBattleAnimate = function(monsterId, callback) {
|
||||
var initDamage = 0; // 战前伤害
|
||||
|
||||
// 吸血
|
||||
if (this.hasSpecial(mon_special, 11)) {
|
||||
if (core.enemys.hasSpecial(mon_special, 11)) {
|
||||
var vampireDamage = hero_hp * monster.value;
|
||||
|
||||
// 如果有神圣盾免疫吸血等可以在这里写
|
||||
@ -1207,6 +1207,7 @@ ui.prototype.drawToolbox = function(index) {
|
||||
|
||||
// 退出
|
||||
core.canvas.ui.textAlign = 'center';
|
||||
core.fillText('ui', '删除道具', 370, 32,'#DDDDDD', 'bold 15px Verdana');
|
||||
core.fillText('ui', '返回游戏', 370, 403,'#DDDDDD', 'bold 15px Verdana');
|
||||
}
|
||||
|
||||
|
||||
2
main.js
2
main.js
@ -20,7 +20,7 @@ function main() {
|
||||
];
|
||||
this.animates = [ // 在此存放所有可能使用的动画,必须是animate格式,在这里不写后缀名
|
||||
// 动画必须放在animates目录下;文件名不能使用中文,不能带空格或特殊字符
|
||||
"hand", "sword", "zone", "yongchang", // "thunder" // 根据需求自行添加
|
||||
"hand", "sword", "zone", "yongchang", // "jianji", "thunder" // 根据需求自行添加
|
||||
];
|
||||
this.bgms = [ // 在此存放所有的bgm,和文件名一致。第一项为默认播放项
|
||||
// 音频名不能使用中文,不能带空格或特殊字符;可以直接改名拼音就好
|
||||
|
||||
BIN
常用工具/RM动画导出器.exe
BIN
常用工具/RM动画导出器.exe
Binary file not shown.
14
更新说明.txt
14
更新说明.txt
@ -1,4 +1,16 @@
|
||||
HTML5魔塔样板V1.3.3
|
||||
HTML5魔塔样板V1.4.1
|
||||
|
||||
改变图块(setBlock事件)。
|
||||
同一个点的多事件处理(做法详见文档)。
|
||||
地图中每个块的可通行方向控制(悬崖效果)。
|
||||
动画支持带旋转和翻转的帧。
|
||||
现在可以允许用户丢弃道具了(例如不会再使用的装备)。
|
||||
修复行走时按键会发生动画抖动问题。
|
||||
修复无法打开战斗动画的Bug。
|
||||
|
||||
-----------------------------------------------------------------------
|
||||
|
||||
HTML5魔塔样板V1.4
|
||||
|
||||
动画!动画!!动画!!!
|
||||
瞬间移动。
|
||||
|
||||
Loading…
Reference in New Issue
Block a user