Skip to content

Commit 4fd676c

Browse files
Phaser: examples 2.6.2.
1 parent 14e64ff commit 4fd676c

File tree

125 files changed

+4556
-535
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+4556
-535
lines changed

source/phasereditor/phasereditor.inspect.core.resources/phaser-version/phaser-custom/examples/examples-cache.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
2+
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render });
3+
4+
function preload() {
5+
6+
game.load.image('wizball', 'assets/sprites/wizball.png');
7+
game.load.image('disk', 'assets/sprites/copy-that-floppy.png');
8+
9+
}
10+
11+
var ball1;
12+
var ball2;
13+
var disk;
14+
15+
function create() {
16+
17+
game.physics.startSystem(Phaser.Physics.ARCADE);
18+
19+
disk = game.add.sprite(80, 0, 'disk');
20+
ball1 = game.add.sprite(100, 240, 'wizball');
21+
ball2 = game.add.sprite(700, 240, 'wizball');
22+
23+
// rect corners collide, but circles don't
24+
// ball2.x = 280;
25+
// ball2.y = 220;
26+
27+
// circles collide
28+
// ball2.x = 260;
29+
// ball2.y = 140;
30+
31+
// disk rect NOT collide with ball1, and is out of its bounds
32+
// disk.x = 320;
33+
// disk.y = 380;
34+
35+
// disk rect NOT collide with ball1, but is within its bounds
36+
// disk.x = 280;
37+
// disk.y = 380;
38+
39+
// disk rect WILL collide with ball1
40+
// disk.x = 270;
41+
// disk.y = 370;
42+
43+
44+
// game.physics.arcade.enable([ball1, ball2]);
45+
game.physics.arcade.enable([disk, ball1, ball2]);
46+
47+
// By default the Body is a rectangle. Let's turn it into a Circle with a radius of 45 pixels
48+
49+
ball1.body.setCircle(45);
50+
ball2.body.setCircle(45);
51+
52+
// ball1.body.immovable = true;
53+
// ball2.body.mass = 3;
54+
55+
// Set the ball to collide with the world, have gravity, bounce, and move.
56+
ball1.body.collideWorldBounds = true;
57+
ball2.body.collideWorldBounds = true;
58+
disk.body.collideWorldBounds = true;
59+
60+
ball1.body.bounce.set(1);
61+
ball2.body.bounce.set(1);
62+
disk.body.bounce.set(1);
63+
64+
ball1.body.gravity.y = 100;
65+
ball2.body.gravity.y = 100;
66+
disk.body.gravity.y = 100;
67+
68+
// ball1.body.velocity.x = 50;
69+
// ball2.body.velocity.x = -50;
70+
71+
ball1.body.velocity.set(150);
72+
ball2.body.velocity.set(-200, 60);
73+
disk.body.velocity.set(50);
74+
75+
// game.input.onDown.add(function() { console.log(game.physics.arcade.intersects(ball1.body, ball2.body)); });
76+
// game.input.onDown.add(function() { console.log(game.physics.arcade.intersects(ball1.body, disk.body)); });
77+
78+
}
79+
80+
function update () {
81+
82+
game.physics.arcade.collide(ball1, ball2);
83+
game.physics.arcade.collide(ball1, disk);
84+
game.physics.arcade.collide(ball2, disk);
85+
86+
}
87+
88+
function render () {
89+
90+
game.debug.body(disk);
91+
game.debug.body(ball1);
92+
game.debug.body(ball2);
93+
94+
}

source/phasereditor/phasereditor.inspect.core.resources/phaser-version/phaser-examples-master/examples/arcade physics/group vs self.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,35 @@ var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: p
33

44
function preload() {
55

6-
game.load.spritesheet('spinner', 'assets/sprites/bluemetal_32x32x4.png', 32, 32);
6+
game.load.spritesheet('spinner', 'assets/sprites/bluemetal_32x32x4.png', 32, 32);
77

88
}
99

1010
var sprites;
1111

1212
function create() {
1313

14-
// Here we create a group, populate it with sprites, give them all a random velocity
15-
// and then check the group against itself for collision
14+
// Here we create a group, populate it with sprites, give them all a random velocity
15+
// and then check the group against itself for collision
1616

17-
sprites = game.add.physicsGroup(Phaser.Physics.ARCADE);
17+
sprites = game.add.physicsGroup(Phaser.Physics.ARCADE);
1818

19-
for (var i = 0; i < 90; i++)
20-
{
21-
var s = sprites.create(game.rnd.integerInRange(100, 700), game.rnd.integerInRange(32, 200), 'spinner');
22-
s.animations.add('spin', [0, 1, 2, 3]);
23-
s.play('spin', 20, true);
24-
s.body.velocity.set(game.rnd.integerInRange(-200, 200), game.rnd.integerInRange(-200, 200));
25-
}
19+
for (var i = 0; i < 90; i++)
20+
{
21+
var s = sprites.create(game.rnd.integerInRange(100, 700), game.rnd.integerInRange(32, 200), 'spinner');
22+
s.animations.add('spin', [0, 1, 2, 3]);
23+
s.play('spin', 20, true);
24+
s.body.velocity.set(game.rnd.integerInRange(-200, 200), game.rnd.integerInRange(-200, 200));
25+
}
2626

27-
sprites.setAll('body.collideWorldBounds', true);
28-
sprites.setAll('body.bounce.x', 1);
29-
sprites.setAll('body.bounce.y', 1);
27+
sprites.setAll('body.collideWorldBounds', true);
28+
sprites.setAll('body.bounce.x', 1);
29+
sprites.setAll('body.bounce.y', 1);
3030

3131
}
3232

3333
function update() {
3434

35-
game.physics.arcade.collide(sprites);
35+
game.physics.arcade.collide(sprites);
3636

3737
}

0 commit comments

Comments
 (0)