phaser/examples/sprites/dynamic crop.js

36 lines
634 B
JavaScript
Raw Normal View History

2013-10-22 02:58:20 +00:00
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render });
2013-10-22 02:58:20 +00:00
function preload() {
game.load.image('trsi', 'assets/pics/trsipic1_lazur.jpg');
}
var pic;
function create() {
pic = game.add.sprite(0, 0, 'trsi');
pic.cropEnabled = true;
pic.crop.width = 128;
pic.crop.height = 128;
2013-10-22 02:58:20 +00:00
}
function update() {
pic.x = game.input.x;
pic.y = game.input.y;
pic.crop.x = game.input.x;
pic.crop.y = game.input.y;
}
function render() {
game.debug.renderText('x: ' + game.input.x + ' y: ' + game.input.y, 32, 32);
2013-10-22 02:58:20 +00:00
}