Second commit, all the basic examples added, and wip files moved

This commit is contained in:
Webeled
2013-10-25 18:10:03 +01:00
parent f63e8d7d06
commit 8dfe5aee1c
11 changed files with 125 additions and 27 deletions
+33
View File
@@ -0,0 +1,33 @@
var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create });
function preload() {
// You can fill the preloader with as many assets as your game requires
// Here we are loading an image. The first parameter is the unique
// string by which we'll identify the image later in our code.
// The second parameter is the URL of the image (relative)
game.load.image('einstein', 'assets/pics/ra_einstein.png');
}
function create() {
// This creates a simple sprite that is using our loaded image and
// displays it on-screen
// and assign it to a variable
var image = game.add.sprite(0, 0, 'einstein');
//enables all kind of input actions on this image (click, etc)
image.inputEnabled=true;
image.events.onInputDown.add(listener,this);
}
function listener () {
alert('clicked');
}
+24
View File
@@ -0,0 +1,24 @@
var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create });
function preload() {
// You can fill the preloader with as many assets as your game requires
// Here we are loading an image. The first parameter is the unique
// string by which we'll identify the image later in our code.
// The second parameter is the URL of the image (relative)
game.load.image('einstein', 'assets/pics/ra_einstein.png');
}
function create() {
// This creates a simple sprite that is using our loaded image and
// displays it on-screen
// and assign it to a variable
var image = game.add.sprite(0, 0, 'einstein');
image.body.velocity.x=50;
}
@@ -0,0 +1,35 @@
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create,update:update,render:render });
function preload() {
// You can fill the preloader with as many assets as your game requires
// Here we are loading an image. The first parameter is the unique
// string by which we'll identify the image later in our code.
// The second parameter is the URL of the image (relative)
game.load.image('cactuar', 'assets/pics/cactuar.png');
}
var image;
function create() {
// This creates a simple sprite that is using our loaded image and
// displays it on-screen
// and assign it to a variable
image = game.add.sprite(0, 0, 'cactuar');
}
function update () {
//magic formula to make an object follow the mouse
game.physics.moveToPointer(image,300,game.input.activePointer);
}
function render () {
//debug helper
game.debug.renderInputInfo(32,32);
}
+22
View File
@@ -0,0 +1,22 @@
var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create });
function preload() {
game.load.atlasJSONHash('bot', 'assets/sprites/running_bot.png', 'assets/sprites/running_bot.json');
}
function create() {
// This sprite is using a texture atlas for all of its animation data
var bot = game.add.sprite(200, 200, 'bot');
// Here we add a new animation called 'run'
// We haven't specified any frames because it's using every frame in the texture atlas
bot.animations.add('run');
// And this starts the animation playing by using its key ("run")
// 15 is the frame rate (15fps)
// true means it will loop when it finishes
bot.animations.play('run', 15, true);
}
+11
View File
@@ -0,0 +1,11 @@
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { create: create });
function create() {
var text = "- phaser -\n with a sprinkle of \n pixi dust.";
var style = { font: "65px Arial", fill: "#ff0044", align: "center" };
var t = game.add.text(game.world.centerX-300, 0, text, style);
}