Skip to content

Commit

Permalink
Loads of new examples, some more bug fixes, all of them work beautifully
Browse files Browse the repository at this point in the history
  • Loading branch information
Webeled committed Oct 14, 2013
1 parent faf432b commit 969fa46
Show file tree
Hide file tree
Showing 24 changed files with 400 additions and 38 deletions.
4 changes: 2 additions & 2 deletions examples/animation/multiple anims.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@



var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create });
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create });

function preload() {
game.load.atlas('bot', 'assets/misc/NumberSprite.png', 'assets/misc/NumberSprite.json');
Expand All @@ -22,7 +22,7 @@ function create() {
bot.animations.add('num3', ['num30000','num30001','num30002','num30003','num30004','num30005'], 24, false, false);

// bot.animations.play('num1', 15, true);
bot.animations.play('num2', 15, true);
//bot.animations.play('num2', 15, true);
// bot.animations.play('num3', 15, true);

}
Expand Down
2 changes: 1 addition & 1 deletion examples/camera/follow styles.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function create() {


// background images
game.add.sprite(0, 0, 'sky');
game.add.tileSprite(0, 0,1400,600, 'sky');
game.add.sprite(0, 360, 'ground');
game.add.sprite(0, 400, 'river');
game.add.sprite(200, 120, 'cloud0');
Expand Down
2 changes: 1 addition & 1 deletion examples/camera/world sprite.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

function preload() {

game.world.setBounds(1920, 1200);
game.world.setBounds(0,0,1920, 1200);

game.load.image('backdrop', 'assets/pics/remember-me.jpg');
game.load.image('card', 'assets/sprites/mana_card.png');
Expand Down
10 changes: 5 additions & 5 deletions examples/collision/group vs group.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,16 @@ function create() {

function update() {

sprite.velocity.x = 0;
sprite.velocity.y = 0;
sprite.body.velocity.x = 0;
sprite.body.velocity.y = 0;

if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
{
sprite.velocity.x = -200;
sprite.body.velocity.x = -200;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
{
sprite.velocity.x = 200;
sprite.body.velocity.x = 200;
}

if (game.input.keyboard.isDown(Phaser.Keyboard.SPACEBAR))
Expand All @@ -86,7 +86,7 @@ function fireBullet () {
if (bullet)
{
bullet.reset(sprite.x + 6, sprite.y - 8);
bullet.velocity.y = -300;
bullet.body.velocity.y = -300;
bulletTime = game.time.now + 250;
}
}
Expand Down
12 changes: 6 additions & 6 deletions examples/collision/sprite vs group.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,25 +49,25 @@ function create() {

function update() {

sprite.velocity.x = 0;
sprite.velocity.y = 0;
sprite.body.velocity.x = 0;
sprite.body.velocity.y = 0;

if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
{
sprite.velocity.x = -200;
sprite.body.velocity.x = -200;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
{
sprite.velocity.x = 200;
sprite.body.velocity.x = 200;
}

if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
{
sprite.velocity.y = -200;
sprite.body.velocity.y = -200;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
{
sprite.velocity.y = 200;
sprite.body.velocity.y = 200;
}

game.physics.collide(sprite, group, collisionHandler, null, this);
Expand Down
2 changes: 0 additions & 2 deletions examples/display/graphics.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ function create() {
graphics.moveTo(30,30);
graphics.lineTo(600, 300);

game.add.tween(graphics).to({ x: 200 }, 2000, Phaser.Easing.Linear.None, true, 0, 1000, true);

}


Expand Down
10 changes: 5 additions & 5 deletions examples/games/invaders.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,16 @@ function descend() {

function update() {

player.velocity.x = 0;
player.velocity.y = 0;
player.body.velocity.x = 0;
player.body.velocity.y = 0;

if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
{
player.velocity.x = -200;
player.body.velocity.x = -200;
}
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
{
player.velocity.x = 200;
player.body.velocity.x = 200;
}

if (game.input.keyboard.isDown(Phaser.Keyboard.SPACEBAR))
Expand All @@ -95,7 +95,7 @@ function fireBullet () {
if (bullet)
{
bullet.reset(player.x, player.y - 8);
bullet.velocity.y = -300;
bullet.body.velocity.y = -300;
bulletTime = game.time.now + 250;
}
}
Expand Down
32 changes: 32 additions & 0 deletions examples/geometry/circle.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
$title = "Circle";
require('../head.php');
?>

<script type="text/javascript">



var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', {create: create,render:render});

var circle;
var floor;

function create() {

circle = new Phaser.Circle(game.world.centerX, 100,64);
}

function render () {
game.debug.renderCircle(circle,'#cfffff');
game.debug.renderText('Diameter : '+circle.diameter,50,200);
game.debug.renderText('Circumference : '+circle.circumference(),50,230);
}



</script>

<?php
require('../foot.php');
?>
32 changes: 32 additions & 0 deletions examples/geometry/line.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
$title = "Rectangle";
require('../head.php');
?>

<script type="text/javascript">



var game = new Phaser.Game(800, 600, Phaser.AUTO, '', {create: create});

function create() {

var graphics = game.add.graphics(50,50);

// set a fill and line style
graphics.beginFill(0xFF0000);
graphics.lineStyle(10, 0xFF0000, 1);

// draw a shape
graphics.moveTo(50,50);
graphics.lineTo(250, 50);
graphics.endFill();
}



</script>

<?php
require('../foot.php');
?>
70 changes: 70 additions & 0 deletions examples/geometry/playing with points.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php
$title = "Rotate point";
require('../head.php');
?>

<script type="text/javascript">



var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', {create: create,update:update,render:render});

var p1;
var p2;
var p3;
var p4;

var d2 = 0;
var d3 = 0;
var d4 = 0;

function create() {

p1 = new Phaser.Point(game.world.centerX, game.world.centerY);
p2 = new Phaser.Point(p1.x - 50, p1.y - 50);
p3 = new Phaser.Point(p2.x - 50, p2.y - 50);
p4 = new Phaser.Point(p3.x - 50, p3.y - 50);

}

function update() {

p2.rotate(p1.x, p1.y, game.math.wrapAngle(d2), true, 150);
p3.rotate(p2.x, p2.y, game.math.wrapAngle(d3), true, 50);
p4.rotate(p3.x, p3.y, game.math.wrapAngle(d4), true, 100);

d2 += 1;
d3 += 4;
d4 += 6;

}

function render() {

game.context.strokeStyle = 'rgb(0,255,255)';
game.context.beginPath();
game.context.moveTo(p1.x, p1.y);
game.context.lineTo(p2.x, p2.y);
game.context.lineTo(p3.x, p3.y);
game.context.lineTo(p4.x, p4.y);
game.context.stroke();
game.context.closePath();

game.context.fillStyle = 'rgb(255,255,0)';
game.context.fillRect(p1.x, p1.y, 4, 4);

game.context.fillStyle = 'rgb(255,0,0)';
game.context.fillRect(p2.x, p2.y, 4, 4);

game.context.fillStyle = 'rgb(0,255,0)';
game.context.fillRect(p3.x, p3.y, 4, 4);

game.context.fillStyle = 'rgb(255,0,255)';
game.context.fillRect(p4.x, p4.y, 4, 4);

}
</script>

<?php
require('../foot.php');
?>
30 changes: 30 additions & 0 deletions examples/geometry/rectangle.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
$title = "Rectangle";
require('../head.php');
?>

<script type="text/javascript">



var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', {create: create,render:render});

var floor;

function create() {

// A simple floor
floor = new Phaser.Rectangle(0, 550,800,50);
}

function render () {
game.debug.renderRectangle(floor,'#0fffff');
}



</script>

<?php
require('../foot.php');
?>
47 changes: 47 additions & 0 deletions examples/geometry/rotate point.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php
$title = "Rotate point";
require('../head.php');
?>

<script type="text/javascript">



var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', {create: create,update:update,render:render});

var p1;
var p2;
var d=0;

function create() {

p1 = new Phaser.Point(200, 300);
p2 = new Phaser.Point(300, 300);

}

function update() {

p1.rotate(p2.x, p2.y, game.math.wrapAngle(d), true);

d++;

}

function render() {

game.context.fillStyle = 'rgb(255,255,0)';
game.context.fillRect(p1.x, p1.y, 4, 4);

game.context.fillStyle = 'rgb(255,0,0)';
game.context.fillRect(p2.x, p2.y, 4, 4);

}



</script>

<?php
require('../foot.php');
?>
2 changes: 1 addition & 1 deletion examples/groups/group as layer.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create,render:render});

function preload() {
game.world.setBounds(1280, 800);
game.world.setBounds(0,0,1280, 800);

game.load.image('ground', 'assets/tests/ground-2x.png');
game.load.image('river', 'assets/tests/river-2x.png');
Expand Down
2 changes: 1 addition & 1 deletion examples/input/game scale.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function preload() {
function create() {

//We increase the size of our game world
game.world.setBounds(2000, 2000);
game.world.setBounds(0,0,2000, 2000);

for (var i = 0; i < 1000; i++)
{
Expand Down
4 changes: 2 additions & 2 deletions examples/input/keyboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
var speed=4;

function preload() {
game.world.setBounds(1280, 600);
game.world.setBounds(0,0,1280, 600);
game.load.image('ground', 'assets/tests/ground-2x.png');
game.load.image('river', 'assets/tests/river-2x.png');
game.load.image('sky', 'assets/tests/sky-2x.png');
Expand All @@ -31,7 +31,7 @@ function preload() {
}
function create() {
// background images
game.add.sprite(0, 0, 'sky');
game.add.tileSprite(0, 0,1280,600, 'sky');
game.add.sprite(0, 360, 'ground');
game.add.sprite(0, 400, 'river');
game.add.sprite(200, 120, 'cloud0');
Expand Down
Loading

0 comments on commit 969fa46

Please sign in to comment.