flag:px & flag:py

This commit is contained in:
oc 2018-12-30 01:44:53 +08:00
parent 0c33f89e8b
commit d702ef4d3f
4 changed files with 36 additions and 10 deletions

View File

@ -1647,7 +1647,7 @@ choices为一个数组其中每一项都是一个选项列表。
当用户执行操作后:
- 如果是键盘的按键操作则会将flag:type置为0并且把flag:keycode置为刚刚按键的keycode。
- 如果是屏幕的点击操作则会将flag:type置为1并且设置flag:x和flag:y为刚刚的点击坐标。
- 如果是屏幕的点击操作则会将flag:type置为1并且设置flag:x和flag:y为刚刚的点击坐标0-12之间flag:px和flag:py置为刚刚的像素坐标0-415之间
下面是一个while事件和wait合并使用的例子这个例子将不断接收用户的点击或按键行为并输出该信息。
如果用户按下了ESC或者点击了屏幕正中心则退出循环。
@ -1667,7 +1667,7 @@ choices为一个数组其中每一项都是一个选项列表。
}
],
"false": [ // flag:type==1鼠标点击
"你当前点击屏幕了,坐标是[${flag:x},${flag:y}]",
"你当前点击屏幕了,位置坐标是[${flag:x},${flag:y}],像素坐标是[${flag:px},${flag:py}]",
{"type": "if", "condition": "flag:x==6 && flag:y==6", // 点击(6,6)
"true": [{"type": "break"}], // 跳出循环
"false": []

View File

@ -951,7 +951,7 @@ this.getAchievements = function () {
- **`flag:hatred`**: 当前的仇恨数值。
- **`flag:commonTimes`**: 全局商店共用次数时的访问次数。
- **`flag:input`**: 接受用户输入的事件后,存放用户输入的结果。
- **`flag:type`**, **`flag:keycode`**, **`flag:x`**, **`flag:y`**: 等待用户操作后用户的操作类型按键keycode或点击坐标。
- **`flag:type`**, **`flag:keycode`**, **`flag:x`**, **`flag:y`**, **`flag:px`**, **`flag:py`**: 等待用户操作后用户的操作类型按键keycode或点击/像素坐标。
- **`flag:skill`**, **`flag:skillName`**: 开启的技能编号和技能名。
- **`flag:heroIcon`**: 当前的勇士行走图名称。
- **`flag:saveEquips`**: 快速换装时保存的套装。

View File

@ -329,16 +329,29 @@ actions.prototype.keyUp = function(keyCode, altKey, fromReplay) {
actions.prototype.ondown = function (loc) {
if (this.checkReplaying()) return;
var x = parseInt(loc.x / loc.size), y = parseInt(loc.y / loc.size);
var px = parseInt(loc.x/core.domStyle.scale), py = parseInt(loc.y/core.domStyle.scale);
// 画板
if (core.status.played && (core.status.event||{}).id=='paint') {
this.ondownPaint(loc.x/core.domStyle.scale, loc.y/core.domStyle.scale);
this.ondownPaint(px, py);
return;
}
var x = parseInt(loc.x / loc.size), y = parseInt(loc.y / loc.size);
if (!core.status.played || core.status.lockControl) {
if (!this.checkReplaying() && core.status.event.id=='action' && core.status.event.data.type=='wait') {
core.setFlag('type', 1);
core.setFlag('x', x);
core.setFlag('y', y);
core.setFlag('px', px);
core.setFlag('py', py);
core.status.route.push("input:"+(1000000+1000*px+py));
core.doAction();
}
else {
this.onclick(x, y, []);
}
if (core.timeout.onDownTimeout==null) {
core.timeout.onDownTimeout = setTimeout(function () {
if (core.interval.onDownInterval == null) {
@ -789,6 +802,7 @@ actions.prototype.clickAction = function (x,y) {
core.doAction();
return;
}
/*
if (core.status.event.data.type=='wait') {
core.setFlag('type', 1);
core.setFlag('x', x);
@ -797,6 +811,7 @@ actions.prototype.clickAction = function (x,y) {
core.doAction();
return;
}
*/
if (core.status.event.data.type=='choices') {
// 选项

View File

@ -1188,10 +1188,21 @@ events.prototype.doAction = function() {
if (code.indexOf("input:")==0) {
var value = parseInt(code.substring(6));
core.status.route.push("input:"+value);
if (value>=10000) {
if (value>=1000000) {
core.setFlag('type', 1);
core.setFlag('x', parseInt((value-10000)/100));
core.setFlag('y', value%100);
var px = parseInt((value-1000000)/1000), py = value%1000;
core.setFlag('px', px);
core.setFlag('py', py);
core.setFlag('x', parseInt(px/32));
core.setFlag('y', parseInt(py/32));
}
else if (value>=10000) {
core.setFlag('type', 1);
var x = parseInt((value-10000)/100), y = value%100;
core.setFlag('px', 32*x+16);
core.setFlag('py', 32*y+16);
core.setFlag('x', x);
core.setFlag('y', y);
}
else {
core.setFlag('type', 0);