2013-10-22 02:58:20 +00:00
|
|
|
|
2013-10-24 03:27:28 +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;
|
2014-02-28 18:40:06 +00:00
|
|
|
var cropRect;
|
2013-10-22 02:58:20 +00:00
|
|
|
|
|
|
|
function create() {
|
|
|
|
|
|
|
|
pic = game.add.sprite(0, 0, 'trsi');
|
|
|
|
|
2014-02-28 18:40:06 +00:00
|
|
|
cropRect = {x : 0, y : 0 , width : 128, height : 128};
|
|
|
|
}
|
2014-02-28 18:22:52 +00:00
|
|
|
|
2014-02-28 18:40:06 +00:00
|
|
|
function update() {
|
2013-10-24 03:27:28 +00:00
|
|
|
|
2014-02-28 18:40:06 +00:00
|
|
|
if(game.input.x < pic.width && game.input.y < pic.height){
|
2013-10-22 02:58:20 +00:00
|
|
|
|
2014-02-28 18:40:06 +00:00
|
|
|
pic.x = game.input.x;
|
|
|
|
pic.y = game.input.y;
|
2013-10-22 02:58:20 +00:00
|
|
|
|
2014-02-28 18:40:06 +00:00
|
|
|
cropRect.x = game.input.x;
|
|
|
|
cropRect.y = game.input.y;
|
|
|
|
|
|
|
|
pic.crop(cropRect);
|
|
|
|
|
|
|
|
|
2013-10-22 02:58:20 +00:00
|
|
|
|
2014-02-28 18:40:06 +00:00
|
|
|
}
|
2013-10-22 02:58:20 +00:00
|
|
|
|
2014-02-28 18:40:06 +00:00
|
|
|
|
2013-10-24 03:27:28 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function render() {
|
|
|
|
|
2014-03-03 01:19:31 +00:00
|
|
|
game.debug.text('x: ' + game.input.x + ' y: ' + game.input.y, 32, 32);
|
2013-10-22 02:58:20 +00:00
|
|
|
|
|
|
|
}
|