From 34ee2b0b200c941ca35c199ac9bf4281a4dac4c9 Mon Sep 17 00:00:00 2001 From: photonstorm Date: Fri, 28 Feb 2014 03:09:04 +0000 Subject: [PATCH] Fixed issue with CocoonJS detection in Device. Fixed docs issue in Tilemap. Created landscape pointer test, confirmed working fine (issue #276) --- README.md | 1 + examples/wip/bmd.js | 27 ++++----- examples/wip/cocoon.html | 12 ++++ examples/wip/cocoon.php | 95 +++++++++++++++++++++++++++++++ examples/wip/index-fs.php | 31 ++++++++++ examples/wip/index.php | 4 +- examples/wip/index2.php | 88 ---------------------------- examples/wip/landscape-pointer.js | 59 +++++++++++++++++++ src/system/Device.js | 2 +- src/tilemap/Tilemap.js | 5 ++ src/utils/Debug.js | 1 + 11 files changed, 218 insertions(+), 107 deletions(-) create mode 100644 examples/wip/cocoon.html create mode 100644 examples/wip/cocoon.php create mode 100644 examples/wip/index-fs.php create mode 100644 examples/wip/landscape-pointer.js diff --git a/README.md b/README.md index 39ac8265b..b9f6195c8 100644 --- a/README.md +++ b/README.md @@ -362,6 +362,7 @@ Beyond version 2.2 * Look at HiDPI Canvas settings. * Multiple Camera support. * DragonBones support. +* Cache to localStorage using If-Modified-Since. [See github request](https://github.com/photonstorm/phaser/issues/495) Nadion diff --git a/examples/wip/bmd.js b/examples/wip/bmd.js index c9cd8a802..2e55f0b39 100644 --- a/examples/wip/bmd.js +++ b/examples/wip/bmd.js @@ -1,9 +1,9 @@ -var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render }); +var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, update: update, render: render }); function preload() { - game.load.image('pic', 'assets/pics/backscroll.png'); + game.load.image('pic', '../assets/pics/questar.png'); } @@ -12,33 +12,26 @@ var bmd; function create() { - bmd = game.add.bitmapData(800, 600); - bmd.fillStyle('rgba(255,0,0,0.2)'); - // bmd.fillRect(0, 0, 300, 100); - // bmd.fillRect(0, 200, 300, 100); + game.add.image(0, 0, 'pic'); - image = game.add.image(0, 0, bmd); - // image.anchor.set(0.5); + console.log('pic?'); - game.input.onDown.add(tint, this); + // bmd = game.add.bitmapData(800, 600); + // bmd.context.fillStyle = 'rgba(255,0,0,0.2)'; + // bmd.context.fillRect(0, 0, 300, 100); -} - -function tint() { - - image.tint = Math.random() * 0xFFFFFF; + // image = game.add.image(0, 0, bmd); } function update() { - bmd.fillStyle('rgba(255,0,0,0.2)'); - bmd.fillRect(game.input.x, game.input.y, 6, 6); + // bmd.context.fillRect(game.input.x, game.input.y, 8, 8); } function render() { - game.debug.renderText(game.input.x, 32, 32); + // game.debug.renderText(game.input.x, 32, 32); } diff --git a/examples/wip/cocoon.html b/examples/wip/cocoon.html new file mode 100644 index 000000000..185050e18 --- /dev/null +++ b/examples/wip/cocoon.html @@ -0,0 +1,12 @@ + + + + + phaser + + + + + + + \ No newline at end of file diff --git a/examples/wip/cocoon.php b/examples/wip/cocoon.php new file mode 100644 index 000000000..65083f081 --- /dev/null +++ b/examples/wip/cocoon.php @@ -0,0 +1,95 @@ + $value) + { + if (is_array($value) && count($value) > 0) + { + $total += count($value); + } + } + + function getFile() { + + global $files, $dir, $filename, $title, $code; + + if (isset($_GET['d']) && isset($_GET['f'])) + { + $dir = urldecode($_GET['d']); + $filename = urldecode($_GET['d']) . '/' . urldecode($_GET['f']); + $title = urldecode($_GET['t']); + + if (file_exists($filename)) + { + $code = file_get_contents($filename); + $files = dirToArray($dir); + } + } + + } + + function dirToArray($dir) { + + $ignore = array('.', '..', '_site', 'assets', 'gfx', 'states', 'book', 'filters', 'misc'); + $result = array(); + $root = scandir($dir); + $dirs = array_diff($root, $ignore); + + foreach ($dirs as $key => $value) + { + if (is_dir($dir . DIRECTORY_SEPARATOR . $value)) + { + $result[$value] = dirToArray($dir . DIRECTORY_SEPARATOR . $value); + } + else + { + if (substr($value, -3) == '.js') + { + $result[] = $value; + } + } + } + + return $result; + } + + function printJSLinks($dir, $files) { + + $output = ""; + + foreach ($files as $key => $value) + { + $value2 = substr($value, 0, -3); + $file = urlencode($value); + + $output .= "$value2
"; + } + + return $output; + + } +?> + + + + + phaser + + + + + + + +
+ + + \ No newline at end of file diff --git a/examples/wip/index-fs.php b/examples/wip/index-fs.php new file mode 100644 index 000000000..9788e2106 --- /dev/null +++ b/examples/wip/index-fs.php @@ -0,0 +1,31 @@ + + + + + + phaser + + + + + + + + +
+ + + \ No newline at end of file diff --git a/examples/wip/index.php b/examples/wip/index.php index 76d4bea7c..a6a39448c 100644 --- a/examples/wip/index.php +++ b/examples/wip/index.php @@ -64,7 +64,7 @@ $value2 = substr($value, 0, -3); $file = urlencode($value); - $output .= "$value2
"; + $output .= "$value2(full screen)(cocoon)"; } return $output; @@ -110,9 +110,11 @@

work in progress examples

+ +
diff --git a/examples/wip/index2.php b/examples/wip/index2.php index a7a73672d..c4c272778 100644 --- a/examples/wip/index2.php +++ b/examples/wip/index2.php @@ -1,76 +1,3 @@ - $value) - { - if (is_array($value) && count($value) > 0) - { - $total += count($value); - } - } - - function getFile() { - - global $files, $dir, $filename, $title, $code; - - if (isset($_GET['d']) && isset($_GET['f'])) - { - $dir = urldecode($_GET['d']); - $filename = urldecode($_GET['d']) . '/' . urldecode($_GET['f']); - $title = urldecode($_GET['t']); - - if (file_exists($filename)) - { - $code = file_get_contents($filename); - $files = dirToArray($dir); - } - } - - } - - function dirToArray($dir) { - - $ignore = array('.', '..', '_site', 'assets', 'gfx', 'states', 'book', 'filters', 'misc'); - $result = array(); - $root = scandir($dir); - $dirs = array_diff($root, $ignore); - - foreach ($dirs as $key => $value) - { - if (is_dir($dir . DIRECTORY_SEPARATOR . $value)) - { - $result[$value] = dirToArray($dir . DIRECTORY_SEPARATOR . $value); - } - else - { - if (substr($value, -3) == '.js') - { - $result[] = $value; - } - } - } - - return $result; - } - - function printJSLinks($dir, $files) { - - $output = ""; - - foreach ($files as $key => $value) - { - $value2 = substr($value, 0, -3); - $file = urlencode($value); - - $output .= "$value2
"; - } - - return $output; - - } -?> @@ -93,8 +20,6 @@ body { margin: 0; padding: 0; - font-family: Arial; - font-size: 14px; } @@ -102,18 +27,5 @@
- - - -
- -

work in progress examples

- - - -
- \ No newline at end of file diff --git a/examples/wip/landscape-pointer.js b/examples/wip/landscape-pointer.js new file mode 100644 index 000000000..eac0cf1df --- /dev/null +++ b/examples/wip/landscape-pointer.js @@ -0,0 +1,59 @@ + +var game = new Phaser.Game(1024, 672, Phaser.CANVAS, 'phaser-example', { init: init, preload: preload, create: create, update: update, render: render }); + +function init() { + + game.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL; + game.scale.minWidth = 480; + game.scale.minHeight = 260; + game.scale.maxWidth = 1024; + game.scale.maxHeight = 768; + game.scale.forceOrientation(true, false); + game.scale.enterIncorrectOrientation.add(enterIncorrectOrientation, game); + game.scale.leaveIncorrectOrientation.add(leaveIncorrectOrientation, game); + game.scale.setScreenSize(true); + + game.stage.backgroundColor = 0x004400; + +} + +function preload() { + + game.load.spritesheet('mummy', 'assets/sprites/metalslug_mummy37x45.png', 37, 45, 18); + +} + +var mummy; +var anim; + +function create() { + + mummy = game.add.sprite(300, 200, 'mummy', 5); + + anim = mummy.animations.add('walk'); + + anim.play(20, true); + +} + +function enterIncorrectOrientation () { + + game.stage.backgroundColor = 0xff0000; + +} + +function leaveIncorrectOrientation () { + + game.stage.backgroundColor = 0x000033; + +} + +function update() { + +} + +function render() { + + game.debug.renderPointer(game.input.activePointer); + +} \ No newline at end of file diff --git a/src/system/Device.js b/src/system/Device.js index d26a4eb18..0e60d498c 100644 --- a/src/system/Device.js +++ b/src/system/Device.js @@ -414,7 +414,7 @@ Phaser.Device.prototype = { */ _checkFeatures: function () { - this.canvas = !!window['CanvasRenderingContext2D'] || this.iscocoonJS; + this.canvas = !!window['CanvasRenderingContext2D'] || this.cocoonJS; try { this.localStorage = !!localStorage.getItem; diff --git a/src/tilemap/Tilemap.js b/src/tilemap/Tilemap.js index cd99b2bb5..c594f9df0 100644 --- a/src/tilemap/Tilemap.js +++ b/src/tilemap/Tilemap.js @@ -998,11 +998,16 @@ Phaser.Tilemap.prototype = { * @method Phaser.Tilemap#getTileWorldXY * @param {number} x - X position to get the tile from (given in pixels) * @param {number} y - Y position to get the tile from (given in pixels) + * @param {number} [tileWidth] - The width of the tiles. If not given the map default is used. + * @param {number} [tileHeight] - The height of the tiles. If not given the map default is used. * @param {number|string|Phaser.TilemapLayer} [layer] - The layer to get the tile from. * @return {Phaser.Tile} The tile at the given coordinates. */ getTileWorldXY: function (x, y, tileWidth, tileHeight, layer) { + if (typeof tileWidth === 'undefined') { tileWidth = this.tileWidth; } + if (typeof tileHeight === 'undefined') { tileHeight = this.tileHeight; } + layer = this.getLayer(layer); x = this.game.math.snapToFloor(x, tileWidth) / tileWidth; diff --git a/src/utils/Debug.js b/src/utils/Debug.js index 8ef5490a1..8ba6da7ad 100644 --- a/src/utils/Debug.js +++ b/src/utils/Debug.js @@ -293,6 +293,7 @@ Phaser.Utils.Debug.prototype = { this.line('World X: ' + pointer.worldX + " World Y: " + pointer.worldY); this.line('Screen X: ' + pointer.x + " Screen Y: " + pointer.y); this.line('Duration: ' + pointer.duration + " ms"); + this.line('is Down: ' + pointer.isDown + " is Up: " + pointer.isUp); this.stop(); },