1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 | // Ex03. Sprite
var game = new Phaser.Game(800, 600, Phaser.AUTO, 'ex03',
{ preload: preload, create: create});
var ball;
function preload() {
game.load.image('ball', 'images/ex03.png');
}
function create() {
game.stage.backgroundColor = "#0FFF0F";
var x = game.world.centerX;
var y = game.world.centerY;
ball = game.add.sprite(x, y, 'ball');
ball.scale.setTo(2,2);
ball.anchor.setTo(0.5, 0.5);
game.input.onDown.add(changePosition, this);
}
function changePosition() {
ball.x = game.input.activePointer.x;
ball.y = game.input.activePointer.y;
}
|
No comments:
Post a Comment