網頁 http://fattyboy.cn/gt/ 在 firefox、chrome 會有問題, 需修正如下: 1. tiny-game.js 第 258 行: - window.devicePixelRatio = window.devicePixelRatio || 1; + if (!window.devicePixelRatio) window.devicePixelRatio = 1; 2. main.js 第 290,300 行: dom.addEventListener 的 callback function 要帶入 event
2014-06-18
謝謝. 我就是用的 chrome 啊 沒有遇到問題啊. firefox 我確實不支持 以后也不會支持. 1 第 258 行 你寫的那個 和我寫的那個有什么不同? 2 謝謝. 稍后更正. :)
2014-08-16
我用的是 MBP。關鍵點是:
1. Firefox 不允許更改 window.devicePixelRatio, 會報錯并中止執行 JS, 也許是 desktop 版的關系。所以改成 window.devicePixelRatio 已有值時就不再設定。
2. Event callback 函式依 W3C 標準第一個參數是 event 物件, IE 瀏覽器卻允許不帶參數, 故函式中的 event 會引用全域變數, 但在其他瀏覽器中應無 event 全域變數(chrome 有?), 因此會造成非 IE 瀏覽器的錯誤。一個快速避開的方式是在 event callback 函式中檢查 event:
function(event) {
if (event == null) event = window.event;
....
}