mirror of
https://github.com/wassname/phaser.git
synced 2026-08-20 12:40:12 +08:00
Device, Canvas and GamePad classes all updated for better CocoonJS support (thanks Videlais)
This commit is contained in:
@@ -67,7 +67,7 @@ Phaser.Gamepad = function (game) {
|
||||
* @property {boolean} _gamepadSupportAvailable - Are gamepads supported in this browser or not?
|
||||
* @private
|
||||
*/
|
||||
this._gamepadSupportAvailable = !!navigator.webkitGetGamepads || !!navigator.webkitGamepads || (navigator.userAgent.indexOf('Firefox/') != -1);
|
||||
this._gamepadSupportAvailable = !!navigator.webkitGetGamepads || !!navigator.webkitGamepads || (navigator.userAgent.indexOf('Firefox/') != -1) || !!navigator.getGamepads;
|
||||
|
||||
/**
|
||||
* Used to check for differences between earlier polls and current state of gamepads.
|
||||
@@ -220,7 +220,7 @@ Phaser.Gamepad.prototype = {
|
||||
*/
|
||||
_pollGamepads: function () {
|
||||
|
||||
var rawGamepads = (navigator.webkitGetGamepads && navigator.webkitGetGamepads()) || navigator.webkitGamepads;
|
||||
var rawGamepads = (navigator.webkitGetGamepads && navigator.webkitGetGamepads()) || navigator.webkitGamepads || navigator.getGamepads;
|
||||
|
||||
if (rawGamepads)
|
||||
{
|
||||
|
||||
@@ -26,7 +26,8 @@ Phaser.Canvas = {
|
||||
width = width || 256;
|
||||
height = height || 256;
|
||||
|
||||
var canvas = document.createElement('canvas');
|
||||
// var canvas = document.createElement('canvas');
|
||||
var canvas = document.createElement(navigator.isCocoonJS ? 'screencanvas' : 'canvas');
|
||||
|
||||
if (typeof id === 'string')
|
||||
{
|
||||
|
||||
@@ -385,7 +385,7 @@ Phaser.Device.prototype = {
|
||||
*/
|
||||
_checkFeatures: function () {
|
||||
|
||||
this.canvas = !!window['CanvasRenderingContext2D'];
|
||||
this.canvas = !!window['CanvasRenderingContext2D'] || this.iscocoonJS;
|
||||
|
||||
try {
|
||||
this.localStorage = !!localStorage.getItem;
|
||||
|
||||
Reference in New Issue
Block a user