何か古い値を維持し、私はPhaserjsを使用し、デバイスクラスを上書きしよう....起こっ:グローバル変数は奇妙
let Device = (function(device)
{
return {
Android :function() {
return navigator.userAgent.match(/Android/i) == true;
//return Phaser.Device.Android != undefined;
},
BlackBerry: function() {
return navigator.userAgent.match(/BlackBerry/i) == true;
},
iOS: function() {
return navigator.userAgent.match(/iPhone|iPad|iPod/i) == true;
//return Phaser.Device.iOS == true;
},
Opera: function() {
return navigator.userAgent.match(/Opera Mini/i) == true;
},
Windows: function() {
return navigator.userAgent.match(/IEMobile/i) == true;
//return Phaser.Device.WindowsPhone != undefined;
},
firefox : function() {
return navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
//return Phaser.Device.Firefox == true;
},
any: function() {
return (Device.Android() || Device.BlackBerry() || Device.iOS() || Device.Opera() || Device.Windows());
},
debug: function()
{
//console.log("Ios "+Phaser.Device.Firefox+" Dev:"+Phaser.Device);
return "Android:"+Device.Android()+" "+
"BlackBerry:"+Device.BlackBerry()+" "+
"iOS:"+Device.iOS()+" "+
"Opera:"+Device.Opera()+" "+
"Windows:"+Device.Windows()+" "+
"firefox:"+Device.firefox();
}
};
})(Phaser.device);
export default Device;
Phaser.Deviceは、それが最初に初期化する必要が$(document).ready
シングルトンであるなど。機能は、私がメインスクリプトに次のようにデバイスをインポート
問題は、私はFirefoxやiOSの機能(Device.iOS()
)を呼び出すときに私は古い値ではなく初期化された値(真と偽)を取得することですPhaser.Device.whenReady(foobar,this);
です:
import Device from './helpers/GameDevice';
なぜですか?問題の継ぎ目は範囲の問題になるが、私は何を知りません!
古い値は何ですか? –
私はFFですので、私はFirefox:TRUEとiOS:FALSEを持っている必要がありますが、私はFF:FALSEとiOS:trueを返します。 – xeonarno
アドオンを含む多くの理由で、ブラウザの検出に失敗することがあります。 navigator.userAgentは最新のものなので、常に動作するとは限りません –