Skip to content

Commit 969fa46

Browse files
author
Webeled
committed
Loads of new examples, some more bug fixes, all of them work beautifully
1 parent faf432b commit 969fa46

24 files changed

Lines changed: 400 additions & 38 deletions

examples/animation/multiple anims.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88

99

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

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

2424
// bot.animations.play('num1', 15, true);
25-
bot.animations.play('num2', 15, true);
25+
//bot.animations.play('num2', 15, true);
2626
// bot.animations.play('num3', 15, true);
2727

2828
}

examples/camera/follow styles.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ function create() {
4646

4747

4848
// background images
49-
game.add.sprite(0, 0, 'sky');
49+
game.add.tileSprite(0, 0,1400,600, 'sky');
5050
game.add.sprite(0, 360, 'ground');
5151
game.add.sprite(0, 400, 'river');
5252
game.add.sprite(200, 120, 'cloud0');

examples/camera/world sprite.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
function preload() {
1414

15-
game.world.setBounds(1920, 1200);
15+
game.world.setBounds(0,0,1920, 1200);
1616

1717
game.load.image('backdrop', 'assets/pics/remember-me.jpg');
1818
game.load.image('card', 'assets/sprites/mana_card.png');

examples/collision/group vs group.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,16 @@ function create() {
5656

5757
function update() {
5858

59-
sprite.velocity.x = 0;
60-
sprite.velocity.y = 0;
59+
sprite.body.velocity.x = 0;
60+
sprite.body.velocity.y = 0;
6161

6262
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
6363
{
64-
sprite.velocity.x = -200;
64+
sprite.body.velocity.x = -200;
6565
}
6666
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
6767
{
68-
sprite.velocity.x = 200;
68+
sprite.body.velocity.x = 200;
6969
}
7070

7171
if (game.input.keyboard.isDown(Phaser.Keyboard.SPACEBAR))
@@ -86,7 +86,7 @@ function fireBullet () {
8686
if (bullet)
8787
{
8888
bullet.reset(sprite.x + 6, sprite.y - 8);
89-
bullet.velocity.y = -300;
89+
bullet.body.velocity.y = -300;
9090
bulletTime = game.time.now + 250;
9191
}
9292
}

examples/collision/sprite vs group.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,25 +49,25 @@ function create() {
4949

5050
function update() {
5151

52-
sprite.velocity.x = 0;
53-
sprite.velocity.y = 0;
52+
sprite.body.velocity.x = 0;
53+
sprite.body.velocity.y = 0;
5454

5555
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
5656
{
57-
sprite.velocity.x = -200;
57+
sprite.body.velocity.x = -200;
5858
}
5959
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
6060
{
61-
sprite.velocity.x = 200;
61+
sprite.body.velocity.x = 200;
6262
}
6363

6464
if (game.input.keyboard.isDown(Phaser.Keyboard.UP))
6565
{
66-
sprite.velocity.y = -200;
66+
sprite.body.velocity.y = -200;
6767
}
6868
else if (game.input.keyboard.isDown(Phaser.Keyboard.DOWN))
6969
{
70-
sprite.velocity.y = 200;
70+
sprite.body.velocity.y = 200;
7171
}
7272

7373
game.physics.collide(sprite, group, collisionHandler, null, this);

examples/display/graphics.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ function create() {
5555
graphics.moveTo(30,30);
5656
graphics.lineTo(600, 300);
5757

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

6260

examples/games/invaders.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,16 @@ function descend() {
6565

6666
function update() {
6767

68-
player.velocity.x = 0;
69-
player.velocity.y = 0;
68+
player.body.velocity.x = 0;
69+
player.body.velocity.y = 0;
7070

7171
if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT))
7272
{
73-
player.velocity.x = -200;
73+
player.body.velocity.x = -200;
7474
}
7575
else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT))
7676
{
77-
player.velocity.x = 200;
77+
player.body.velocity.x = 200;
7878
}
7979

8080
if (game.input.keyboard.isDown(Phaser.Keyboard.SPACEBAR))
@@ -95,7 +95,7 @@ function fireBullet () {
9595
if (bullet)
9696
{
9797
bullet.reset(player.x, player.y - 8);
98-
bullet.velocity.y = -300;
98+
bullet.body.velocity.y = -300;
9999
bulletTime = game.time.now + 250;
100100
}
101101
}

examples/geometry/circle.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
$title = "Circle";
3+
require('../head.php');
4+
?>
5+
6+
<script type="text/javascript">
7+
8+
9+
10+
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', {create: create,render:render});
11+
12+
var circle;
13+
var floor;
14+
15+
function create() {
16+
17+
circle = new Phaser.Circle(game.world.centerX, 100,64);
18+
}
19+
20+
function render () {
21+
game.debug.renderCircle(circle,'#cfffff');
22+
game.debug.renderText('Diameter : '+circle.diameter,50,200);
23+
game.debug.renderText('Circumference : '+circle.circumference(),50,230);
24+
}
25+
26+
27+
28+
</script>
29+
30+
<?php
31+
require('../foot.php');
32+
?>

examples/geometry/line.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
$title = "Rectangle";
3+
require('../head.php');
4+
?>
5+
6+
<script type="text/javascript">
7+
8+
9+
10+
var game = new Phaser.Game(800, 600, Phaser.AUTO, '', {create: create});
11+
12+
function create() {
13+
14+
var graphics = game.add.graphics(50,50);
15+
16+
// set a fill and line style
17+
graphics.beginFill(0xFF0000);
18+
graphics.lineStyle(10, 0xFF0000, 1);
19+
20+
// draw a shape
21+
graphics.moveTo(50,50);
22+
graphics.lineTo(250, 50);
23+
graphics.endFill();
24+
}
25+
26+
27+
28+
</script>
29+
30+
<?php
31+
require('../foot.php');
32+
?>
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?php
2+
$title = "Rotate point";
3+
require('../head.php');
4+
?>
5+
6+
<script type="text/javascript">
7+
8+
9+
10+
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', {create: create,update:update,render:render});
11+
12+
var p1;
13+
var p2;
14+
var p3;
15+
var p4;
16+
17+
var d2 = 0;
18+
var d3 = 0;
19+
var d4 = 0;
20+
21+
function create() {
22+
23+
p1 = new Phaser.Point(game.world.centerX, game.world.centerY);
24+
p2 = new Phaser.Point(p1.x - 50, p1.y - 50);
25+
p3 = new Phaser.Point(p2.x - 50, p2.y - 50);
26+
p4 = new Phaser.Point(p3.x - 50, p3.y - 50);
27+
28+
}
29+
30+
function update() {
31+
32+
p2.rotate(p1.x, p1.y, game.math.wrapAngle(d2), true, 150);
33+
p3.rotate(p2.x, p2.y, game.math.wrapAngle(d3), true, 50);
34+
p4.rotate(p3.x, p3.y, game.math.wrapAngle(d4), true, 100);
35+
36+
d2 += 1;
37+
d3 += 4;
38+
d4 += 6;
39+
40+
}
41+
42+
function render() {
43+
44+
game.context.strokeStyle = 'rgb(0,255,255)';
45+
game.context.beginPath();
46+
game.context.moveTo(p1.x, p1.y);
47+
game.context.lineTo(p2.x, p2.y);
48+
game.context.lineTo(p3.x, p3.y);
49+
game.context.lineTo(p4.x, p4.y);
50+
game.context.stroke();
51+
game.context.closePath();
52+
53+
game.context.fillStyle = 'rgb(255,255,0)';
54+
game.context.fillRect(p1.x, p1.y, 4, 4);
55+
56+
game.context.fillStyle = 'rgb(255,0,0)';
57+
game.context.fillRect(p2.x, p2.y, 4, 4);
58+
59+
game.context.fillStyle = 'rgb(0,255,0)';
60+
game.context.fillRect(p3.x, p3.y, 4, 4);
61+
62+
game.context.fillStyle = 'rgb(255,0,255)';
63+
game.context.fillRect(p4.x, p4.y, 4, 4);
64+
65+
}
66+
</script>
67+
68+
<?php
69+
require('../foot.php');
70+
?>

0 commit comments

Comments
 (0)