Cursor
This commit is contained in:
parent
deb465ed5c
commit
e0b7331a1a
30
libs/core.js
30
libs/core.js
@ -94,6 +94,8 @@ function core() {
|
||||
'destY': null,
|
||||
'autoStepRoutes': [],
|
||||
'moveStepBeforeStop': [],
|
||||
'cursorX': null,
|
||||
'cursorY': null,
|
||||
},
|
||||
|
||||
// 按下键的时间:为了判定双击
|
||||
@ -711,6 +713,10 @@ core.prototype.keyDown = function(keyCode) {
|
||||
core.events.keyDownLocalSaveSelect(keyCode);
|
||||
return;
|
||||
}
|
||||
if (core.status.event.id=='cursor') {
|
||||
core.events.keyDownCursor(keyCode);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if(!core.status.played) {
|
||||
@ -834,6 +840,11 @@ core.prototype.keyUp = function(keyCode) {
|
||||
core.events.keyUpLocalSaveSelect(keyCode);
|
||||
return;
|
||||
}
|
||||
|
||||
if (core.status.event.id=='cursor') {
|
||||
core.events.keyUpCursor(keyCode);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@ -864,6 +875,10 @@ core.prototype.keyUp = function(keyCode) {
|
||||
if (core.status.heroStop)
|
||||
core.load(true);
|
||||
break;
|
||||
case 69: // E
|
||||
if (core.status.heroStop)
|
||||
core.ui.drawCursor();
|
||||
break;
|
||||
case 84: // T
|
||||
if (core.status.heroStop)
|
||||
core.openToolbox(true);
|
||||
@ -1049,6 +1064,8 @@ core.prototype.onclick = function (x, y, stepPostfix) {
|
||||
if (core.isset(core.status.replay)&&core.status.replay.replaying) return;
|
||||
// console.log("Click: (" + x + "," + y + ")");
|
||||
|
||||
stepPostfix=stepPostfix||[];
|
||||
|
||||
// 非游戏屏幕内
|
||||
if (x<0 || y<0 || x>12 || y>12) return;
|
||||
|
||||
@ -1180,6 +1197,11 @@ core.prototype.onclick = function (x, y, stepPostfix) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (core.status.event.id == 'cursor') {
|
||||
core.events.clickCursor(x,y);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
////// 滑动鼠标滚轮时的操作 //////
|
||||
@ -1933,6 +1955,10 @@ core.prototype.openDoor = function (id, x, y, needKey, callback) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!core.isset(core.status.event.id)) // 自动存档
|
||||
core.autosave(true);
|
||||
|
||||
// open
|
||||
core.playSound("door.ogg");
|
||||
var state = 0;
|
||||
@ -1974,6 +2000,10 @@ core.prototype.battle = function (id, x, y, force, callback) {
|
||||
core.clearContinueAutomaticRoute();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!core.isset(core.status.event.id)) // 自动存档
|
||||
core.autosave(true);
|
||||
|
||||
if (core.flags.battleAnimate&&!core.status.replay.replaying) {
|
||||
core.waitHeroToStop(function() {
|
||||
core.ui.drawBattleAnimate(id, function() {
|
||||
|
||||
@ -6,7 +6,7 @@ function events() {
|
||||
events.prototype.init = function () {
|
||||
this.events = {
|
||||
'battle': function (data, core, callback) {
|
||||
core.autosave(true);
|
||||
//core.autosave(true);
|
||||
core.battle(data.event.id, data.x, data.y);
|
||||
if (core.isset(callback))
|
||||
callback();
|
||||
@ -17,7 +17,7 @@ events.prototype.init = function () {
|
||||
callback();
|
||||
},
|
||||
'openDoor': function (data, core, callback) {
|
||||
core.autosave(true);
|
||||
//core.autosave(true);
|
||||
core.openDoor(data.event.id, data.x, data.y, true, function () {
|
||||
if (core.isset(callback)) callback();
|
||||
core.replay();
|
||||
@ -224,14 +224,14 @@ events.prototype.afterChangeFloor = function (floorId) {
|
||||
|
||||
if (!core.hasFlag("visited_"+floorId)) {
|
||||
this.doEvents(core.floors[floorId].firstArrive, null, null, function () {
|
||||
core.autosave();
|
||||
//core.autosave();
|
||||
});
|
||||
core.setFlag("visited_"+floorId, true);
|
||||
return;
|
||||
}
|
||||
|
||||
// 自动存档
|
||||
core.autosave();
|
||||
//core.autosave();
|
||||
}
|
||||
|
||||
////// 开始执行一系列自定义事件 //////
|
||||
@ -1989,6 +1989,56 @@ events.prototype.clickKeyBoard = function (x, y) {
|
||||
core.ui.closePanel();
|
||||
}
|
||||
|
||||
////// 光标界面时的点击操作 //////
|
||||
events.prototype.clickCursor = function (x,y) {
|
||||
|
||||
if (x==core.status.automaticRoute.cursorX && y==core.status.automaticRoute.cursorY) {
|
||||
core.ui.closePanel();
|
||||
core.onclick(x,y,[]);
|
||||
return;
|
||||
}
|
||||
core.status.automaticRoute.cursorX=x;
|
||||
core.status.automaticRoute.cursorY=y;
|
||||
core.ui.drawCursor();
|
||||
}
|
||||
|
||||
////// 光标界面时,按下某个键的操作 //////
|
||||
events.prototype.keyDownCursor = function (keycode) {
|
||||
if (keycode==37) { // left
|
||||
core.status.automaticRoute.cursorX--;
|
||||
core.ui.drawCursor();
|
||||
return;
|
||||
}
|
||||
if (keycode==38) { // up
|
||||
core.status.automaticRoute.cursorY--;
|
||||
core.ui.drawCursor();
|
||||
return;
|
||||
}
|
||||
if (keycode==39) { // right
|
||||
core.status.automaticRoute.cursorX++;
|
||||
core.ui.drawCursor();
|
||||
return;
|
||||
}
|
||||
if (keycode==40) { // down
|
||||
core.status.automaticRoute.cursorY++;
|
||||
core.ui.drawCursor();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
////// 光标界面时,放开某个键的操作 //////
|
||||
events.prototype.keyUpCursor = function (keycode) {
|
||||
if (keycode==27 || keycode==88) {
|
||||
core.ui.closePanel();
|
||||
return;
|
||||
}
|
||||
if (keycode==13 || keycode==32 || keycode==67 || keycode==69) {
|
||||
core.ui.closePanel();
|
||||
core.onclick(core.status.automaticRoute.cursorX, core.status.automaticRoute.cursorY, []);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
////// “关于”界面时的点击操作 //////
|
||||
events.prototype.clickAbout = function () {
|
||||
if (core.isPlaying())
|
||||
|
||||
24
libs/ui.js
24
libs/ui.js
@ -726,6 +726,30 @@ ui.prototype.drawPagination = function (page, totalPage) {
|
||||
|
||||
}
|
||||
|
||||
////// 绘制键盘光标 //////
|
||||
ui.prototype.drawCursor = function () {
|
||||
|
||||
if (!core.isset(core.status.automaticRoute.cursorX))
|
||||
core.status.automaticRoute.cursorX=core.getHeroLoc('x');
|
||||
if (core.status.automaticRoute.cursorX<0) core.status.automaticRoute.cursorX=0;
|
||||
if (core.status.automaticRoute.cursorX>12) core.status.automaticRoute.cursorX=12;
|
||||
if (!core.isset(core.status.automaticRoute.cursorY))
|
||||
core.status.automaticRoute.cursorY=core.getHeroLoc('y');
|
||||
if (core.status.automaticRoute.cursorY<0) core.status.automaticRoute.cursorY=0;
|
||||
if (core.status.automaticRoute.cursorY>12) core.status.automaticRoute.cursorY=12;
|
||||
|
||||
core.status.event.id = 'cursor';
|
||||
core.lockControl();
|
||||
|
||||
core.clearMap('ui', 0, 0, 416, 416);
|
||||
core.setAlpha('ui', 1);
|
||||
|
||||
var width = 4;
|
||||
core.strokeRect('ui', 32*core.status.automaticRoute.cursorX+width/2, 32*core.status.automaticRoute.cursorY+width/2,
|
||||
32-width, 32-width, '#FFD700', width);
|
||||
|
||||
}
|
||||
|
||||
////// 绘制怪物手册 //////
|
||||
ui.prototype.drawBook = function (index) {
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user