2014-02-06 19:34:05 +00:00
|
|
|
|
2014-02-06 23:13:39 +00:00
|
|
|
// var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create, update: update, render: render });
|
2014-02-06 19:34:05 +00:00
|
|
|
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render });
|
|
|
|
|
|
|
|
function preload() {
|
|
|
|
|
|
|
|
game.load.image('pic', 'assets/pics/backscroll.png');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
var image;
|
|
|
|
var image2;
|
2014-02-06 23:13:39 +00:00
|
|
|
var r;
|
2014-02-06 19:34:05 +00:00
|
|
|
|
|
|
|
function create() {
|
|
|
|
|
|
|
|
image = game.add.image(32, 50, 'pic');
|
|
|
|
|
|
|
|
image2 = game.add.image(32, 250, 'pic');
|
|
|
|
|
2014-02-06 23:13:39 +00:00
|
|
|
r = new Phaser.Rectangle(0, 0, 100, 100);
|
|
|
|
|
|
|
|
image2.crop(r);
|
|
|
|
|
2014-02-06 19:34:05 +00:00
|
|
|
game.input.onDown.add(tint, this);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function tint() {
|
|
|
|
|
|
|
|
image.tint = Math.random() * 0xFFFFFF;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function update() {
|
|
|
|
|
2014-02-06 23:13:39 +00:00
|
|
|
if (r && r.width < 300)
|
|
|
|
{
|
|
|
|
r.width += 1;
|
|
|
|
image2.crop(r);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
image2.crop();
|
|
|
|
r = null;
|
|
|
|
}
|
2014-02-06 19:34:05 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function render() {
|
|
|
|
|
2014-03-03 01:19:31 +00:00
|
|
|
game.debug.text(image2.width, 32, 32);
|
2014-02-06 19:34:05 +00:00
|
|
|
|
|
|
|
}
|