ios
This commit is contained in:
parent
eb00081e6e
commit
8454108be0
|
@ -71,15 +71,21 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},5000);
|
},5000);
|
||||||
if(navigator.userAgent.toLowerCase().indexOf('android')!=-1){
|
var scripts=document.head.querySelectorAll('script');
|
||||||
var script=document.createElement('script');
|
for(var i=0;i<scripts.length;i++){
|
||||||
script.src='cordova.js';
|
if(scripts[i].src&&scripts[i].src.indexOf('game/game.js')!=-1){
|
||||||
document.body.appendChild(script);
|
if(scripts[i].src.indexOf('ios')!=-1||scripts[i].src.indexOf('android')!=-1){
|
||||||
document.addEventListener('deviceready',function(){
|
var script=document.createElement('script');
|
||||||
if(window._onDeviceReady){
|
script.src='cordova.js';
|
||||||
window._onDeviceReady();
|
document.body.appendChild(script);
|
||||||
delete window._onDeviceReady;
|
document.addEventListener('deviceready',function(){
|
||||||
|
if(window._onDeviceReady){
|
||||||
|
window._onDeviceReady();
|
||||||
|
delete window._onDeviceReady;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}())
|
}())
|
||||||
|
|
84
game/game.js
84
game/game.js
|
@ -2821,20 +2821,25 @@
|
||||||
for(var i=0;i<scripts.length;i++){
|
for(var i=0;i<scripts.length;i++){
|
||||||
if(scripts[i].src&&scripts[i].src.indexOf('game/game.js')!=-1){
|
if(scripts[i].src&&scripts[i].src.indexOf('game/game.js')!=-1){
|
||||||
if(scripts[i].src.indexOf('ios')!=-1){
|
if(scripts[i].src.indexOf('ios')!=-1){
|
||||||
|
lib.device='ios';
|
||||||
var ua=navigator.userAgent.toLowerCase();
|
var ua=navigator.userAgent.toLowerCase();
|
||||||
if(ua.indexOf('ipad')!=-1){
|
if(ua.indexOf('ipad')!=-1){
|
||||||
window.isIpad=true;
|
window.isIpad=true;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
var metas=document.head.querySelectorAll('meta');
|
var metas=document.head.querySelectorAll('meta');
|
||||||
for(var i=0;i<metas.length;i++){
|
for(var j=0;j<metas.length;j++){
|
||||||
if(metas[i].name=='viewport'){
|
if(metas[j].name=='viewport'){
|
||||||
metas[i].content="user-scalable=no, initial-scale=0.6, maximum-scale=0.6, minimum-scale=0.6, width=device-width, height=device-height";
|
metas[j].content="user-scalable=no, initial-scale=0.6, maximum-scale=0.6, minimum-scale=0.6, width=device-width, height=device-height";
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(scripts[i].src.indexOf('cordova')!=-1){
|
else if(scripts[i].src.indexOf('android')!=-1){
|
||||||
|
lib.device='android';
|
||||||
|
}
|
||||||
|
if(scripts[i].src.indexOf('cdvfile')!=-1){
|
||||||
lib.assetLoading=[];
|
lib.assetLoading=[];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -3164,7 +3169,7 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if(navigator.userAgent.toLowerCase().indexOf('android')!=-1){
|
if(lib.device=='android'){
|
||||||
window._onDeviceReady=function(){
|
window._onDeviceReady=function(){
|
||||||
document.addEventListener("pause", function(){
|
document.addEventListener("pause", function(){
|
||||||
if(!_status.paused2&&!_status.event.isMine()){
|
if(!_status.paused2&&!_status.event.isMine()){
|
||||||
|
@ -3200,31 +3205,32 @@
|
||||||
navigator.app.exitApp();
|
navigator.app.exitApp();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if(window.resolveLocalFileSystemURL){
|
if(Array.isArray(lib.assetLoading)){
|
||||||
window.resolveLocalFileSystemURL(cordova.file.externalApplicationStorageDirectory,function(entry){
|
var url=cordova.file.externalApplicationStorageDirectory;
|
||||||
var url=entry.toURL();
|
for(var i=0;i<lib.assetLoading.length;i++){
|
||||||
if(Array.isArray(lib.assetLoading)){
|
var item=lib.assetLoading[i];
|
||||||
for(var i=0;i<lib.assetLoading.length;i++){
|
if(typeof item=='string'){
|
||||||
var item=lib.assetLoading[i];
|
ui.fontsheet.sheet.insertRule("@font-face {font-family: '"+item+"';src: url('"+url+"font/"+item+".ttf');}",0);
|
||||||
if(typeof item=='string'){
|
|
||||||
ui.fontsheet.sheet.insertRule("@font-face {font-family: '"+item+"';src: url('"+url+"font/"+item+".ttf');}",0);
|
|
||||||
}
|
|
||||||
else if(item._cordovaimg){
|
|
||||||
item.style.backgroundImage='url("'+url+item._cordovaimg+'")';
|
|
||||||
delete item._cordovaimg;
|
|
||||||
}
|
|
||||||
else if(item._cordovasrc){
|
|
||||||
item.src=url+item._cordovasrc;
|
|
||||||
delete item._cordovasrc;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
delete lib.assetLoading;
|
else if(item._cordovaimg){
|
||||||
lib.assetURL=url;
|
item.style.backgroundImage='url("'+url+item._cordovaimg+'")';
|
||||||
});
|
delete item._cordovaimg;
|
||||||
|
}
|
||||||
|
else if(item._cordovasrc){
|
||||||
|
item.src=url+item._cordovasrc;
|
||||||
|
delete item._cordovasrc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
delete lib.assetLoading;
|
||||||
|
lib.assetURL=url;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if(lib.device=='ios'){
|
||||||
|
window._onDeviceReady=function(){
|
||||||
|
game.export('123');
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
css:function(path,file,before){
|
css:function(path,file,before){
|
||||||
var style = document.createElement("link");
|
var style = document.createElement("link");
|
||||||
|
@ -9941,12 +9947,19 @@
|
||||||
var fileNameToSaveAs = name||'noname';
|
var fileNameToSaveAs = name||'noname';
|
||||||
fileNameToSaveAs=fileNameToSaveAs.replace(/\\|\/|\:|\?|\"|\*|\<|\>|\|/g,'.');
|
fileNameToSaveAs=fileNameToSaveAs.replace(/\\|\/|\:|\?|\"|\*|\<|\>|\|/g,'.');
|
||||||
|
|
||||||
if(window.resolveLocalFileSystemURL){
|
if(lib.device=='android'||lib.device=='ios'){
|
||||||
window.resolveLocalFileSystemURL(cordova.file.externalDataDirectory,function(entry){
|
var directory;
|
||||||
|
if(lib.device=='android'){
|
||||||
|
directory=cordova.file.externalDataDirectory;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
directory=cordova.file.documentsDirectory;
|
||||||
|
}
|
||||||
|
window.resolveLocalFileSystemURL(directory,function(entry){
|
||||||
entry.getFile(fileNameToSaveAs,{create:true},function(fileEntry){
|
entry.getFile(fileNameToSaveAs,{create:true},function(fileEntry){
|
||||||
fileEntry.createWriter(function(fileWriter){
|
fileEntry.createWriter(function(fileWriter){
|
||||||
fileWriter.onwriteend=function(){
|
fileWriter.onwriteend=function(){
|
||||||
alert('文件已导出至'+cordova.file.externalDataDirectory+fileNameToSaveAs);
|
alert('文件已导出至'+directory+fileNameToSaveAs);
|
||||||
}
|
}
|
||||||
fileWriter.write(textFileAsBlob)
|
fileWriter.write(textFileAsBlob)
|
||||||
});
|
});
|
||||||
|
@ -9977,11 +9990,18 @@
|
||||||
fileNameToSaveAs+='.zip';
|
fileNameToSaveAs+='.zip';
|
||||||
|
|
||||||
if(window.resolveLocalFileSystemURL){
|
if(window.resolveLocalFileSystemURL){
|
||||||
window.resolveLocalFileSystemURL(cordova.file.externalDataDirectory,function(entry){
|
var directory;
|
||||||
|
if(lib.device=='android'){
|
||||||
|
directory=cordova.file.externalDataDirectory;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
directory=cordova.file.documentsDirectory;
|
||||||
|
}
|
||||||
|
window.resolveLocalFileSystemURL(directory,function(entry){
|
||||||
entry.getFile(fileNameToSaveAs,{create:true},function(fileEntry){
|
entry.getFile(fileNameToSaveAs,{create:true},function(fileEntry){
|
||||||
fileEntry.createWriter(function(fileWriter){
|
fileEntry.createWriter(function(fileWriter){
|
||||||
fileWriter.onwriteend=function(){
|
fileWriter.onwriteend=function(){
|
||||||
alert('文件已导出至'+cordova.file.externalDataDirectory+fileNameToSaveAs);
|
alert('文件已导出至'+directory+fileNameToSaveAs);
|
||||||
}
|
}
|
||||||
fileWriter.write(blob)
|
fileWriter.write(blob)
|
||||||
});
|
});
|
||||||
|
@ -15152,7 +15172,7 @@
|
||||||
game.saveConfig('extension_'+extname+'_'+i,game.importedPack.config[i].init);
|
game.saveConfig('extension_'+extname+'_'+i,game.importedPack.config[i].init);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(game.importedPack.image){
|
if(game.importedPack.image&&lib.db){
|
||||||
for(var i=0;i<game.importedPack.image.length;i++){
|
for(var i=0;i<game.importedPack.image.length;i++){
|
||||||
var buttons=page.querySelectorAll('.button.character');
|
var buttons=page.querySelectorAll('.button.character');
|
||||||
for(var j=0;j<buttons.length;j++){
|
for(var j=0;j<buttons.length;j++){
|
||||||
|
|
Loading…
Reference in New Issue