show/hide status bar

This commit is contained in:
oc 2018-12-01 14:48:52 +08:00
parent d727a4d9d1
commit a6a8b91863
7 changed files with 114 additions and 4 deletions

View File

@ -63,6 +63,8 @@ HTML5 canvas制作的魔塔样板支持全平台游戏
* [x] 升级事件改用事件编辑器完成
* [x] 每层楼都增添该层的并行事件处理
* [x] 新增快捷键N返回标题P查看评论O打开工程
* [x] 新增事件:设置全局属性或全局数值
* [x] 新增事件:隐藏/显示状态栏
* [x] 道具可以设置是否在回放时绘制道具栏或直接使用
* [x] 可以同时异步移动/跳跃勇士和多个NPC
* [x] 可以同时异步移动两张或以上的图片了

View File

@ -230,6 +230,8 @@ action
| setBgFgBlock_s
| setHeroIcon_s
| update_s
| showStatusBar_s
| hideStatusBar_s
| updateEnemys_s
| sleep_s
| wait_s
@ -445,7 +447,7 @@ setGlobalAttribute_s
/* setGlobalAttribute_s
tooltip : setGlobalAttribute设置全局属性
helpUrl : https://h5mota.com/games/template/docs/#/event?id=setFloor%ef%bc%9a%e8%ae%be%e7%bd%ae%e6%a5%bc%e5%b1%82%e5%b1%9e%e6%80%a7
helpUrl : https://h5mota.com/games/template/docs/#/event?id=setGlobalAttribute%ef%bc%9a%e8%ae%be%e7%bd%ae%e4%b8%80%e4%b8%aa%e5%85%a8%e5%b1%80%e5%b1%9e%e6%80%a7
default : ["font","Verdana"]
colour : this.dataColor
var code = '{"type": "setGlobalAttribute", "name": "'+Global_Attribute_List_0+'", "value": "'+EvalString_0+'"},\n';
@ -459,7 +461,7 @@ setGlobalValue_s
/* setGlobalValue_s
tooltip : setGlobalValue设置全局属性
helpUrl : https://h5mota.com/games/template/docs/#/event?id=setFloor%ef%bc%9a%e8%ae%be%e7%bd%ae%e6%a5%bc%e5%b1%82%e5%b1%9e%e6%80%a7
helpUrl : https://h5mota.com/games/template/docs/#/event?id=setGlobalValue%ef%bc%9a%e8%ae%be%e7%bd%ae%e4%b8%80%e4%b8%aa%e5%85%a8%e5%b1%80%e6%95%b0%e5%80%bc
default : ["lavaDamage","100"]
colour : this.dataColor
var code = '{"type": "setGlobalValue", "name": "'+Global_Value_List_0+'", "value": '+EvalString_0+'},\n';
@ -768,6 +770,30 @@ var code = '{"type": "update"},\n';
return code;
*/;
showStatusBar_s
: '显示状态栏' Newline
/* showStatusBar_s
tooltip : showStatusBar: 显示状态栏
helpUrl : https://h5mota.com/games/template/docs/#/event?id=showStatusBar%ef%bc%9a%e6%98%be%e7%a4%ba%e7%8a%b6%e6%80%81%e6%a0%8f
colour : this.soundColor
var code = '{"type": "showStatusBar"},\n';
return code;
*/;
hideStatusBar_s
: '隐藏状态栏' Newline
/* hideStatusBar_s
tooltip : hideStatusBar: 隐藏状态栏
helpUrl : https://h5mota.com/games/template/docs/#/event?id=hideStatusBar%ef%bc%9a%e9%9a%90%e8%97%8f%e7%8a%b6%e6%80%81%e6%a0%8f
colour : this.soundColor
var code = '{"type": "hideStatusBar"},\n';
return code;
*/;
updateEnemys_s
: '更新怪物数据' Newline
@ -2175,6 +2201,14 @@ ActionParser.prototype.parseAction = function() {
this.next = MotaActionBlocks['update_s'].xmlText([
this.next]);
break;
case "showStatusBar":
this.next = MotaActionBlocks['showStatusBar_s'].xmlText([
this.next]);
break;
case "hideStatusBar":
this.next = MotaActionBlocks['hideStatusBar_s'].xmlText([
this.next]);
break;
case "updateEnemys":
this.next = MotaActionBlocks['updateEnemys_s'].xmlText([
this.next]);

View File

@ -133,6 +133,8 @@ editor_blockly = function () {
MotaActionBlocks['wait_s'].xmlText(),
MotaActionBlocks['viberate_s'].xmlText(),
MotaActionBlocks['animate_s'].xmlText(),
MotaActionBlocks['showStatusBar_s'].xmlText(),
MotaActionBlocks['hideStatusBar_s'].xmlText(),
MotaActionBlocks['setFg_0_s'].xmlText(),
MotaActionBlocks['setFg_1_s'].xmlText(),
MotaActionBlocks['setWeather_s'].xmlText(),

View File

@ -414,6 +414,37 @@ value为必填项代表要修改到的数值。其应该和楼层属性中的
!> 如果修改到的是字符串类型比如楼层中文名、状态栏名称、地面素材ID、背景音乐等必须加引号否则会报错。
### setGlobalAttribute设置一个全局属性
使用`{"type":"setGlobalAttribute"}`可以设置一个全局属性。
``` js
"x,y": [ // 实际执行的事件列表
{"type": "setGlobalAttribute", "name": "font", "value": "Verdana"}, // 设置字体为Verdana
]
```
name必填项代表要修改的全局属性。目前只能为`"font", "statusLeftBackground", "statusTopBackground", "toolsBackground",
"borderColor", "statusBarColor", "hardLabelColor", "floorChangingBackground", "floorChangingTextColor"`。
value为必填项代表要修改到的结果。此项无需再手动加单引号。
### setGlobalValue设置一个全局数值
使用`{"type":"setGlobalValue"}`可以设置一个全局数值。
``` js
"x,y": [ // 实际执行的事件列表
{"type": "setGlobalValue", "name": "lavaDamage", "value": 200}, // 设置血网伤害为200
]
```
name必填项代表要修改的全局数值其和全塔属性中的values一一对应。目前只能为`"lavaDamage", "poisonDamage", "weakValue", "redJewel",
"blueJewel", "greenJewel", "redPotion", "bluePotion", "yellowPotion", "greenPotion", "breakArmor", "counterAttack",
"purify", "hatred", "maxValidHp", "animateSpeed"`。
value为必填项代表要修改到的结果。该项必须是个数值。
### show将一个禁用事件启用
我们上面提到了所有事件都必须靠其他事件驱动来完成不存在当某个flag为true时自动执行的说法。那么我们自然要有启用事件的写法。
@ -676,6 +707,16 @@ name是可选的代表目标行走图的文件名。
如果你需要刷新状态栏和地图显伤,只需要简单地调用 `{"type": "update"}` 即可。
### hideStatusBar隐藏状态栏
使用`{"type": "hideStatusBar"}`可以隐藏状态栏。读档或重新开始游戏时,状态栏会重新显示。
隐藏状态栏的状态下,将无法点击工具栏里面的按钮(如存读档怪物手册等)。建议仅在事件中使用,事件结束前显示。
### showStatusBar显示状态栏
使用`{"type": "showStatusBar"}`会重新显示状态栏。
### updateEnemys更新怪物数据
使用 `{"type": "updateEnemys"}` 可以动态修改怪物数据。

View File

@ -293,6 +293,9 @@ control.prototype.resetStatus = function(hero, hard, floorId, route, maps, value
// 清除游戏数据
core.clearStatus();
// 显示状态栏
core.control.triggerStatusBar("show");
// 初始化status
core.status = core.clone(core.initStatus);
// 初始化maps
@ -2732,6 +2735,26 @@ control.prototype.updateStatusBar = function () {
}
}
control.prototype.triggerStatusBar = function (name) {
if (name!='hide') name='show';
var statusItems = core.dom.status;
var toolItems = core.dom.tools;
if (name == 'hide') {
for (var i = 0; i < statusItems.length; ++i)
statusItems[i].style.opacity = 0;
for (var i = 0; i < toolItems.length; ++i)
toolItems[i].style.display = 'none';
}
else {
for (var i = 0; i < statusItems.length; ++i)
statusItems[i].style.opacity = 1;
for (var i = 0; i < toolItems.length; ++i)
toolItems[i].style.display = 'block';
if (core.domStyle.screenMode != 'vertical')
core.statusBar.image.shop.style.display = 'none';
}
}
control.prototype.updateHeroIcon = function (name) {
name = name || "hero.png";
if (core.statusBar.icons.name == name) return;

View File

@ -98,8 +98,6 @@ events.prototype.startGame = function (hard, seed, route, callback) {
console.log('开始游戏');
core.resetStatus(core.firstData.hero, hard, core.firstData.floorId, null, core.initStatus.maps);
core.status.isStarting = true;
if (core.isset(seed)) {
core.setFlag('__seed__', seed);
core.setFlag('__rand__', seed);
@ -1046,6 +1044,14 @@ events.prototype.doAction = function() {
core.updateStatusBar();
this.doAction();
break;
case "showStatusBar":
core.control.triggerStatusBar("show");
this.doAction();
break;
case "hideStatusBar":
core.control.triggerStatusBar("hide");
this.doAction();
break;
case "updateEnemys":
core.enemys.updateEnemys();
core.updateStatusBar();

View File

@ -8,6 +8,8 @@
升级事件改用事件编辑器完成
每层楼都增添该层的并行事件处理
新增快捷键N返回标题P查看评论O打开工程
新增事件:设置全局属性或全局数值
新增事件:隐藏/显示状态栏
道具可以设置是否在回放时绘制道具栏或直接使用
可以同时异步移动/跳跃勇士和多个NPC
可以同时异步移动两张或以上的图片了