mirror of
https://github.com/wassname/phaser.git
synced 2026-08-20 12:40:12 +08:00
StateManager fixes for when you change state in the create function.
TilemapLayer update for WebGL.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create, update: update, render: render });
|
||||
var game = new Phaser.Game(800, 600, Phaser.WEBGL, 'phaser-example', { preload: preload, create: create, update: update, render: render });
|
||||
|
||||
function preload() {
|
||||
|
||||
|
||||
@@ -41,6 +41,13 @@ function create() {
|
||||
var text2 = game.add.bitmapText(200, 500, 'desyrel', 'camera fixies', 32);
|
||||
text2.fixedToCamera = true;
|
||||
|
||||
// Test fixing a Graphics object to the Camera
|
||||
var graphics = game.add.graphics(0, 0);
|
||||
graphics.fixedToCamera = true;
|
||||
graphics.beginFill(0xFF3300);
|
||||
graphics.lineStyle(2, 0x0000FF, 1);
|
||||
graphics.drawRect(50, 250, 100, 100);
|
||||
|
||||
// Button! do mouse events still work then?
|
||||
|
||||
game.camera.follow(mushroom);
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
<?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" />
|
||||
<meta name="viewport" content="initial-scale=1 maximum-scale=1 user-scalable=0 minimal-ui" />
|
||||
<title>phaser</title>
|
||||
<base href="../" />
|
||||
<script src="_site/js/jquery-2.0.3.min.js" type="text/javascript"></script>
|
||||
<script src="../build/phaser.js" type="text/javascript"></script>
|
||||
<?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;
|
||||
font-family: Arial;
|
||||
font-size: 14px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<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>
|
||||
@@ -0,0 +1,57 @@
|
||||
|
||||
// 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.WEBGL, 'phaser-example', { preload: preload, create: create, update: update, render: render });
|
||||
|
||||
function preload() {
|
||||
|
||||
game.load.image('ship', 'assets/sprites/thrust_ship2.png');
|
||||
|
||||
}
|
||||
|
||||
var ship;
|
||||
var cursors;
|
||||
|
||||
function create() {
|
||||
|
||||
game.stage.backgroundColor = '#2d2d2d';
|
||||
|
||||
ship = game.add.sprite(200, 200, 'ship');
|
||||
ship.physicsEnabled = true;
|
||||
// We do this because our ship is shaped like a triangle, not a square :)
|
||||
ship.body.addPolygon({}, 29, 23 , 0, 23 , 14, 1);
|
||||
|
||||
cursors = game.input.keyboard.createCursorKeys();
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
if (cursors.left.isDown)
|
||||
{
|
||||
ship.body.rotateLeft(100);
|
||||
}
|
||||
else if (cursors.right.isDown)
|
||||
{
|
||||
ship.body.rotateRight(100);
|
||||
}
|
||||
else
|
||||
{
|
||||
ship.body.setZeroRotation();
|
||||
}
|
||||
|
||||
if (cursors.up.isDown)
|
||||
{
|
||||
ship.body.thrust(400);
|
||||
}
|
||||
else if (cursors.down.isDown)
|
||||
{
|
||||
ship.body.reverse(400);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function render() {
|
||||
|
||||
game.debug.renderPhysicsBody(ship.body);
|
||||
|
||||
}
|
||||
@@ -21,6 +21,7 @@ BasicGame.Boot.prototype = {
|
||||
|
||||
create: function () {
|
||||
|
||||
console.log('Boot create');
|
||||
this.game.state.start('Preloader', true, false, this.a, this.b);
|
||||
|
||||
}
|
||||
@@ -48,6 +49,7 @@ BasicGame.Preloader.prototype = {
|
||||
|
||||
create: function () {
|
||||
|
||||
console.log('Preloader create');
|
||||
this.game.state.start('MainMenu', true, false, this.a, this.b);
|
||||
|
||||
}
|
||||
@@ -89,4 +91,4 @@ game.state.add('Boot', BasicGame.Boot);
|
||||
game.state.add('Preloader', BasicGame.Preloader);
|
||||
game.state.add('MainMenu', BasicGame.MainMenu);
|
||||
|
||||
game.state.start('Boot');
|
||||
game.state.start('Boot', true, false, 'hello', 'world');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
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.AUTO, 'phaser-example', { preload: preload, create: create, update: update, render: render });
|
||||
// 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.AUTO, 'phaser-example', { preload: preload, create: create, update: update, render: render });
|
||||
|
||||
function preload() {
|
||||
|
||||
@@ -36,7 +36,7 @@ function create() {
|
||||
|
||||
layer = map.createLayer('Tile Layer 1');
|
||||
|
||||
layer.resizeWorld();
|
||||
// layer.resizeWorld();
|
||||
|
||||
map.setCollisionBetween(1, 12);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user