Merge remote-tracking branch 'refs/remotes/ckcz123/master' into dev-2.0-blockly-20180214
This commit is contained in:
commit
2fe7150b0e
@ -267,8 +267,8 @@
|
||||
|
||||
``` js
|
||||
"x,y": [ // 实际执行的事件列表
|
||||
{"type": "setText", "position": "up", "title": [255,0,0], "text": [255,255,0], "background": [0,0,255,0.3]},
|
||||
"这段话将显示在上方,标题为红色,正文为黄色,背景为透明度0.3的蓝色"
|
||||
{"type": "setText", "position": "up", "title": [255,0,0], "text": [255,255,0], "background": [0,0,255,0.3], "bold": true},
|
||||
"这段话将显示在上方,标题为红色,正文为黄色粗体,背景为透明度0.3的蓝色"
|
||||
]
|
||||
```
|
||||
|
||||
@ -280,6 +280,8 @@ text为可选项,如果设置则为一个RGB三元组或RGBA四元组,表示
|
||||
|
||||
background为可选项,如果设置则为一个RGB三元组或RGBA四元组,表示背景色。
|
||||
|
||||
bold为可选项,如果设置则为true或false,表示正文是否使用粗体。
|
||||
|
||||
### tip:显示一段提示文字
|
||||
|
||||
`{"type": "tip"}`可以在左上角显示一段提示文字。
|
||||
@ -1324,7 +1326,7 @@ events.prototype.afterPushBox = function () {
|
||||
- 如果`effect`为字符串,则和上面的全局商店的写法完全相同。可由分号分开,每一项为X+=Y的形式,X为你要修改的勇士属性/道具个数,Y为一个表达式。
|
||||
- 如果`effect`为函数,则也允许写一个`function`,来代表本次升级将会执行的操作。
|
||||
|
||||
## 开始,难度分歧,获胜与失败
|
||||
## 开始,难度分歧,获胜与失败,多结局
|
||||
|
||||
游戏开始时将调用`events.js`中的`startGame`函数。
|
||||
|
||||
@ -1362,13 +1364,16 @@ events.prototype.setInitData = function (hard) {
|
||||
``` js
|
||||
////// 游戏获胜事件 //////
|
||||
events.prototype.win = function(reason) {
|
||||
core.ui.closePanel();
|
||||
var replaying = core.status.replay.replaying;
|
||||
core.stopReplay();
|
||||
core.waitHeroToStop(function() {
|
||||
core.removeGlobalAnimate(0,0,true);
|
||||
core.clearMap('all'); // 清空全地图
|
||||
core.drawText([
|
||||
"\t[结局2]恭喜通关!你的分数是${status:hp}。"
|
||||
"\t[恭喜通关]你的分数是${status:hp}。"
|
||||
], function () {
|
||||
core.restart();
|
||||
core.events.gameOver('', replaying);
|
||||
})
|
||||
});
|
||||
}
|
||||
@ -1381,11 +1386,14 @@ events.prototype.win = function(reason) {
|
||||
``` js
|
||||
////// 游戏失败事件 //////
|
||||
events.prototype.lose = function(reason) {
|
||||
core.ui.closePanel();
|
||||
var replaying = core.status.replay.replaying;
|
||||
core.stopReplay();
|
||||
core.waitHeroToStop(function() {
|
||||
core.drawText([
|
||||
"\t[结局1]你死了。\n如题。"
|
||||
], function () {
|
||||
core.restart();
|
||||
core.events.gameOver(null, replaying);
|
||||
});
|
||||
})
|
||||
}
|
||||
@ -1393,6 +1401,26 @@ events.prototype.lose = function(reason) {
|
||||
|
||||
其参数reason为失败原因。你可以在这里修改失败界面时显示的文字。
|
||||
|
||||
如果要设置多种不同的结局,只需要在win的传参中把`core.events.gameOver('', replaying);`的空字符串改成具体的结局名。
|
||||
|
||||
例如:
|
||||
|
||||
``` js
|
||||
events.prototype.win = function(reason) { // 传入参数"reason"为结局名
|
||||
// ... 上略
|
||||
], function () {
|
||||
core.events.gameOver(reason, replaying); // 使用reason作为结局名
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 然后在事件可以调用
|
||||
{"type": "win", "reason": "TRUE END"}, // TE结局
|
||||
{"type": "win", "reason": "NORMAL END"} // NE结局
|
||||
```
|
||||
|
||||
上面这个例子中,我们直接把reason作为结局名的参数传入gameOver函数,这样的话就可以直接在{"type": "win"}中加上"reason"代表具体的结局。
|
||||
|
||||
==========================================================================================
|
||||
|
||||
[继续阅读下一章:个性化](personalization)
|
||||
|
||||
@ -130,6 +130,7 @@ function core() {
|
||||
"title": [255,215,0,1],
|
||||
"background": [0,0,0,0.85],
|
||||
"text": [255,255,255,1],
|
||||
"bold": false,
|
||||
},
|
||||
'curtainColor': null,
|
||||
'usingCenterFly':false,
|
||||
@ -4783,8 +4784,10 @@ core.prototype.loadData = function (data, callback) {
|
||||
|
||||
// load shop times
|
||||
for (var shop in core.status.shops) {
|
||||
core.status.shops[shop].times = data.shops[shop].times;
|
||||
core.status.shops[shop].visited = data.shops[shop].visited;
|
||||
if (core.isset(data.shops[shop])) {
|
||||
core.status.shops[shop].times = data.shops[shop].times;
|
||||
core.status.shops[shop].visited = data.shops[shop].visited;
|
||||
}
|
||||
}
|
||||
|
||||
core.events.afterLoadData(data);
|
||||
|
||||
@ -313,6 +313,9 @@ events.prototype.doAction = function() {
|
||||
core.status.textAttribute[t]=data[t];
|
||||
}
|
||||
})
|
||||
if (core.isset(data.bold)) {
|
||||
core.status.textAttribute.bold=data.bold;
|
||||
}
|
||||
core.events.doAction();
|
||||
break;
|
||||
case "tip":
|
||||
|
||||
@ -120,7 +120,9 @@ ui.prototype.drawTextBox = function(content) {
|
||||
if (id=='hero' || core.isset(icon)) content_left=left+63;
|
||||
|
||||
var validWidth = right-(content_left-left)-13;
|
||||
var contents = core.splitLines("ui", content, validWidth, '16px Verdana');
|
||||
var font = '16px Verdana';
|
||||
if (textAttribute.bold) font = "bold "+font;
|
||||
var contents = core.splitLines("ui", content, validWidth, font);
|
||||
|
||||
var height = 20 + 21*(contents.length+1) + (id=='hero'?core.material.icons.hero.height-10:core.isset(name)?32-10:0);
|
||||
|
||||
@ -229,7 +231,7 @@ ui.prototype.drawTextBox = function(content) {
|
||||
core.setFillStyle('ui', core.arrayToRGB(textAttribute.text));
|
||||
|
||||
for (var i=0;i<contents.length;i++) {
|
||||
core.fillText('ui', contents[i], content_left, content_top, null, '16px Verdana');
|
||||
core.fillText('ui', contents[i], content_left, content_top, null, font);
|
||||
content_top+=21;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user