mirror of
https://github.com/photonstorm/phaser
synced 2024-12-24 20:13:35 +00:00
29 lines
536 B
JavaScript
29 lines
536 B
JavaScript
|
|
var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create, update: update });
|
|
|
|
function preload() {
|
|
game.load.image('trsi', 'assets/pics/trsipic1_lazur.jpg');
|
|
}
|
|
|
|
var r;
|
|
var pic;
|
|
|
|
function create() {
|
|
|
|
pic = game.add.sprite(0, 0, 'trsi');
|
|
|
|
r = new Phaser.Rectangle(0, 0, 200, 200);
|
|
|
|
}
|
|
|
|
function update() {
|
|
|
|
r.x = game.input.x;
|
|
r.y = game.input.y;
|
|
pic.x = game.input.x;
|
|
pic.y = game.input.y;
|
|
|
|
// Apply the new crop Rectangle to the sprite
|
|
pic.crop = r;
|
|
|
|
}
|