mirror of
https://github.com/wassname/phaser.git
synced 2026-08-02 13:00:25 +08:00
Tweens are now bound to their own TweenManager, not always the global game one. So you can create your own managers now (for you clark :)
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create });
|
||||
|
||||
function preload() {
|
||||
var text;
|
||||
var counter = 0;
|
||||
|
||||
function preload () {
|
||||
|
||||
// You can fill the preloader with as many assets as your game requires
|
||||
|
||||
@@ -10,24 +13,30 @@ function preload() {
|
||||
|
||||
// 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');
|
||||
// displays it on-screen and assign it to a variable
|
||||
var image = game.add.sprite(game.world.centerX, game.world.centerY, 'einstein');
|
||||
|
||||
//enables all kind of input actions on this image (click, etc)
|
||||
image.inputEnabled=true;
|
||||
// Moves the image anchor to the middle, so it centers inside the game properly
|
||||
image.anchor.set(0.5);
|
||||
|
||||
image.events.onInputDown.add(listener,this);
|
||||
// Enables all kind of input actions on this image (click, etc)
|
||||
image.inputEnabled = true;
|
||||
|
||||
text = game.add.text(250, 16, '', { fill: '#ffffff' });
|
||||
|
||||
image.events.onInputDown.add(listener, this);
|
||||
|
||||
}
|
||||
|
||||
function listener () {
|
||||
alert('clicked');
|
||||
|
||||
counter++;
|
||||
text.text = "You clicked " + counter + " times!";
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user