Fixed issue with CocoonJS detection in Device.

Fixed docs issue in Tilemap.
Created landscape pointer test, confirmed working fine (issue #276)
This commit is contained in:
photonstorm 2014-02-28 03:09:04 +00:00
parent 43cd5e4b3f
commit 34ee2b0b20
11 changed files with 218 additions and 107 deletions

View file

@ -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

View file

@ -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);
}

12
examples/wip/cocoon.html Normal file
View file

@ -0,0 +1,12 @@
<!doctype html>
<html>
<head>
<meta charset="UTF-8" />
<title>phaser</title>
<script src="../../dist/phaser.js" type="text/javascript"></script>
<script src="bmd.js" type="text/javascript"></script>
</head>
<body>
</body>
</html>

95
examples/wip/cocoon.php Normal file
View file

@ -0,0 +1,95 @@
<?php
// Global
$files = dirToArray(dirname(__FILE__));
$total = 0;
foreach ($files as $key => $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 .= "<a href=\"wip/index.php?f=$file\">$value2</a><br />";
}
return $output;
}
?>
<!doctype html>
<html>
<head>
<meta charset="UTF-8" />
<title>phaser</title>
<?php
if (isset($_GET['f']))
{
$f = $_GET['f'];
?>
<script src="../../dist/phaser.js" type="text/javascript"></script>
<script src="<?php echo $f?>" type="text/javascript"></script>
<?php
}
?>
</head>
<body>
<div id="phaser-example"></div>
</body>
</html>

31
examples/wip/index-fs.php Normal file
View file

@ -0,0 +1,31 @@
<!doctype html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="initial-scale=1 maximum-scale=1 user-scalable=0 minimal-ui" />
<title>phaser</title>
<base href="../" />
<?php
require('../../build/config.php');
if (isset($_GET['f']))
{
$f = $_GET['f'];
?>
<script src="wip/<?php echo $f?>" type="text/javascript"></script>
<?php
}
?>
<style>
body {
margin: 0;
padding: 0;
}
</style>
</head>
<body>
<div id="phaser-example"></div>
</body>
</html>

View file

@ -64,7 +64,7 @@
$value2 = substr($value, 0, -3);
$file = urlencode($value);
$output .= "<a href=\"wip/index.php?f=$file\">$value2</a><br />";
$output .= "<tr><td><a href=\"wip/index.php?f=$file\">$value2</a></td><td><a href=\"wip/index-fs.php?f=$file\">(full screen)</a></td><td><a href=\"wip/cocoon.php?f=$file\">(cocoon)</a></td></tr>";
}
return $output;
@ -110,9 +110,11 @@
<h2>work in progress examples</h2>
<table>
<?php
echo printJSLinks('wip', $files);
?>
</table>
</div>

View file

@ -1,76 +1,3 @@
<?php
// Global
$files = dirToArray(dirname(__FILE__));
$total = 0;
foreach ($files as $key => $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 .= "<a href=\"wip/index.php?f=$file\">$value2</a><br />";
}
return $output;
}
?>
<!doctype html>
<html>
<head>
@ -93,8 +20,6 @@
body {
margin: 0;
padding: 0;
font-family: Arial;
font-size: 14px;
}
</style>
</head>
@ -102,18 +27,5 @@
<div id="phaser-example"></div>
<input type="button" id="step" value="step" />
<input type="button" id="start" value="start" style="margin-left: 32px" />
<div style="padding: 32px">
<h2>work in progress examples</h2>
<?php
echo printJSLinks('wip', $files);
?>
</div>
</body>
</html>

View file

@ -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);
}

View file

@ -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;

View file

@ -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;

View file

@ -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();
},