赞 | 6 |
VIP | 0 |
好人卡 | 5 |
积分 | 5 |
经验 | 13099 |
最后登录 | 2022-11-27 |
在线时间 | 271 小时 |
Lv2.观梦者
- 梦石
- 0
- 星屑
- 470
- 在线时间
- 271 小时
- 注册时间
- 2011-10-17
- 帖子
- 99
|
本帖最后由 wmzmtz 于 2018-3-6 20:24 编辑
大神,我尝试了下修改您那个插件,想实现按安卓返回键时,模拟电脑esc键(呼叫菜单、关闭菜单、返回功能)
现在的结果是,每打开游戏app后,第1次按安卓返回键时,能成功模拟(当前在地图上时就是呼叫菜单,当前在菜单里就是关闭菜单或者返回上一层),但是第2次按安卓返回键时,就又成了秒退游戏
我也是没辙了,望您指教,改动的代码如下,其实就是把//menu/return button的一部分代码替换进//PreventAndroidReturnKey那段的$(window).on('popstate', function()里了:
- if (AXY.AjaxNetStuff.Param.PreventAndroidReturnKey) {
- $(window).on('popstate', function() {
- if(!$gameMap){
- return;
- }
- if(!$gameMap._mapId){
- return;
- }
- TouchInput._events.cancelled = true;
- });
- window.history.pushState(null, null, '#forward');
- }
复制代码
另外,大神,我还想把你的//menu/return button那段改动改动,模拟别的按键。看你模拟返回是用TouchInput._events.cancelled = true实现的,请问我如果想模拟上、下、左、右、空格时,不知应该替换成什么代码呢?我对JS完全小白....
改动的代码如下,其实就是把您的代码放在了一个插件指令里启动,关键就是第30行可以怎么改才成实现模拟上下左右空格....
- var _Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
- Game_Interpreter.prototype.pluginCommand = function(command, args) {
- _Game_Interpreter_pluginCommand.call(this, command, args);
- if (command == "EnablePictureCommand") {
- //返回键
- if(AXY.AjaxNetStuff.Param.EnableMenuButton){
- //display html first
- var AXYAjaxMenuButtonTemplate =
- '<div class="AXYAjaxMenuButtonButtonImg"><img src="img/pictures/Button-Menu.png" class="AXYAjaxMenuButtonOpen"></div>';
- var AXYAjaxMenuButtonStyleCss =
- '.AXYAjaxMenuButtonButtonImg{position:fixed;z-index:10000;margin:auto;left:'+
- AXY.AjaxNetStuff.Param.ESC_X+'px;right:0;top:'+
- AXY.AjaxNetStuff.Param.ESC_Y+'px;bottom:0;pointer-events:none;}.AXYAjaxMenuButtonButtonImg img{width:'+
- AXY.AjaxNetStuff.Param.ImgWidth+'px;height:'+
- AXY.AjaxNetStuff.Param.ImgHeight+'px;opacity:'+
- AXY.AjaxNetStuff.Param.ImgOpacity+';pointer-events:auto;}';
- $('body').append(AXYAjaxMenuButtonTemplate);
- $('.AXYAjaxMenuButtonButtonImg').append('<style type="text/css">'+AXYAjaxMenuButtonStyleCss+'</style>');
- //last bind the click
- $('.AXYAjaxMenuButtonOpen').unbind('click touchend').bind('click touchend',function () {
- if(!$gameMap){
- return;
- }
- if(!$gameMap._mapId){
- return;
- }
- // TouchInput._events.cancelled = true;
- });
- }
- }
- };
复制代码
|
|