mirror of
https://github.com/wassname/phaser.git
synced 2026-06-27 16:10:15 +08:00
Second commit, all the basic examples added, and wip files moved
This commit is contained in:
@@ -19,10 +19,6 @@
|
||||
{
|
||||
"file": "sprite+sheet.js",
|
||||
"title": "sprite sheet"
|
||||
},
|
||||
{
|
||||
"file": "texture+packer+json+hash.js",
|
||||
"title": "texture packer json hash"
|
||||
}
|
||||
],
|
||||
"audio": [
|
||||
@@ -43,6 +39,26 @@
|
||||
{
|
||||
"file": "01+-+load+an+image.js",
|
||||
"title": "01 - load an image"
|
||||
},
|
||||
{
|
||||
"file": "02+-+click+on+an+image.js",
|
||||
"title": "02 - click on an image"
|
||||
},
|
||||
{
|
||||
"file": "03+-+move+an+image.js",
|
||||
"title": "03 - move an image"
|
||||
},
|
||||
{
|
||||
"file": "04+-+image+follow+input.js",
|
||||
"title": "04 - image follow input"
|
||||
},
|
||||
{
|
||||
"file": "05+-+load+an+animation.js",
|
||||
"title": "05 - load an animation"
|
||||
},
|
||||
{
|
||||
"file": "06+-+render+text.js",
|
||||
"title": "06 - render text"
|
||||
}
|
||||
],
|
||||
"buttons": [
|
||||
@@ -504,10 +520,6 @@
|
||||
"file": "bitmap+fonts.js",
|
||||
"title": "bitmap fonts"
|
||||
},
|
||||
{
|
||||
"file": "hello+arial.js",
|
||||
"title": "hello arial"
|
||||
},
|
||||
{
|
||||
"file": "kern+of+duty.js",
|
||||
"title": "kern of duty"
|
||||
@@ -575,22 +587,6 @@
|
||||
{
|
||||
"file": "swap+tiles.js",
|
||||
"title": "swap tiles"
|
||||
},
|
||||
{
|
||||
"file": "wip1.js",
|
||||
"title": "wip1"
|
||||
},
|
||||
{
|
||||
"file": "wip2.js",
|
||||
"title": "wip2"
|
||||
},
|
||||
{
|
||||
"file": "wip3.js",
|
||||
"title": "wip3"
|
||||
},
|
||||
{
|
||||
"file": "wip4.js",
|
||||
"title": "wip4"
|
||||
}
|
||||
],
|
||||
"tweens": [
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create });
|
||||
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');
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { create: create });
|
||||
|
||||
function create() {
|
||||
@@ -10,4 +9,4 @@ function create() {
|
||||
|
||||
t.anchor.setTo(0.5, 0.5);
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user