mirror of
https://github.com/photonstorm/phaser
synced 2024-11-22 20:53:39 +00:00
Updating examples with new runner and menu system.
This commit is contained in:
parent
ad0d32b7aa
commit
70233b7508
155 changed files with 2377 additions and 104 deletions
66
examples/audio/play music.php
Normal file
66
examples/audio/play music.php
Normal file
|
@ -0,0 +1,66 @@
|
|||
<?php
|
||||
$title = "Playing an audio file";
|
||||
require('../head.php');
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
(function () {
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, update: update, render: render });
|
||||
|
||||
function preload() {
|
||||
|
||||
game.load.image('disk', 'assets/sprites/ra_dont_crack_under_pressure.png');
|
||||
|
||||
// Firefox doesn't support mp3 files, so use ogg
|
||||
game.load.audio('boden', ['assets/audio/bodenstaendig_2000_in_rock_4bit.mp3', 'assets/audio/bodenstaendig_2000_in_rock_4bit.ogg']);
|
||||
|
||||
}
|
||||
|
||||
var s;
|
||||
var music;
|
||||
|
||||
function create() {
|
||||
|
||||
game.stage.backgroundColor = '#182d3b';
|
||||
game.input.touch.preventDefault = false;
|
||||
|
||||
music = game.add.audio('boden');
|
||||
music.play();
|
||||
|
||||
s = game.add.sprite(game.world.centerX, game.world.centerY, 'disk');
|
||||
s.anchor.setTo(0.5, 0.5);
|
||||
|
||||
game.input.onDown.add(changeVolume, this);
|
||||
|
||||
}
|
||||
|
||||
function changeVolume(pointer) {
|
||||
|
||||
if (pointer.y < 300)
|
||||
{
|
||||
music.volume += 0.1;
|
||||
}
|
||||
else
|
||||
{
|
||||
music.volume -= 0.1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
s.rotation += 0.01;
|
||||
}
|
||||
|
||||
function render() {
|
||||
game.debug.renderSoundInfo(music, 20, 32);
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
</script>
|
||||
|
||||
<?php
|
||||
require('../foot.php');
|
||||
?>
|
114
examples/collision/group vs group.php
Normal file
114
examples/collision/group vs group.php
Normal file
|
@ -0,0 +1,114 @@
|
|||
<?php
|
||||
$title = "Group vs. Group Collision";
|
||||
require('../head.php');
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
(function () {
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update });
|
||||
|
||||
function preload() {
|
||||
|
||||
game.load.image('phaser', 'assets/sprites/phaser-dude.png');
|
||||
game.load.image('bullet', 'assets/misc/bullet0.png');
|
||||
game.load.spritesheet('veggies', 'assets/sprites/fruitnveg32wh37.png', 32, 32);
|
||||
|
||||
}
|
||||
|
||||
var sprite;
|
||||
var bullets;
|
||||
var veggies;
|
||||
var bulletTime = 0;
|
||||
|
||||
var bullet;
|
||||
|
||||
function create() {
|
||||
|
||||
game.stage.backgroundColor = '#2d2d2d';
|
||||
|
||||
// This will check Group vs. Group collision (bullets vs. veggies!)
|
||||
|
||||
veggies = game.add.group();
|
||||
|
||||
for (var i = 0; i < 50; i++)
|
||||
{
|
||||
var c = veggies.create(game.world.randomX, Math.random() * 500, 'veggies', game.rnd.integerInRange(0, 36));
|
||||
c.name = 'veg' + i;
|
||||
c.body.immovable = true;
|
||||
}
|
||||
|
||||
bullets = game.add.group();
|
||||
|
||||
for (var i = 0; i < 10; i++)
|
||||
{
|
||||
var b = bullets.create(0, 0, 'bullet');
|
||||
b.name = 'bullet' + i;
|
||||
b.exists = false;
|
||||
b.visible = false;
|
||||
b.events.onOutOfBounds.add(resetBullet, this);
|
||||
}
|
||||
|
||||
sprite = game.add.sprite(400, 550, 'phaser');
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
sprite.velocity.x = 0;
|
||||
sprite.velocity.y = 0;
|
||||
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
|
||||
{
|
||||
sprite.velocity.x = -200;
|
||||
}
|
||||
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
|
||||
{
|
||||
sprite.velocity.x = 200;
|
||||
}
|
||||
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.SPACEBAR))
|
||||
{
|
||||
fireBullet();
|
||||
}
|
||||
|
||||
game.physics.collide(bullets, veggies, collisionHandler, null, this);
|
||||
|
||||
}
|
||||
|
||||
function fireBullet () {
|
||||
|
||||
if (game.time.now > bulletTime)
|
||||
{
|
||||
bullet = bullets.getFirstExists(false);
|
||||
|
||||
if (bullet)
|
||||
{
|
||||
bullet.reset(sprite.x + 6, sprite.y - 8);
|
||||
bullet.velocity.y = -300;
|
||||
bulletTime = game.time.now + 250;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Called if the bullet goes out of the screen
|
||||
function resetBullet (bullet) {
|
||||
bullet.kill();
|
||||
}
|
||||
|
||||
function collisionHandler (bullet, veg) {
|
||||
|
||||
bullet.kill();
|
||||
veg.kill();
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
</script>
|
||||
|
||||
<?php
|
||||
require('../foot.php');
|
||||
?>
|
96
examples/collision/sprite vs group.php
Normal file
96
examples/collision/sprite vs group.php
Normal file
|
@ -0,0 +1,96 @@
|
|||
<?php
|
||||
$title = "Group vs. Group Collision";
|
||||
require('../head.php');
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
(function () {
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update });
|
||||
|
||||
function preload() {
|
||||
|
||||
game.load.image('phaser', 'assets/sprites/phaser-dude.png');
|
||||
game.load.spritesheet('veggies', 'assets/sprites/fruitnveg32wh37.png', 32, 32);
|
||||
|
||||
}
|
||||
|
||||
var sprite;
|
||||
var group;
|
||||
|
||||
function create() {
|
||||
|
||||
game.stage.backgroundColor = '#2d2d2d';
|
||||
|
||||
// This will check Sprite vs. Group collision
|
||||
|
||||
sprite = game.add.sprite(32, 200, 'phaser');
|
||||
sprite.name = 'phaser-dude';
|
||||
|
||||
group = game.add.group();
|
||||
|
||||
for (var i = 0; i < 50; i++)
|
||||
{
|
||||
var c = group.create(100 + Math.random() * 700, game.world.randomY, 'veggies', game.rnd.integerInRange(0, 36));
|
||||
c.name = 'veg' + i;
|
||||
c.body.immovable = true;
|
||||
}
|
||||
|
||||
for (var i = 0; i < 20; i++)
|
||||
{
|
||||
// Here we'll create some chillis which the player can pick-up. They are still part of the same Group.
|
||||
var c = group.create(100 + Math.random() * 700, game.world.randomY, 'veggies', 17);
|
||||
c.name = 'chilli' + i;
|
||||
c.body.immovable = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
sprite.velocity.x = 0;
|
||||
sprite.velocity.y = 0;
|
||||
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
|
||||
{
|
||||
sprite.velocity.x = -200;
|
||||
}
|
||||
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
|
||||
{
|
||||
sprite.velocity.x = 200;
|
||||
}
|
||||
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
|
||||
{
|
||||
sprite.velocity.y = -200;
|
||||
}
|
||||
else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
|
||||
{
|
||||
sprite.velocity.y = 200;
|
||||
}
|
||||
|
||||
game.physics.collide(sprite, group, collisionHandler, null, this);
|
||||
|
||||
}
|
||||
|
||||
function collisionHandler (obj1, obj2) {
|
||||
|
||||
// If the player collides with the chillis then they get eaten :)
|
||||
// The chilli frame ID is 17
|
||||
|
||||
console.log('Hit', obj2.name);
|
||||
|
||||
if (obj2.frame == 17)
|
||||
{
|
||||
obj2.kill();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
</script>
|
||||
|
||||
<?php
|
||||
require('../foot.php');
|
||||
?>
|
92
examples/collision/sprite vs sprite custom.php
Normal file
92
examples/collision/sprite vs sprite custom.php
Normal file
|
@ -0,0 +1,92 @@
|
|||
<?php
|
||||
$title = "Group vs. Group Collision";
|
||||
require('../head.php');
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
(function () {
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update, render: render });
|
||||
|
||||
function preload() {
|
||||
|
||||
game.load.image('atari', 'assets/sprites/atari130xe.png');
|
||||
game.load.image('mushroom', 'assets/sprites/mushroom2.png');
|
||||
|
||||
}
|
||||
|
||||
var sprite1;
|
||||
var sprite2;
|
||||
|
||||
function create() {
|
||||
|
||||
game.stage.backgroundColor = '#2d2d2d';
|
||||
|
||||
// This will check Sprite vs. Sprite collision using a custom process callback
|
||||
|
||||
sprite1 = game.add.sprite(0, 200, 'atari');
|
||||
sprite1.name = 'atari';
|
||||
// We'll use a random velocity here so we can test it in our processHandler
|
||||
sprite1.body.velocity.x = 50 + Math.random() * 100;
|
||||
// This tells phaser to not use the built-in body separation, instead you should handle it in your process callback (see below)
|
||||
sprite1.body.customSeparateX = true;
|
||||
|
||||
sprite2 = game.add.sprite(750, 220, 'mushroom');
|
||||
sprite2.name = 'mushroom';
|
||||
// We'll use a random velocity here so we can test it in our processHandler
|
||||
sprite2.body.velocity.x = -(50 + Math.random() * 100);
|
||||
// This tells phaser to not use the built-in body separation, instead you should handle it in your process callback (see below)
|
||||
sprite2.body.customSeparateX = true;
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
game.physics.collide(sprite1, sprite2, collisionHandler, processHandler, this);
|
||||
|
||||
}
|
||||
|
||||
function processHandler (obj1, obj2) {
|
||||
|
||||
// This function can perform your own additional checks on the 2 objects that collided.
|
||||
// For example you could test for velocity, health, etc.
|
||||
// If you want the collision to be deemed successful this function must return true.
|
||||
// In which case the collisionHandler will be called, otherwise it won't.
|
||||
|
||||
// Note: the objects will have already been separated by this point unless you have set
|
||||
// their customSeparateX/Y flags to true. If you do that it's up to you to handle separation.
|
||||
|
||||
// Whichever one is going fastest wins, the other dies :)
|
||||
if (obj1.body.velocity.x > Math.abs(obj2.body.velocity.x))
|
||||
{
|
||||
obj2.kill();
|
||||
obj1.body.velocity.x = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
obj1.kill();
|
||||
obj2.body.velocity.x = 0;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
function collisionHandler (obj1, obj2) {
|
||||
|
||||
game.stage.backgroundColor = '#992d2d';
|
||||
|
||||
console.log(obj1.name + ' collided with ' + obj2.name);
|
||||
|
||||
}
|
||||
|
||||
function render() {
|
||||
}
|
||||
|
||||
})();
|
||||
</script>
|
||||
|
||||
<?php
|
||||
require('../foot.php');
|
||||
?>
|
61
examples/collision/sprite vs sprite.php
Normal file
61
examples/collision/sprite vs sprite.php
Normal file
|
@ -0,0 +1,61 @@
|
|||
<?php
|
||||
$title = "Group vs. Group Collision";
|
||||
require('../head.php');
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
(function () {
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update, render: render });
|
||||
|
||||
function preload() {
|
||||
|
||||
game.load.image('atari', 'assets/sprites/atari130xe.png');
|
||||
game.load.image('mushroom', 'assets/sprites/mushroom2.png');
|
||||
|
||||
}
|
||||
|
||||
var sprite1;
|
||||
var sprite2;
|
||||
|
||||
function create() {
|
||||
|
||||
game.stage.backgroundColor = '#2d2d2d';
|
||||
|
||||
// This will check Sprite vs. Sprite collision
|
||||
|
||||
sprite1 = game.add.sprite(50, 200, 'atari');
|
||||
sprite1.name = 'atari';
|
||||
sprite1.body.velocity.x = 100;
|
||||
|
||||
sprite2 = game.add.sprite(700, 220, 'mushroom');
|
||||
sprite2.name = 'mushroom';
|
||||
sprite2.body.velocity.x = -100;
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
// object1, object2, collideCallback, processCallback, callbackContext
|
||||
game.physics.collide(sprite1, sprite2, collisionHandler, null, this);
|
||||
|
||||
}
|
||||
|
||||
function collisionHandler (obj1, obj2) {
|
||||
|
||||
game.stage.backgroundColor = '#992d2d';
|
||||
|
||||
console.log(obj1.name + ' collided with ' + obj2.name);
|
||||
|
||||
}
|
||||
|
||||
function render() {
|
||||
}
|
||||
|
||||
})();
|
||||
</script>
|
||||
|
||||
<?php
|
||||
require('../foot.php');
|
||||
?>
|
14
examples/foot.php
Normal file
14
examples/foot.php
Normal file
|
@ -0,0 +1,14 @@
|
|||
|
||||
<script>
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
||||
|
||||
ga('create', 'UA-44006568-1', 'phaser.io');
|
||||
ga('send', 'pageview');
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
18
examples/head.php
Normal file
18
examples/head.php
Normal file
|
@ -0,0 +1,18 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>phaser - <?php echo $title?></title>
|
||||
<base href="../">
|
||||
<?php
|
||||
require('js.php');
|
||||
|
||||
if (isset($mobile))
|
||||
{
|
||||
?>
|
||||
<meta name="viewport" content="initial-scale=1 maximum-scale=1 user-scalable=0" />
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</head>
|
||||
<body>
|
79
examples/index.php
Normal file
79
examples/index.php
Normal file
|
@ -0,0 +1,79 @@
|
|||
<?php
|
||||
function dirToArray($dir) {
|
||||
|
||||
$ignore = array('.', '..', 'Tests.csproj', 'Tests.csproj.user', 'bin', 'index.php', 'phaser.css', 'obj', 'assets', 'states', 'Phaser Tests.sublime-project');
|
||||
$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, -4) == '.php')
|
||||
{
|
||||
$result[] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
function printJSLinks($dir, $files) {
|
||||
|
||||
foreach ($files as $key => $value)
|
||||
{
|
||||
$value2 = substr($value, 0, -4);
|
||||
echo "<a href=\"$dir/$value\" class=\"button\">$value2</a>";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$files = dirToArray(dirname(__FILE__));
|
||||
$total = 0;
|
||||
|
||||
foreach ($files as $key => $value)
|
||||
{
|
||||
if (is_array($value) && count($value) > 0)
|
||||
{
|
||||
$total += count($value);
|
||||
}
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE HTML>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>Phaser Examples</title>
|
||||
<link rel="stylesheet" href="phaser.css" type="text/css" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="header">
|
||||
<h1 id="title">Phaser Test Suite</h1>
|
||||
</div>
|
||||
|
||||
<div id="links">
|
||||
|
||||
<?php
|
||||
echo "<h2>Total Tests: $total </h2>";
|
||||
|
||||
foreach ($files as $key => $value)
|
||||
{
|
||||
// If $key is an array, output it as an h2 or something
|
||||
if (is_array($value) && count($value) > 0)
|
||||
{
|
||||
echo "<h2>$key (" . count($value) . " examples)</h2>";
|
||||
printJSLinks($key, $value);
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
50
examples/input/bring to top.php
Normal file
50
examples/input/bring to top.php
Normal file
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
$title = "Test Title";
|
||||
require('../head.php');
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
(function () {
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, render: render });
|
||||
|
||||
function preload() {
|
||||
|
||||
game.load.image('atari1', 'assets/sprites/atari130xe.png');
|
||||
game.load.image('atari2', 'assets/sprites/atari800xl.png');
|
||||
game.load.image('atari4', 'assets/sprites/atari800.png');
|
||||
game.load.image('sonic', 'assets/sprites/sonic_havok_sanity.png');
|
||||
game.load.image('duck', 'assets/sprites/darkwing_crazy.png');
|
||||
game.load.image('firstaid', 'assets/sprites/firstaid.png');
|
||||
game.load.image('diamond', 'assets/sprites/diamond.png');
|
||||
game.load.image('mushroom', 'assets/sprites/mushroom2.png');
|
||||
|
||||
}
|
||||
|
||||
function create() {
|
||||
|
||||
// This returns an array of all the image keys in the cache
|
||||
var images = game.cache.getImageKeys();
|
||||
|
||||
// Now let's create some random sprites and enable them all for drag and 'bring to top'
|
||||
for (var i = 0; i < 20; i++)
|
||||
{
|
||||
var img = game.rnd.pick(images);
|
||||
var tempSprite = game.add.sprite(game.world.randomX, game.world.randomY, img);
|
||||
tempSprite.inputEnabled = true;
|
||||
tempSprite.input.enableDrag(false, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function render() {
|
||||
game.debug.renderInputInfo(32, 32);
|
||||
}
|
||||
|
||||
})();
|
||||
</script>
|
||||
|
||||
<?php
|
||||
require('../foot.php');
|
||||
?>
|
51
examples/input/bring to top2.php
Normal file
51
examples/input/bring to top2.php
Normal file
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
$title = "Test Title";
|
||||
require('../head.php');
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
(function () {
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, render: render });
|
||||
|
||||
function preload() {
|
||||
|
||||
game.load.image('atari1', 'assets/sprites/atari130xe.png');
|
||||
game.load.image('atari2', 'assets/sprites/atari800xl.png');
|
||||
game.load.image('atari4', 'assets/sprites/atari800.png');
|
||||
game.load.image('sonic', 'assets/sprites/sonic_havok_sanity.png');
|
||||
game.load.image('duck', 'assets/sprites/darkwing_crazy.png');
|
||||
game.load.image('firstaid', 'assets/sprites/firstaid.png');
|
||||
game.load.image('diamond', 'assets/sprites/diamond.png');
|
||||
game.load.image('mushroom', 'assets/sprites/mushroom2.png');
|
||||
|
||||
}
|
||||
|
||||
function create() {
|
||||
|
||||
// This returns an array of all the image keys in the cache
|
||||
var images = game.cache.getImageKeys();
|
||||
|
||||
var test = game.add.group();
|
||||
|
||||
// Now let's create some random sprites and enable them all for drag and 'bring to top'
|
||||
for (var i = 0; i < 20; i++)
|
||||
{
|
||||
var tempSprite = test.create(game.world.randomX, game.world.randomY, game.rnd.pick(images));
|
||||
tempSprite.inputEnabled = true;
|
||||
tempSprite.input.enableDrag(false, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function render() {
|
||||
game.debug.renderInputInfo(32, 32);
|
||||
}
|
||||
|
||||
})();
|
||||
</script>
|
||||
|
||||
<?php
|
||||
require('../foot.php');
|
||||
?>
|
39
examples/input/drag.php
Normal file
39
examples/input/drag.php
Normal file
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
$title = "Test Title";
|
||||
require('../head.php');
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
(function () {
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create });
|
||||
|
||||
function preload() {
|
||||
|
||||
game.load.image('grid', 'assets/tests/debug-grid-1920x1920.png');
|
||||
game.load.image('atari', 'assets/sprites/atari800xl.png');
|
||||
|
||||
}
|
||||
|
||||
function create() {
|
||||
|
||||
game.add.sprite(0, 0, 'grid');
|
||||
|
||||
atari1 = game.add.sprite(300, 300, 'atari');
|
||||
|
||||
// Input Enable the sprites
|
||||
atari1.inputEnabled = true;
|
||||
|
||||
// Allow dragging
|
||||
// enableDrag parameters = (lockCenter, bringToTop, pixelPerfect, alphaThreshold, boundsRect, boundsSprite)
|
||||
atari1.input.enableDrag(true);
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
</script>
|
||||
|
||||
<?php
|
||||
require('../foot.php');
|
||||
?>
|
62
examples/input/pixelpick.php
Normal file
62
examples/input/pixelpick.php
Normal file
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
$title = "Test Title";
|
||||
require('../head.php');
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
(function () {
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, update: update, render: render });
|
||||
|
||||
function preload() {
|
||||
|
||||
game.load.image('bunny', 'assets/sprites/bunny.png');
|
||||
|
||||
}
|
||||
|
||||
var b;
|
||||
|
||||
function create() {
|
||||
|
||||
b = game.add.sprite(game.world.centerX, game.world.centerY, 'bunny');
|
||||
b.anchor.setTo(0.5, 0.5);
|
||||
|
||||
// Listen for input events on this sprite
|
||||
b.inputEnabled = true;
|
||||
|
||||
// Check the pixel data of the sprite
|
||||
b.input.pixelPerfect = true;
|
||||
|
||||
// Enable the hand cursor
|
||||
b.input.useHandCursor = true;
|
||||
|
||||
b.events.onInputOver.add(overSprite, this);
|
||||
b.events.onInputOut.add(outSprite, this);
|
||||
|
||||
}
|
||||
|
||||
function overSprite() {
|
||||
console.log('over');
|
||||
}
|
||||
|
||||
function outSprite() {
|
||||
console.log('out');
|
||||
}
|
||||
|
||||
function update() {
|
||||
b.angle += 0.1;
|
||||
}
|
||||
|
||||
function render() {
|
||||
|
||||
game.debug.renderSpriteInputInfo(b, 32, 32);
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
</script>
|
||||
|
||||
<?php
|
||||
require('../foot.php');
|
||||
?>
|
65
examples/input/pixelpick2.php
Normal file
65
examples/input/pixelpick2.php
Normal file
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
$title = "Test Title";
|
||||
require('../head.php');
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
(function () {
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, update: update, render: render });
|
||||
|
||||
function preload() {
|
||||
|
||||
game.load.spritesheet('mummy', 'assets/sprites/metalslug_mummy37x45.png', 37, 45, 18);
|
||||
|
||||
}
|
||||
|
||||
var b;
|
||||
|
||||
function create() {
|
||||
|
||||
b = game.add.sprite(game.world.centerX, game.world.centerY, 'mummy');
|
||||
b.anchor.setTo(0.5, 0.5);
|
||||
b.scale.setTo(6, 6);
|
||||
b.animations.add('walk');
|
||||
b.animations.play('walk', 5, true);
|
||||
|
||||
// Listen for input events on this sprite
|
||||
b.inputEnabled = true;
|
||||
|
||||
// Check the pixel data of the sprite
|
||||
b.input.pixelPerfect = true;
|
||||
|
||||
// Enable the hand cursor
|
||||
b.input.useHandCursor = true;
|
||||
|
||||
b.events.onInputOver.add(overSprite, this);
|
||||
b.events.onInputOut.add(outSprite, this);
|
||||
|
||||
}
|
||||
|
||||
function overSprite() {
|
||||
console.log('over');
|
||||
}
|
||||
|
||||
function outSprite() {
|
||||
console.log('out');
|
||||
}
|
||||
|
||||
function update() {
|
||||
// b.angle += 0.1;
|
||||
}
|
||||
|
||||
function render() {
|
||||
|
||||
game.debug.renderSpriteInputInfo(b, 32, 32);
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
</script>
|
||||
|
||||
<?php
|
||||
require('../foot.php');
|
||||
?>
|
114
examples/input/pixelpick3.php
Normal file
114
examples/input/pixelpick3.php
Normal file
|
@ -0,0 +1,114 @@
|
|||
<?php
|
||||
$title = "Test Title";
|
||||
require('../head.php');
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
(function () {
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, update: update, render: render });
|
||||
|
||||
function preload() {
|
||||
|
||||
game.load.spritesheet('mummy', 'assets/sprites/metalslug_mummy37x45.png', 37, 45, 18);
|
||||
game.load.image('stars', 'assets/misc/starfield.jpg');
|
||||
|
||||
}
|
||||
|
||||
var b;
|
||||
var camSpeed = 8;
|
||||
var s;
|
||||
|
||||
function create() {
|
||||
|
||||
// Make our world big ...
|
||||
game.world.setSize(4000, 2000);
|
||||
|
||||
// Scrolling background
|
||||
s = game.add.tileSprite(0, 0, 800, 600, 'stars');
|
||||
s.scrollFactor.setTo(0, 0);
|
||||
|
||||
b = game.add.sprite(200, 200, 'mummy');
|
||||
b.anchor.setTo(0.5, 0.5);
|
||||
b.scale.setTo(6, 6);
|
||||
b.animations.add('walk');
|
||||
b.animations.play('walk', 5, true);
|
||||
b.body.velocity.setTo(50, 0);
|
||||
|
||||
// Listen for input events on this sprite
|
||||
b.inputEnabled = true;
|
||||
|
||||
// Check the pixel data of the sprite
|
||||
b.input.pixelPerfect = true;
|
||||
|
||||
// Enable the hand cursor
|
||||
b.input.useHandCursor = true;
|
||||
|
||||
b.events.onInputOver.add(overSprite, this);
|
||||
b.events.onInputOut.add(outSprite, this);
|
||||
|
||||
}
|
||||
|
||||
function overSprite() {
|
||||
console.log('over');
|
||||
}
|
||||
|
||||
function outSprite() {
|
||||
console.log('out');
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
|
||||
{
|
||||
game.camera.x -= camSpeed;
|
||||
|
||||
if (!game.camera.atLimit.x)
|
||||
{
|
||||
s.tilePosition.x += camSpeed;
|
||||
}
|
||||
}
|
||||
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
|
||||
{
|
||||
game.camera.x += camSpeed;
|
||||
|
||||
if (!game.camera.atLimit.x)
|
||||
{
|
||||
s.tilePosition.x -= camSpeed;
|
||||
}
|
||||
}
|
||||
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
|
||||
{
|
||||
game.camera.y -= camSpeed;
|
||||
|
||||
if (!game.camera.atLimit.y)
|
||||
{
|
||||
s.tilePosition.y += camSpeed;
|
||||
}
|
||||
}
|
||||
else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
|
||||
{
|
||||
game.camera.y += camSpeed;
|
||||
|
||||
if (!game.camera.atLimit.y)
|
||||
{
|
||||
s.tilePosition.y -= camSpeed;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function render() {
|
||||
|
||||
game.debug.renderSpriteInputInfo(b, 32, 32);
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
</script>
|
||||
|
||||
<?php
|
||||
require('../foot.php');
|
||||
?>
|
50
examples/input/snap.php
Normal file
50
examples/input/snap.php
Normal file
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
$title = "Test Title";
|
||||
require('../head.php');
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
(function () {
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create });
|
||||
|
||||
function preload() {
|
||||
|
||||
game.load.image('grid', 'assets/tests/debug-grid-1920x1920.png');
|
||||
game.load.image('atari1', 'assets/sprites/atari130xe.png');
|
||||
game.load.image('atari2', 'assets/sprites/atari800xl.png');
|
||||
|
||||
}
|
||||
|
||||
function create() {
|
||||
|
||||
game.add.sprite(0, 0, 'grid');
|
||||
|
||||
atari1 = game.add.sprite(128, 128, 'atari1');
|
||||
atari2 = game.add.sprite(256, 256, 'atari2');
|
||||
|
||||
// Input Enable the sprites
|
||||
atari1.inputEnabled = true;
|
||||
atari2.inputEnabled = true;
|
||||
|
||||
// Allow dragging
|
||||
// enableDrag parameters = (lockCenter, bringToTop, pixelPerfect, alphaThreshold, boundsRect, boundsSprite)
|
||||
atari1.input.enableDrag();
|
||||
atari2.input.enableDrag();
|
||||
|
||||
// Enable snapping. For the atari1 sprite it will snap as its dragged around and on release.
|
||||
// The snap is set to every 32x32 pixels.
|
||||
atari1.input.enableSnap(32, 32, true, true);
|
||||
|
||||
// For the atari2 sprite it will snap only when released, not on drag.
|
||||
atari2.input.enableSnap(32, 32, false, true);
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
</script>
|
||||
|
||||
<?php
|
||||
require('../foot.php');
|
||||
?>
|
|
@ -2,95 +2,6 @@
|
|||
// All JS files in build order.
|
||||
// Much easier for debugging
|
||||
?>
|
||||
<script src="../src/pixi/Pixi.js"></script>
|
||||
|
||||
<script src="../src/Phaser.js"></script>
|
||||
<script src="../src/utils/Utils.js"></script>
|
||||
|
||||
<script src="../src/pixi/core/Matrix.js"></script>
|
||||
<script src="../src/pixi/core/Point.js"></script>
|
||||
<script src="../src/pixi/core/Rectangle.js"></script>
|
||||
<script src="../src/pixi/display/DisplayObject.js"></script>
|
||||
<script src="../src/pixi/display/DisplayObjectContainer.js"></script>
|
||||
<script src="../src/pixi/display/Sprite.js"></script>
|
||||
<script src="../src/pixi/display/MovieClip.js"></script>
|
||||
<script src="../src/pixi/display/Stage.js"></script>
|
||||
<script src="../src/pixi/extras/CustomRenderable.js"></script>
|
||||
<script src="../src/pixi/extras/Strip.js"></script>
|
||||
<script src="../src/pixi/extras/Rope.js"></script>
|
||||
<script src="../src/pixi/extras/Spine.js"></script>
|
||||
<script src="../src/pixi/extras/TilingSprite.js"></script>
|
||||
<script src="../src/pixi/filters/FilterBlock.js"></script>
|
||||
<script src="../src/pixi/filters/MaskFilter.js"></script>
|
||||
<script src="../src/pixi/primitives/Graphics.js"></script>
|
||||
<script src="../src/pixi/renderers/canvas/CanvasGraphics.js"></script>
|
||||
<script src="../src/pixi/renderers/canvas/CanvasRenderer.js"></script>
|
||||
<script src="../src/pixi/renderers/webgl/WebGLBatch.js"></script>
|
||||
<script src="../src/pixi/renderers/webgl/WebGLGraphics.js"></script>
|
||||
<script src="../src/pixi/renderers/webgl/WebGLRenderer.js"></script>
|
||||
<script src="../src/pixi/renderers/webgl/WebGLRenderGroup.js"></script>
|
||||
<script src="../src/pixi/renderers/webgl/WebGLShaders.js"></script>
|
||||
<script src="../src/pixi/text/BitmapText.js"></script>
|
||||
<script src="../src/pixi/text/Text.js"></script>
|
||||
<script src="../src/pixi/textures/BaseTexture.js"></script>
|
||||
<script src="../src/pixi/textures/Texture.js"></script>
|
||||
<script src="../src/pixi/textures/RenderTexture.js"></script>
|
||||
<script src="../src/pixi/utils/EventTarget.js"></script>
|
||||
<script src="../src/pixi/utils/Polyk.js"></script>
|
||||
|
||||
<script src="../src/core/Camera.js"></script>
|
||||
<script src="../src/core/State.js"></script>
|
||||
<script src="../src/core/StateManager.js"></script>
|
||||
<script src="../src/core/LinkedList.js"></script>
|
||||
<script src="../src/core/Signal.js"></script>
|
||||
<script src="../src/core/SignalBinding.js"></script>
|
||||
<script src="../src/core/Plugin.js"></script>
|
||||
<script src="../src/core/PluginManager.js"></script>
|
||||
<script src="../src/core/Stage.js"></script>
|
||||
<script src="../src/core/Group.js"></script>
|
||||
<script src="../src/core/World.js"></script>
|
||||
<script src="../src/core/Game.js"></script>
|
||||
<script src="../src/input/Input.js"></script>
|
||||
<script src="../src/input/Keyboard.js"></script>
|
||||
<script src="../src/input/Mouse.js"></script>
|
||||
<script src="../src/input/MSPointer.js"></script>
|
||||
<script src="../src/input/Pointer.js"></script>
|
||||
<script src="../src/input/Touch.js"></script>
|
||||
<script src="../src/input/InputHandler.js"></script>
|
||||
<script src="../src/system/Canvas.js"></script>
|
||||
<script src="../src/gameobjects/Events.js"></script>
|
||||
<script src="../src/gameobjects/GameObjectFactory.js"></script>
|
||||
<script src="../src/gameobjects/Sprite.js"></script>
|
||||
<script src="../src/gameobjects/TileSprite.js"></script>
|
||||
<script src="../src/gameobjects/Text.js"></script>
|
||||
<script src="../src/system/Canvas.js"></script>
|
||||
<script src="../src/system/Device.js"></script>
|
||||
<script src="../src/system/RequestAnimationFrame.js"></script>
|
||||
<script src="../src/math/RandomDataGenerator.js"></script>
|
||||
<script src="../src/math/Math.js"></script>
|
||||
<script src="../src/math/QuadTree.js"></script>
|
||||
<script src="../src/geom/Circle.js"></script>
|
||||
<script src="../src/geom/Point.js"></script>
|
||||
<script src="../src/geom/Rectangle.js"></script>
|
||||
<script src="../src/net/Net.js"></script>
|
||||
<script src="../src/tween/TweenManager.js"></script>
|
||||
<script src="../src/tween/Tween.js"></script>
|
||||
<script src="../src/tween/Easing.js"></script>
|
||||
<script src="../src/time/Time.js"></script>
|
||||
<script src="../src/animation/AnimationManager.js"></script>
|
||||
<script src="../src/animation/Animation.js"></script>
|
||||
<script src="../src/animation/Frame.js"></script>
|
||||
<script src="../src/animation/FrameData.js"></script>
|
||||
<script src="../src/animation/Parser.js"></script>
|
||||
<script src="../src/loader/Cache.js"></script>
|
||||
<script src="../src/loader/Loader.js"></script>
|
||||
<script src="../src/sound/Sound.js"></script>
|
||||
<script src="../src/sound/SoundManager.js"></script>
|
||||
<script src="../src/utils/Debug.js"></script>
|
||||
|
||||
<script src="../src/physics/arcade/ArcadePhysics.js"></script>
|
||||
<script src="../src/physics/arcade/Body.js"></script>
|
||||
|
||||
<script src="../src/physics/advanced/Math.js"></script>
|
||||
<script src="../src/physics/advanced/Util.js"></script>
|
||||
<script src="../src/physics/advanced/Collision.js"></script>
|
||||
|
@ -113,4 +24,3 @@
|
|||
<script src="../src/physics/advanced/shapes/Poly.js"></script>
|
||||
<script src="../src/physics/advanced/shapes/Triangle.js"></script>
|
||||
<script src="../src/physics/advanced/shapes/Box.js"></script>
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
// All JS files in build order. Much easier for debugging
|
||||
// <xscript src="../src/pixi/extras/Spine.js"></script> <xscript src="../src/pixi/display/MovieClip.js"></script>
|
||||
// All JS files in build order.
|
||||
// Much easier for debugging re: line numbers
|
||||
?>
|
||||
<script src="../src/Intro.js"></script>
|
||||
<script src="../src/pixi/Pixi.js"></script>
|
||||
|
|
22
examples/phaser-mobile.css
Normal file
22
examples/phaser-mobile.css
Normal file
|
@ -0,0 +1,22 @@
|
|||
body
|
||||
{
|
||||
background: #000000;
|
||||
color: white;
|
||||
font: 1em/2em Arial, Helvetica;
|
||||
-webkit-touch-callout: none;
|
||||
-webkit-user-select: none;
|
||||
-khtml-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
* {
|
||||
user-select: none;
|
||||
-webkit-tap-highlight-color: rgb(0, 0, 0, 0);
|
||||
-webkit-touch-callout: none;
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
}
|
209
examples/phaser.css
Normal file
209
examples/phaser.css
Normal file
|
@ -0,0 +1,209 @@
|
|||
body
|
||||
{
|
||||
background: url(assets/suite/background.png);
|
||||
color: white;
|
||||
font: 1em/2em Arial, Helvetica;
|
||||
-webkit-touch-callout: none;
|
||||
-webkit-user-select: none;
|
||||
-khtml-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
* {
|
||||
user-select: none;
|
||||
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
|
||||
-webkit-touch-callout: none;
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
}
|
||||
|
||||
#links {
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
:-webkit-full-screen {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-family: 'Arial', sans-serif;
|
||||
font-size: 30pt;
|
||||
margin: 0;
|
||||
padding: 16px;
|
||||
text-shadow: 0px 4px 3px rgba(0,0,0,0.4), 0px 8px 13px rgba(0,0,0,0.1), 0px 18px 23px rgba(0,0,0,0.1);
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-family: 'Arial', sans-serif;
|
||||
font-size: 20pt;
|
||||
margin: 16px 0px 16px 0px;
|
||||
text-shadow: 0px 4px 3px rgba(0,0,0,0.4), 0px 8px 13px rgba(0,0,0,0.1), 0px 18px 23px rgba(0,0,0,0.1);
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-family: 'Arial', sans-serif;
|
||||
font-size: 30px;
|
||||
margin: 16px 0px 16px 16px;
|
||||
text-shadow: 0px 4px 3px rgba(0,0,0,0.4), 0px 8px 13px rgba(0,0,0,0.1), 0px 18px 23px rgba(0,0,0,0.1);
|
||||
}
|
||||
|
||||
a {
|
||||
color: yellow;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a:Hover {
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.button
|
||||
{
|
||||
display: inline-block;
|
||||
white-space: nowrap;
|
||||
background-color: #ccc;
|
||||
border: 1px solid #777;
|
||||
padding: 0 1.5em;
|
||||
margin: 0.5em;
|
||||
font: bold 1em/2em Arial, Helvetica;
|
||||
text-decoration: none;
|
||||
color: #333;
|
||||
text-shadow: 0 1px 0 rgba(255, 255, 255, .8);
|
||||
-moz-border-radius: .2em;
|
||||
-webkit-border-radius: .2em;
|
||||
border-radius: .2em;
|
||||
-moz-box-shadow: 0 0 1px 1px rgba(255, 255, 255, .8) inset, 0 1px 0 rgba(0, 0, 0, .3);
|
||||
-webkit-box-shadow: 0 0 1px 1px rgba(255, 255, 255, .8) inset, 0 1px 0 rgba(0, 0, 0, .3);
|
||||
box-shadow: 0 0 1px 1px rgba(255, 255, 255, .8) inset, 0 1px 0 rgba(0, 0, 0, .3);
|
||||
background-image: linear-gradient(top, #eee, #ccc);
|
||||
}
|
||||
|
||||
.button:hover
|
||||
{
|
||||
background-color: #ddd;
|
||||
background-image: linear-gradient(top, #fafafa, #ddd);
|
||||
}
|
||||
|
||||
.button:active
|
||||
{
|
||||
-moz-box-shadow: 0 0 4px 2px rgba(0,0,0,.3) inset;
|
||||
-webkit-box-shadow: 0 0 4px 2px rgba(0,0,0,.3) inset;
|
||||
box-shadow: 0 0 4px 2px rgba(0,0,0,.3) inset;
|
||||
position: relative;
|
||||
top: 1px;
|
||||
}
|
||||
|
||||
.button:focus
|
||||
{
|
||||
outline: 0;
|
||||
background: #fafafa;
|
||||
}
|
||||
|
||||
.button:before
|
||||
{
|
||||
background: #ccc;
|
||||
background: rgba(0,0,0,.1);
|
||||
float: left;
|
||||
width: 1em;
|
||||
text-align: center;
|
||||
font-size: 1.5em;
|
||||
margin: 0 1em 0 -1em;
|
||||
padding: 0 .2em;
|
||||
-moz-box-shadow: 1px 0 0 rgba(0,0,0,.5), 2px 0 0 rgba(255,255,255,.5);
|
||||
-webkit-box-shadow: 1px 0 0 rgba(0,0,0,.5), 2px 0 0 rgba(255,255,255,.5);
|
||||
box-shadow: 1px 0 0 rgba(0,0,0,.5), 2px 0 0 rgba(255,255,255,.5);
|
||||
-moz-border-radius: .15em 0 0 .15em;
|
||||
-webkit-border-radius: .15em 0 0 .15em;
|
||||
border-radius: .15em 0 0 .15em;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
/* Hexadecimal entities for the icons */
|
||||
|
||||
.add:before
|
||||
{
|
||||
content: "\271A";
|
||||
}
|
||||
|
||||
.edit:before
|
||||
{
|
||||
content: "\270E";
|
||||
}
|
||||
|
||||
.delete:before
|
||||
{
|
||||
content: "\2718";
|
||||
}
|
||||
|
||||
.save:before
|
||||
{
|
||||
content: "\2714";
|
||||
}
|
||||
|
||||
.email:before
|
||||
{
|
||||
content: "\2709";
|
||||
}
|
||||
|
||||
.like:before
|
||||
{
|
||||
content: "\2764";
|
||||
}
|
||||
|
||||
.next:before
|
||||
{
|
||||
content: "\279C";
|
||||
}
|
||||
|
||||
.star:before
|
||||
{
|
||||
content: "\2605";
|
||||
}
|
||||
|
||||
.spark:before
|
||||
{
|
||||
content: "\2737";
|
||||
}
|
||||
|
||||
.play:before
|
||||
{
|
||||
content: "\25B6";
|
||||
}
|
||||
|
||||
/* Buttons and inputs */
|
||||
button.button, input.button
|
||||
{
|
||||
cursor: pointer;
|
||||
overflow: visible; /* removes extra side spacing in IE */
|
||||
}
|
||||
|
||||
/* removes extra inner spacing in Firefox */
|
||||
button::-moz-focus-inner
|
||||
{
|
||||
border: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
/* If line-height can't be modified, then fix Firefox spacing with padding */
|
||||
input::-moz-focus-inner
|
||||
{
|
||||
padding: .4em;
|
||||
}
|
||||
|
||||
/* The disabled styles */
|
||||
.button[disabled], .button[disabled]:hover, .button.disabled, .button.disabled:hover
|
||||
{
|
||||
background: #eee;
|
||||
color: #aaa;
|
||||
border-color: #aaa;
|
||||
cursor: default;
|
||||
text-shadow: none;
|
||||
position: static;
|
||||
-moz-box-shadow: none;
|
||||
-webkit-box-shadow: none;
|
||||
box-shadow: none;
|
||||
}
|
106
examples/quadtree/quadtree.php
Normal file
106
examples/quadtree/quadtree.php
Normal file
|
@ -0,0 +1,106 @@
|
|||
<?php
|
||||
$title = "Quad Tree";
|
||||
require('../head.php');
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
(function () {
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, update: update, render: render });
|
||||
|
||||
function preload() {
|
||||
game.load.image('ship', 'assets/sprites/xenon2_ship.png');
|
||||
game.load.image('baddie', 'assets/sprites/space-baddie.png');
|
||||
}
|
||||
|
||||
var ship;
|
||||
var total;
|
||||
var aliens;
|
||||
|
||||
function create() {
|
||||
|
||||
game.world.setSize(2000, 2000);
|
||||
|
||||
aliens = [];
|
||||
|
||||
for (var i = 0; i < 1000; i++)
|
||||
{
|
||||
var s = game.add.sprite(game.world.randomX, game.world.randomY, 'baddie');
|
||||
s.name = 'alien' + s;
|
||||
s.body.collideWorldBounds = true;
|
||||
s.body.bounce.setTo(1, 1);
|
||||
s.body.velocity.setTo(10 + Math.random() * 10, 10 + Math.random() * 10);
|
||||
aliens.push(s);
|
||||
}
|
||||
|
||||
ship = game.add.sprite(400, 400, 'ship');
|
||||
ship.body.collideWorldBounds = true;
|
||||
ship.body.bounce.setTo(0.5, 0.5);
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
for (var i = 0; i < aliens.length; i++)
|
||||
{
|
||||
aliens[i].alpha = 0.3;
|
||||
}
|
||||
|
||||
total = game.physics.quadTree.retrieve(ship);
|
||||
|
||||
// Get the ships top-most ID. If the length of that ID is 1 then we can ignore every other result,
|
||||
// it's simply not colliding with anything :)
|
||||
|
||||
for (var i = 0; i < total.length; i++)
|
||||
{
|
||||
total[i].sprite.alpha = 1;
|
||||
}
|
||||
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
|
||||
{
|
||||
ship.body.velocity.x -= 2;
|
||||
}
|
||||
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
|
||||
{
|
||||
ship.body.velocity.x += 2;
|
||||
}
|
||||
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
|
||||
{
|
||||
ship.body.velocity.y -= 2;
|
||||
}
|
||||
else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
|
||||
{
|
||||
ship.body.velocity.y += 2;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function render() {
|
||||
|
||||
for (var i = 0; i < aliens.length; i++)
|
||||
{
|
||||
// game.debug.renderRectangle(aliens[i].bounds);
|
||||
}
|
||||
|
||||
game.debug.renderText(total.length, 32, 32);
|
||||
game.debug.renderQuadTree(game.physics.quadTree);
|
||||
// game.debug.renderRectangle(ship);
|
||||
|
||||
game.debug.renderText('Index: ' + ship.body.quadTreeIndex, 32, 80);
|
||||
|
||||
for (var i = 0; i < ship.body.quadTreeIDs.length; i++)
|
||||
{
|
||||
game.debug.renderText('ID: ' + ship.body.quadTreeIDs[i], 32, 100 + (i * 20));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
</script>
|
||||
|
||||
<?php
|
||||
require('../foot.php');
|
||||
?>
|
83
examples/quadtree/quadtree2.php
Normal file
83
examples/quadtree/quadtree2.php
Normal file
|
@ -0,0 +1,83 @@
|
|||
<?php
|
||||
$title = "Quad Tree";
|
||||
require('../head.php');
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
(function () {
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, update: update, render: render });
|
||||
|
||||
function preload() {
|
||||
game.load.image('ship', 'assets/sprites/xenon2_ship.png');
|
||||
game.load.image('baddie', 'assets/sprites/space-baddie.png');
|
||||
}
|
||||
|
||||
var ship;
|
||||
var aliens;
|
||||
|
||||
function create() {
|
||||
|
||||
aliens = game.add.group();
|
||||
|
||||
for (var i = 0; i < 50; i++)
|
||||
{
|
||||
var s = aliens.create(game.world.randomX, game.world.randomY, 'baddie')
|
||||
s.name = 'alien' + s;
|
||||
s.body.collideWorldBounds = true;
|
||||
s.body.bounce.setTo(1, 1);
|
||||
s.body.velocity.setTo(10 + Math.random() * 40, 10 + Math.random() * 40);
|
||||
}
|
||||
|
||||
ship = game.add.sprite(400, 400, 'ship');
|
||||
ship.body.collideWorldBounds = true;
|
||||
ship.body.bounce.setTo(1, 1);
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
|
||||
{
|
||||
ship.body.velocity.x -= 2;
|
||||
}
|
||||
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
|
||||
{
|
||||
ship.body.velocity.x += 2;
|
||||
}
|
||||
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
|
||||
{
|
||||
ship.body.velocity.y -= 2;
|
||||
}
|
||||
else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
|
||||
{
|
||||
ship.body.velocity.y += 2;
|
||||
}
|
||||
|
||||
game.physics.collide(ship, aliens);
|
||||
|
||||
}
|
||||
|
||||
function render() {
|
||||
|
||||
game.debug.renderQuadTree(game.physics.quadTree);
|
||||
game.debug.renderRectangle(ship.body);
|
||||
|
||||
// game.debug.renderText('total: ' + total.length, 32, 50);
|
||||
|
||||
game.debug.renderText('up: ' + ship.body.touching.up, 32, 70);
|
||||
game.debug.renderText('down: ' + ship.body.touching.down, 32, 90);
|
||||
game.debug.renderText('left: ' + ship.body.touching.left, 32, 110);
|
||||
game.debug.renderText('right: ' + ship.body.touching.right, 32, 130);
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
</script>
|
||||
|
||||
<?php
|
||||
require('../foot.php');
|
||||
?>
|
31
examples/sprites/sprite1.php
Normal file
31
examples/sprites/sprite1.php
Normal file
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
$title = "Display a Sprite";
|
||||
require('../head.php');
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
(function () {
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update });
|
||||
|
||||
function preload() {
|
||||
game.load.image('mushroom', 'assets/sprites/mushroom2.png');
|
||||
}
|
||||
|
||||
function create() {
|
||||
|
||||
var test = game.add.sprite(200, 200, 'mushroom');
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
</script>
|
||||
|
||||
<?php
|
||||
require('../foot.php');
|
||||
?>
|
51
examples/sprites/sprite2.php
Normal file
51
examples/sprites/sprite2.php
Normal file
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
$title = "Sprite Sheet";
|
||||
require('../head.php');
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
(function () {
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update });
|
||||
|
||||
var bunny;
|
||||
|
||||
function preload() {
|
||||
// 37x45 is the size of each frame
|
||||
// There are 18 frames in the PNG - you can leave this value blank if the frames fill up the entire PNG, but in this case there are some
|
||||
// blank frames at the end, so we tell the loader how many to load
|
||||
game.load.spritesheet('ms', 'assets/sprites/metalslug_mummy37x45.png', 37, 45, 18);
|
||||
}
|
||||
|
||||
function create() {
|
||||
|
||||
bunny = game.add.sprite(40, 100, 'ms');
|
||||
|
||||
bunny.animations.add('walk');
|
||||
|
||||
bunny.animations.play('walk', 50, true);
|
||||
|
||||
game.add.tween(bunny).to({ x: game.width }, 10000, Phaser.Easing.Linear.None, true);
|
||||
|
||||
}
|
||||
|
||||
// update isn't called until 'create' has completed. If you need to process stuff before that point (i.e. while the preload is still happening)
|
||||
// then create a function called loadUpdate() and use that
|
||||
function update() {
|
||||
|
||||
if (bunny.x >= 300)
|
||||
{
|
||||
bunny.scale.x += 0.01;
|
||||
bunny.scale.y += 0.01;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
</script>
|
||||
|
||||
<?php
|
||||
require('../foot.php');
|
||||
?>
|
61
examples/sprites/sprite3.php
Normal file
61
examples/sprites/sprite3.php
Normal file
|
@ -0,0 +1,61 @@
|
|||
<?php
|
||||
$title = "Sprite Sheet and Scale";
|
||||
require('../head.php');
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
(function () {
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update }, false, false);
|
||||
|
||||
var timer = 0;
|
||||
var total = 0;
|
||||
|
||||
function preload() {
|
||||
// 37x45 is the size of each frame
|
||||
// There are 18 frames in the PNG - you can leave this value blank if the frames fill up the entire PNG, but in this case there are some
|
||||
// blank frames at the end, so we tell the loader how many to load
|
||||
game.load.spritesheet('mummy', 'assets/sprites/metalslug_mummy37x45.png', 37, 45, 18);
|
||||
}
|
||||
|
||||
function create() {
|
||||
|
||||
releaseMummy();
|
||||
|
||||
}
|
||||
|
||||
function releaseMummy() {
|
||||
|
||||
var mummy = game.add.sprite(-(Math.random() * 800), game.world.randomY, 'mummy');
|
||||
|
||||
mummy.scale.setTo(2, 2);
|
||||
// If you prefer to work in degrees rather than radians then you can use Phaser.Sprite.angle
|
||||
// otherwise use Phaser.Sprite.rotation
|
||||
mummy.angle = game.rnd.angle();
|
||||
mummy.animations.add('walk');
|
||||
mummy.animations.play('walk', 50, true);
|
||||
|
||||
game.add.tween(mummy).to({ x: game.width + (1600 + mummy.x) }, 20000, Phaser.Easing.Linear.None, true);
|
||||
|
||||
total++;
|
||||
timer = game.time.now + 100;
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
if (total < 200 && game.time.now > timer)
|
||||
{
|
||||
releaseMummy();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
</script>
|
||||
|
||||
<?php
|
||||
require('../foot.php');
|
||||
?>
|
66
examples/sprites/sprite4.php
Normal file
66
examples/sprites/sprite4.php
Normal file
|
@ -0,0 +1,66 @@
|
|||
<?php
|
||||
$title = "Sprite Animation";
|
||||
require('../head.php');
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
(function () {
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, update: update, render: render });
|
||||
|
||||
function preload() {
|
||||
game.load.atlasJSONHash('bot', 'assets/sprites/running_bot.png', 'assets/sprites/running_bot.json');
|
||||
}
|
||||
|
||||
var s;
|
||||
|
||||
function create() {
|
||||
|
||||
// game.world._stage.backgroundColorString = '#182d3b';
|
||||
|
||||
s = game.add.sprite(game.world.centerX, game.world.centerY, 'bot');
|
||||
// s.anchor.setTo(0.5, 0.5);
|
||||
s.scale.setTo(2, 2);
|
||||
|
||||
s.animations.add('run');
|
||||
s.animations.play('run', 10, true);
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
|
||||
{
|
||||
s.x -= 4;
|
||||
}
|
||||
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
|
||||
{
|
||||
s.x += 4;
|
||||
}
|
||||
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
|
||||
{
|
||||
s.y -= 4;
|
||||
}
|
||||
else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
|
||||
{
|
||||
s.y += 4;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function render() {
|
||||
|
||||
game.debug.renderSpriteCorners(s, false, false);
|
||||
game.debug.renderSpriteInfo(s, 20, 32);
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
</script>
|
||||
|
||||
<?php
|
||||
require('../foot.php');
|
||||
?>
|
52
examples/sprites/sprite_extend.php
Normal file
52
examples/sprites/sprite_extend.php
Normal file
|
@ -0,0 +1,52 @@
|
|||
<?php
|
||||
$title = "Custom Sprite";
|
||||
require('../head.php');
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
// Here is a custom game object
|
||||
MonsterBunny = function (game, x, y) {
|
||||
|
||||
Phaser.Sprite.call(this, game, x, y, 'bunny');
|
||||
|
||||
};
|
||||
|
||||
MonsterBunny.prototype = Phaser.Utils.extend(true, Phaser.Sprite.prototype, PIXI.Sprite.prototype);
|
||||
MonsterBunny.prototype.constructor = MonsterBunny;
|
||||
|
||||
/**
|
||||
* Automatically called by World.update
|
||||
*/
|
||||
MonsterBunny.prototype.update = function() {
|
||||
|
||||
this.angle++;
|
||||
|
||||
};
|
||||
|
||||
(function () {
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create });
|
||||
|
||||
function preload() {
|
||||
|
||||
game.load.image('bunny', 'assets/sprites/bunny.png');
|
||||
|
||||
}
|
||||
|
||||
function create() {
|
||||
|
||||
var wabbit = new MonsterBunny(game, 400, 300);
|
||||
wabbit.lifespan = 3000;
|
||||
wabbit.anchor.setTo(0.5, 0.5);
|
||||
|
||||
game.add.existing(wabbit);
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
</script>
|
||||
|
||||
<?php
|
||||
require('../foot.php');
|
||||
?>
|
36
examples/template.php
Normal file
36
examples/template.php
Normal file
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
$title = "Test Title";
|
||||
require('../head.php');
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
(function () {
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update, render: render });
|
||||
|
||||
function preload() {
|
||||
|
||||
// game.load.image('disk', 'assets/sprites/ra_dont_crack_under_pressure.png');
|
||||
|
||||
}
|
||||
|
||||
function create() {
|
||||
|
||||
// game.add.sprite(0, 0, 'disk');
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
}
|
||||
|
||||
function render() {
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
</script>
|
||||
|
||||
<?php
|
||||
require('../foot.php');
|
||||
?>
|
42
examples/texture crop/crop.php
Normal file
42
examples/texture crop/crop.php
Normal file
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
$title = "Texture Crop";
|
||||
require('../head.php');
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
(function () {
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update });
|
||||
|
||||
function preload() {
|
||||
game.load.image('trsi', 'assets/pics/trsipic1_lazur.jpg');
|
||||
}
|
||||
|
||||
var r;
|
||||
var pic;
|
||||
|
||||
function create() {
|
||||
|
||||
pic = game.add.sprite(game.world.centerX, 550, 'trsi');
|
||||
pic.anchor.setTo(0.5, 1);
|
||||
|
||||
r = new Phaser.Rectangle(0, 0, pic.width, 0);
|
||||
|
||||
game.add.tween(r).to( { height: pic.height }, 3000, Phaser.Easing.Bounce.Out, true, 0, 1000, true);
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
// Apply the new crop Rectangle to the sprite
|
||||
pic.crop = r;
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
</script>
|
||||
|
||||
<?php
|
||||
require('../foot.php');
|
||||
?>
|
42
examples/texture crop/crop2.php
Normal file
42
examples/texture crop/crop2.php
Normal file
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
$title = "Texture Crop";
|
||||
require('../head.php');
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
(function () {
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update });
|
||||
|
||||
function preload() {
|
||||
game.load.image('trsi', 'assets/pics/trsipic1_lazur.jpg');
|
||||
}
|
||||
|
||||
var r;
|
||||
var pic;
|
||||
|
||||
function create() {
|
||||
|
||||
pic = game.add.sprite(game.world.centerX, 550, 'trsi');
|
||||
pic.anchor.setTo(0.5, 1);
|
||||
|
||||
r = new Phaser.Rectangle(0, 0, 200, pic.height);
|
||||
|
||||
game.add.tween(r).to( { x: pic.width - 200 }, 3000, Phaser.Easing.Bounce.Out, true, 0, 1000, true);
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
// Apply the new crop Rectangle to the sprite
|
||||
pic.crop = r;
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
</script>
|
||||
|
||||
<?php
|
||||
require('../foot.php');
|
||||
?>
|
44
examples/texture crop/crop3.php
Normal file
44
examples/texture crop/crop3.php
Normal file
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
$title = "Texture Crop";
|
||||
require('../head.php');
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
(function () {
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update });
|
||||
|
||||
function preload() {
|
||||
game.load.image('trsi', 'assets/pics/trsipic1_lazur.jpg');
|
||||
}
|
||||
|
||||
var r;
|
||||
var pic;
|
||||
|
||||
function create() {
|
||||
|
||||
pic = game.add.sprite(0, 0, 'trsi');
|
||||
|
||||
r = new Phaser.Rectangle(0, 0, 200, 200);
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
r.x = game.input.x;
|
||||
r.y = game.input.y;
|
||||
pic.x = game.input.x;
|
||||
pic.y = game.input.y;
|
||||
|
||||
// Apply the new crop Rectangle to the sprite
|
||||
pic.crop = r;
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
</script>
|
||||
|
||||
<?php
|
||||
require('../foot.php');
|
||||
?>
|
59
examples/tile sprites/tilesprite1.php
Normal file
59
examples/tile sprites/tilesprite1.php
Normal file
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
$title = "Tiling Sprites";
|
||||
require('../head.php');
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
(function () {
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update });
|
||||
|
||||
function preload() {
|
||||
game.load.image('disk', 'assets/sprites/p2.jpeg');
|
||||
}
|
||||
|
||||
var s;
|
||||
var count = 0;
|
||||
|
||||
function create() {
|
||||
s = game.add.tileSprite(0, 0, 512, 512, 'disk');
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
count += 0.005
|
||||
|
||||
s.tileScale.x = 2 + Math.sin(count);
|
||||
s.tileScale.y = 2 + Math.cos(count);
|
||||
|
||||
s.tilePosition.x += 1;
|
||||
s.tilePosition.y += 1;
|
||||
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
|
||||
{
|
||||
s.x -= 4;
|
||||
}
|
||||
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
|
||||
{
|
||||
s.x += 4;
|
||||
}
|
||||
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
|
||||
{
|
||||
s.y -= 4;
|
||||
}
|
||||
else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
|
||||
{
|
||||
s.y += 4;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
</script>
|
||||
|
||||
<?php
|
||||
require('../foot.php');
|
||||
?>
|
50
examples/tile sprites/tilesprite2.php
Normal file
50
examples/tile sprites/tilesprite2.php
Normal file
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
$title = "Tiling Sprites";
|
||||
require('../head.php');
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
(function () {
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update });
|
||||
|
||||
var s;
|
||||
|
||||
function preload() {
|
||||
game.load.image('disk', 'assets/misc/starfield.jpg');
|
||||
}
|
||||
|
||||
function create() {
|
||||
s = game.add.tileSprite(0, 0, 800, 600, 'disk');
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
|
||||
{
|
||||
s.tilePosition.x += 8;
|
||||
}
|
||||
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
|
||||
{
|
||||
s.tilePosition.x -= 8;
|
||||
}
|
||||
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
|
||||
{
|
||||
s.tilePosition.y += 8;
|
||||
}
|
||||
else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
|
||||
{
|
||||
s.tilePosition.y -= 8;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
</script>
|
||||
|
||||
<?php
|
||||
require('../foot.php');
|
||||
?>
|
81
examples/tilemaps/mapcollide.php
Normal file
81
examples/tilemaps/mapcollide.php
Normal file
|
@ -0,0 +1,81 @@
|
|||
<?php
|
||||
$title = "Test Title";
|
||||
require('../head.php');
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
(function () {
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, update: update, render: render });
|
||||
|
||||
function preload() {
|
||||
|
||||
game.load.tilemap('mario', 'assets/maps/mario1.png', 'assets/maps/mario1.json', null, Phaser.Tilemap.JSON);
|
||||
game.load.image('player', 'assets/sprites/phaser-dude.png');
|
||||
|
||||
}
|
||||
|
||||
var map;
|
||||
var p;
|
||||
|
||||
function create() {
|
||||
|
||||
game.stage.backgroundColor = '#787878';
|
||||
|
||||
map = game.add.tilemap(0, 0, 'mario');
|
||||
|
||||
// floor
|
||||
map.setCollisionRange(80, 97, true, true, true, true);
|
||||
|
||||
// one-ways
|
||||
map.setCollisionRange(15, 17, true, true, false, true);
|
||||
|
||||
p = game.add.sprite(32, 32, 'player');
|
||||
|
||||
p.body.bounce.y = 0.4;
|
||||
p.body.collideWorldBounds = true;
|
||||
|
||||
game.camera.follow(p);
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
map.collide(p);
|
||||
|
||||
p.body.velocity.x = 0;
|
||||
p.body.acceleration.y = 500;
|
||||
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
|
||||
{
|
||||
p.body.velocity.x = -150;
|
||||
}
|
||||
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
|
||||
{
|
||||
p.body.velocity.x = 150;
|
||||
}
|
||||
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
|
||||
{
|
||||
if (p.body.touching.down)
|
||||
{
|
||||
p.body.velocity.y = -200;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function render() {
|
||||
|
||||
game.debug.renderSpriteCorners(p);
|
||||
game.debug.renderSpriteCollision(p, 32, 320);
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
</script>
|
||||
|
||||
<?php
|
||||
require('../foot.php');
|
||||
?>
|
56
examples/tilemaps/mario.php
Normal file
56
examples/tilemaps/mario.php
Normal file
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
$title = "Test Title";
|
||||
require('../head.php');
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
(function () {
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update, render: render });
|
||||
|
||||
function preload() {
|
||||
|
||||
game.load.tilemap('mario', 'assets/maps/mario1.png', 'assets/maps/mario1.json', null, Phaser.Tilemap.JSON);
|
||||
|
||||
}
|
||||
|
||||
function create() {
|
||||
|
||||
game.stage.backgroundColor = '#787878';
|
||||
|
||||
game.add.tilemap(0, 0, 'mario');
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
|
||||
{
|
||||
game.camera.x -= 8;
|
||||
}
|
||||
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
|
||||
{
|
||||
game.camera.x += 8;
|
||||
}
|
||||
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
|
||||
{
|
||||
game.camera.y -= 8;
|
||||
}
|
||||
else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
|
||||
{
|
||||
game.camera.y += 8;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function render() {
|
||||
}
|
||||
|
||||
})();
|
||||
</script>
|
||||
|
||||
<?php
|
||||
require('../foot.php');
|
||||
?>
|
41
examples/tilemaps/mariotogether.php
Normal file
41
examples/tilemaps/mariotogether.php
Normal file
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
$title = "Test Title";
|
||||
require('../head.php');
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
(function () {
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create });
|
||||
|
||||
function preload() {
|
||||
|
||||
game.load.tilemap('nes', 'assets/maps/mario1.png', 'assets/maps/mario1.json', null, Phaser.Tilemap.JSON);
|
||||
game.load.tilemap('snes', 'assets/maps/smb_tiles.png', 'assets/maps/smb_level1.json', null, Phaser.Tilemap.JSON);
|
||||
|
||||
}
|
||||
|
||||
function create() {
|
||||
|
||||
game.stage.backgroundColor = '#5c94fc';
|
||||
|
||||
game.add.tilemap(0, 0, 'nes');
|
||||
game.add.tilemap(0, 168, 'snes');
|
||||
|
||||
game.add.tween(game.camera).to( { x: 5120-800 }, 30000, Phaser.Easing.Linear.None, true, 0, 1000, true);
|
||||
|
||||
game.input.onDown.add(goFull, this);
|
||||
|
||||
}
|
||||
|
||||
function goFull() {
|
||||
game.stage.scale.startFullScreen();
|
||||
}
|
||||
|
||||
})();
|
||||
</script>
|
||||
|
||||
<?php
|
||||
require('../foot.php');
|
||||
?>
|
58
examples/tilemaps/supermario.php
Normal file
58
examples/tilemaps/supermario.php
Normal file
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
$title = "Test Title";
|
||||
require('../head.php');
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
(function () {
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update, render: render });
|
||||
|
||||
function preload() {
|
||||
|
||||
game.load.tilemap('background', 'assets/maps/smb_bg.png', 'assets/maps/smb_bg.json', null, Phaser.Tilemap.JSON);
|
||||
game.load.tilemap('level1', 'assets/maps/smb_tiles.png', 'assets/maps/smb_level1.json', null, Phaser.Tilemap.JSON);
|
||||
|
||||
}
|
||||
|
||||
function create() {
|
||||
|
||||
game.stage.backgroundColor = '#787878';
|
||||
|
||||
game.add.tilemap(0, 0, 'background');
|
||||
game.add.tilemap(0, 0, 'level1');
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
|
||||
{
|
||||
game.camera.x -= 8;
|
||||
}
|
||||
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
|
||||
{
|
||||
game.camera.x += 8;
|
||||
}
|
||||
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
|
||||
{
|
||||
game.camera.y -= 8;
|
||||
}
|
||||
else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
|
||||
{
|
||||
game.camera.y += 8;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function render() {
|
||||
}
|
||||
|
||||
})();
|
||||
</script>
|
||||
|
||||
<?php
|
||||
require('../foot.php');
|
||||
?>
|
73
examples/tilemaps/supermario2.php
Normal file
73
examples/tilemaps/supermario2.php
Normal file
|
@ -0,0 +1,73 @@
|
|||
<?php
|
||||
$title = "Test Title";
|
||||
require('../head.php');
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
(function () {
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update });
|
||||
|
||||
function preload() {
|
||||
|
||||
game.load.tilemap('background', 'assets/maps/smb_bg.png', 'assets/maps/smb_bg.json', null, Phaser.Tilemap.JSON);
|
||||
game.load.tilemap('level1', 'assets/maps/smb_tiles.png', 'assets/maps/smb_level1.json', null, Phaser.Tilemap.JSON);
|
||||
game.load.spritesheet('balls', 'assets/sprites/balls.png', 17, 17);
|
||||
|
||||
}
|
||||
|
||||
var balls;
|
||||
var map;
|
||||
|
||||
function create() {
|
||||
|
||||
game.stage.backgroundColor = '#787878';
|
||||
|
||||
game.add.tilemap(0, 0, 'background');
|
||||
|
||||
map = game.add.tilemap(0, 0, 'level1');
|
||||
map.setCollisionByIndex([9,10,11,14,15,16,18,19,22,23,24,32,37,38], true, true, true, true);
|
||||
|
||||
balls = game.add.emitter(300, 50, 500);
|
||||
balls.bounce = 0.5;
|
||||
balls.makeParticles('balls', [0,1,2,3,4,5], 500, 1);
|
||||
balls.minParticleSpeed.setTo(-150, 150);
|
||||
balls.maxParticleSpeed.setTo(100, 100);
|
||||
balls.gravity = 8;
|
||||
balls.start(false, 5000, 50);
|
||||
|
||||
game.add.tween(balls).to({ x: 4000 }, 7500, Phaser.Easing.Sinusoidal.InOut, true, 0, 1000, true);
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
game.physics.collide(balls, map);
|
||||
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
|
||||
{
|
||||
game.camera.x -= 8;
|
||||
}
|
||||
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
|
||||
{
|
||||
game.camera.x += 8;
|
||||
}
|
||||
|
||||
if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
|
||||
{
|
||||
game.camera.y -= 8;
|
||||
}
|
||||
else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
|
||||
{
|
||||
game.camera.y += 8;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
</script>
|
||||
|
||||
<?php
|
||||
require('../foot.php');
|
||||
?>
|
|
@ -309,9 +309,9 @@ Phaser.Game.prototype = {
|
|||
|
||||
this.stage.boot();
|
||||
this.world.boot();
|
||||
this.state.boot();
|
||||
this.input.boot();
|
||||
this.sound.boot();
|
||||
this.state.boot();
|
||||
|
||||
if (this.renderType == Phaser.CANVAS)
|
||||
{
|
||||
|
@ -372,9 +372,6 @@ Phaser.Game.prototype = {
|
|||
|
||||
this.state.loadComplete();
|
||||
|
||||
// ?
|
||||
// this.load.onLoadComplete.remove(this.loadComplete, this);
|
||||
|
||||
},
|
||||
|
||||
update: function (time) {
|
||||
|
|
|
@ -291,14 +291,6 @@ Phaser.Input.prototype = {
|
|||
this.hitCanvas.height = 1;
|
||||
this.hitContext = this.hitCanvas.getContext('2d');
|
||||
|
||||
// Debugging
|
||||
// this.hitCanvas.style['width'] = '200px';
|
||||
// this.hitCanvas.style['height'] = '200px';
|
||||
// this.hitCanvas.style['position'] = 'absolute';
|
||||
// this.hitCanvas.style['left'] = '810px';
|
||||
// this.hitCanvas.style['backgroundColor'] = '#ef0000';
|
||||
// Phaser.Canvas.addToDOM(this.hitCanvas);
|
||||
|
||||
this.mouse.start();
|
||||
this.keyboard.start();
|
||||
this.touch.start();
|
||||
|
@ -378,6 +370,11 @@ Phaser.Input.prototype = {
|
|||
**/
|
||||
reset: function (hard) {
|
||||
|
||||
if (this.game.isBooted == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof hard == 'undefined') { hard = false; }
|
||||
|
||||
this.keyboard.reset();
|
||||
|
|
26
wip/examples/js-physics.php
Normal file
26
wip/examples/js-physics.php
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
// All JS files in build order.
|
||||
// Much easier for debugging
|
||||
?>
|
||||
<script src="../src/physics/advanced/Math.js"></script>
|
||||
<script src="../src/physics/advanced/Util.js"></script>
|
||||
<script src="../src/physics/advanced/Collision.js"></script>
|
||||
<script src="../src/physics/advanced/Body.js"></script>
|
||||
<script src="../src/physics/advanced/Joint.js"></script>
|
||||
<script src="../src/physics/advanced/Shape.js"></script>
|
||||
<script src="../src/physics/advanced/Contact.js"></script>
|
||||
<script src="../src/physics/advanced/ContactSolver.js"></script>
|
||||
<script src="../src/physics/advanced/Space.js"></script>
|
||||
<script src="../src/physics/advanced/joints/Angle.js"></script>
|
||||
<script src="../src/physics/advanced/joints/Revolute.js"></script>
|
||||
<script src="../src/physics/advanced/joints/Weld.js"></script>
|
||||
<script src="../src/physics/advanced/joints/Wheel.js"></script>
|
||||
<script src="../src/physics/advanced/joints/Prismatic.js"></script>
|
||||
<script src="../src/physics/advanced/joints/Distance.js"></script>
|
||||
<script src="../src/physics/advanced/joints/Rope.js"></script>
|
||||
<script src="../src/physics/advanced/joints/Mouse.js"></script>
|
||||
<script src="../src/physics/advanced/shapes/Circle.js"></script>
|
||||
<script src="../src/physics/advanced/shapes/Segment.js"></script>
|
||||
<script src="../src/physics/advanced/shapes/Poly.js"></script>
|
||||
<script src="../src/physics/advanced/shapes/Triangle.js"></script>
|
||||
<script src="../src/physics/advanced/shapes/Box.js"></script>
|
109
wip/examples/js.php
Normal file
109
wip/examples/js.php
Normal file
|
@ -0,0 +1,109 @@
|
|||
<?php
|
||||
// All JS files in build order. Much easier for debugging
|
||||
// <xscript src="../src/pixi/extras/Spine.js"></script> <xscript src="../src/pixi/display/MovieClip.js"></script>
|
||||
?>
|
||||
<script src="../src/Intro.js"></script>
|
||||
<script src="../src/pixi/Pixi.js"></script>
|
||||
<script src="../src/Phaser.js"></script>
|
||||
<script src="../src/utils/Utils.js"></script>
|
||||
|
||||
<script src="../src/pixi/core/Matrix.js"></script>
|
||||
<script src="../src/pixi/core/Point.js"></script>
|
||||
<script src="../src/pixi/core/Rectangle.js"></script>
|
||||
<script src="../src/pixi/display/DisplayObject.js"></script>
|
||||
<script src="../src/pixi/display/DisplayObjectContainer.js"></script>
|
||||
<script src="../src/pixi/display/Sprite.js"></script>
|
||||
|
||||
<script src="../src/pixi/display/Stage.js"></script>
|
||||
<script src="../src/pixi/extras/CustomRenderable.js"></script>
|
||||
<script src="../src/pixi/extras/Strip.js"></script>
|
||||
<script src="../src/pixi/extras/Rope.js"></script>
|
||||
|
||||
<script src="../src/pixi/extras/TilingSprite.js"></script>
|
||||
<script src="../src/pixi/filters/FilterBlock.js"></script>
|
||||
<script src="../src/pixi/filters/MaskFilter.js"></script>
|
||||
<script src="../src/pixi/primitives/Graphics.js"></script>
|
||||
<script src="../src/pixi/renderers/canvas/CanvasGraphics.js"></script>
|
||||
<script src="../src/pixi/renderers/canvas/CanvasRenderer.js"></script>
|
||||
<script src="../src/pixi/renderers/webgl/WebGLBatch.js"></script>
|
||||
<script src="../src/pixi/renderers/webgl/WebGLGraphics.js"></script>
|
||||
<script src="../src/pixi/renderers/webgl/WebGLRenderer.js"></script>
|
||||
<script src="../src/pixi/renderers/webgl/WebGLRenderGroup.js"></script>
|
||||
<script src="../src/pixi/renderers/webgl/WebGLShaders.js"></script>
|
||||
<script src="../src/pixi/text/BitmapText.js"></script>
|
||||
<script src="../src/pixi/text/Text.js"></script>
|
||||
<script src="../src/pixi/textures/BaseTexture.js"></script>
|
||||
<script src="../src/pixi/textures/Texture.js"></script>
|
||||
<script src="../src/pixi/textures/RenderTexture.js"></script>
|
||||
<script src="../src/pixi/utils/EventTarget.js"></script>
|
||||
<script src="../src/pixi/utils/Polyk.js"></script>
|
||||
|
||||
<script src="../src/core/Camera.js"></script>
|
||||
<script src="../src/core/State.js"></script>
|
||||
<script src="../src/core/StateManager.js"></script>
|
||||
<script src="../src/core/LinkedList.js"></script>
|
||||
<script src="../src/core/Signal.js"></script>
|
||||
<script src="../src/core/SignalBinding.js"></script>
|
||||
<script src="../src/core/Plugin.js"></script>
|
||||
<script src="../src/core/PluginManager.js"></script>
|
||||
<script src="../src/core/Stage.js"></script>
|
||||
<script src="../src/core/Group.js"></script>
|
||||
<script src="../src/core/World.js"></script>
|
||||
<script src="../src/core/Game.js"></script>
|
||||
<script src="../src/input/Input.js"></script>
|
||||
<script src="../src/input/Keyboard.js"></script>
|
||||
<script src="../src/input/Mouse.js"></script>
|
||||
<script src="../src/input/MSPointer.js"></script>
|
||||
<script src="../src/input/Pointer.js"></script>
|
||||
<script src="../src/input/Touch.js"></script>
|
||||
<script src="../src/input/InputHandler.js"></script>
|
||||
<script src="../src/system/Canvas.js"></script>
|
||||
<script src="../src/gameobjects/Events.js"></script>
|
||||
<script src="../src/gameobjects/GameObjectFactory.js"></script>
|
||||
<script src="../src/gameobjects/Sprite.js"></script>
|
||||
<script src="../src/gameobjects/TileSprite.js"></script>
|
||||
<script src="../src/gameobjects/Text.js"></script>
|
||||
<script src="../src/gameobjects/Button.js"></script>
|
||||
<script src="../src/gameobjects/Graphics.js"></script>
|
||||
<script src="../src/gameobjects/RenderTexture.js"></script>
|
||||
<script src="../src/gameobjects/BitmapText.js"></script>
|
||||
<script src="../src/system/Canvas.js"></script>
|
||||
<script src="../src/system/StageScaleMode.js"></script>
|
||||
<script src="../src/system/Device.js"></script>
|
||||
<script src="../src/system/RequestAnimationFrame.js"></script>
|
||||
<script src="../src/math/RandomDataGenerator.js"></script>
|
||||
<script src="../src/math/Math.js"></script>
|
||||
<script src="../src/math/QuadTree.js"></script>
|
||||
<script src="../src/geom/Circle.js"></script>
|
||||
<script src="../src/geom/Point.js"></script>
|
||||
<script src="../src/geom/Rectangle.js"></script>
|
||||
<script src="../src/net/Net.js"></script>
|
||||
<script src="../src/tween/TweenManager.js"></script>
|
||||
<script src="../src/tween/Tween.js"></script>
|
||||
<script src="../src/tween/Easing.js"></script>
|
||||
<script src="../src/time/Time.js"></script>
|
||||
<script src="../src/animation/AnimationManager.js"></script>
|
||||
<script src="../src/animation/Animation.js"></script>
|
||||
<script src="../src/animation/Frame.js"></script>
|
||||
<script src="../src/animation/FrameData.js"></script>
|
||||
<script src="../src/animation/Parser.js"></script>
|
||||
<script src="../src/loader/Cache.js"></script>
|
||||
<script src="../src/loader/Loader.js"></script>
|
||||
<script src="../src/loader/Parser.js"></script>
|
||||
<script src="../src/sound/Sound.js"></script>
|
||||
<script src="../src/sound/SoundManager.js"></script>
|
||||
<script src="../src/utils/Debug.js"></script>
|
||||
<script src="../src/utils/Color.js"></script>
|
||||
|
||||
<script src="../src/physics/arcade/ArcadePhysics.js"></script>
|
||||
<script src="../src/physics/arcade/Body.js"></script>
|
||||
|
||||
<script src="../src/particles/Particles.js"></script>
|
||||
<script src="../src/particles/arcade/ArcadeParticles.js"></script>
|
||||
<script src="../src/particles/arcade/Emitter.js"></script>
|
||||
|
||||
<script src="../src/tilemap/Tilemap.js"></script>
|
||||
<script src="../src/tilemap/TilemapLayer.js"></script>
|
||||
<script src="../src/tilemap/Tile.js"></script>
|
||||
<script src="../src/tilemap/TilemapRenderer.js"></script>
|
||||
|
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 809 B After Width: | Height: | Size: 809 B |
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue