Skip to content

Commit 155c36b

Browse files
committed
Merge pull request phaserjs#126 from alvinsight/dev
Second commit, all the basic examples added, and wip files moved
2 parents 3f9c07d + 8dfe5ae commit 155c36b

11 files changed

Lines changed: 125 additions & 27 deletions

examples/_site/examples.json

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@
1919
{
2020
"file": "sprite+sheet.js",
2121
"title": "sprite sheet"
22-
},
23-
{
24-
"file": "texture+packer+json+hash.js",
25-
"title": "texture packer json hash"
2622
}
2723
],
2824
"audio": [
@@ -43,6 +39,26 @@
4339
{
4440
"file": "01+-+load+an+image.js",
4541
"title": "01 - load an image"
42+
},
43+
{
44+
"file": "02+-+click+on+an+image.js",
45+
"title": "02 - click on an image"
46+
},
47+
{
48+
"file": "03+-+move+an+image.js",
49+
"title": "03 - move an image"
50+
},
51+
{
52+
"file": "04+-+image+follow+input.js",
53+
"title": "04 - image follow input"
54+
},
55+
{
56+
"file": "05+-+load+an+animation.js",
57+
"title": "05 - load an animation"
58+
},
59+
{
60+
"file": "06+-+render+text.js",
61+
"title": "06 - render text"
4662
}
4763
],
4864
"buttons": [
@@ -504,10 +520,6 @@
504520
"file": "bitmap+fonts.js",
505521
"title": "bitmap fonts"
506522
},
507-
{
508-
"file": "hello+arial.js",
509-
"title": "hello arial"
510-
},
511523
{
512524
"file": "kern+of+duty.js",
513525
"title": "kern of duty"
@@ -575,22 +587,6 @@
575587
{
576588
"file": "swap+tiles.js",
577589
"title": "swap tiles"
578-
},
579-
{
580-
"file": "wip1.js",
581-
"title": "wip1"
582-
},
583-
{
584-
"file": "wip2.js",
585-
"title": "wip2"
586-
},
587-
{
588-
"file": "wip3.js",
589-
"title": "wip3"
590-
},
591-
{
592-
"file": "wip4.js",
593-
"title": "wip4"
594590
}
595591
],
596592
"tweens": [
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
2+
var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create });
3+
4+
function preload() {
5+
6+
// You can fill the preloader with as many assets as your game requires
7+
8+
// Here we are loading an image. The first parameter is the unique
9+
// string by which we'll identify the image later in our code.
10+
11+
// The second parameter is the URL of the image (relative)
12+
game.load.image('einstein', 'assets/pics/ra_einstein.png');
13+
}
14+
15+
function create() {
16+
17+
// This creates a simple sprite that is using our loaded image and
18+
// displays it on-screen
19+
// and assign it to a variable
20+
var image = game.add.sprite(0, 0, 'einstein');
21+
22+
//enables all kind of input actions on this image (click, etc)
23+
image.inputEnabled=true;
24+
25+
image.events.onInputDown.add(listener,this);
26+
27+
28+
29+
}
30+
31+
function listener () {
32+
alert('clicked');
33+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
2+
var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create });
3+
4+
function preload() {
5+
6+
// You can fill the preloader with as many assets as your game requires
7+
8+
// Here we are loading an image. The first parameter is the unique
9+
// string by which we'll identify the image later in our code.
10+
11+
// The second parameter is the URL of the image (relative)
12+
game.load.image('einstein', 'assets/pics/ra_einstein.png');
13+
}
14+
15+
function create() {
16+
17+
// This creates a simple sprite that is using our loaded image and
18+
// displays it on-screen
19+
// and assign it to a variable
20+
var image = game.add.sprite(0, 0, 'einstein');
21+
22+
image.body.velocity.x=50;
23+
24+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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+
// You can fill the preloader with as many assets as your game requires
7+
8+
// Here we are loading an image. The first parameter is the unique
9+
// string by which we'll identify the image later in our code.
10+
11+
// The second parameter is the URL of the image (relative)
12+
game.load.image('cactuar', 'assets/pics/cactuar.png');
13+
}
14+
15+
var image;
16+
17+
function create() {
18+
19+
// This creates a simple sprite that is using our loaded image and
20+
// displays it on-screen
21+
// and assign it to a variable
22+
image = game.add.sprite(0, 0, 'cactuar');
23+
24+
}
25+
26+
function update () {
27+
28+
//magic formula to make an object follow the mouse
29+
game.physics.moveToPointer(image,300,game.input.activePointer);
30+
}
31+
32+
function render () {
33+
//debug helper
34+
game.debug.renderInputInfo(32,32);
35+
}

examples/animation/texture packer json hash.js renamed to examples/basics/05 - load an animation.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create });
2+
var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create });
33

44
function preload() {
55
game.load.atlasJSONHash('bot', 'assets/sprites/running_bot.png', 'assets/sprites/running_bot.json');
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { create: create });
3+
4+
function create() {
5+
6+
var text = "- phaser -\n with a sprinkle of \n pixi dust.";
7+
var style = { font: "65px Arial", fill: "#ff0044", align: "center" };
8+
9+
var t = game.add.text(game.world.centerX-300, 0, text, style);
10+
11+
}

examples/text/hello arial.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { create: create });
32

43
function create() {
@@ -10,4 +9,4 @@ function create() {
109

1110
t.anchor.setTo(0.5, 0.5);
1211

13-
}
12+
}

0 commit comments

Comments
 (0)