mirror of
https://github.com/wassname/phaser.git
synced 2026-07-12 00:50:45 +08:00
Loads of issues reported on Github resolved (sprite crop, music resume, etc).
This commit is contained in:
@@ -1,29 +1,35 @@
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create, update: update });
|
||||
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render });
|
||||
|
||||
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);
|
||||
pic.cropEnabled = true;
|
||||
|
||||
pic.crop.width = 128;
|
||||
pic.crop.height = 128;
|
||||
|
||||
}
|
||||
|
||||
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;
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,27 +1,23 @@
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create, update: update });
|
||||
var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create });
|
||||
|
||||
function preload() {
|
||||
game.load.image('trsi', 'assets/pics/trsipic1_lazur.jpg');
|
||||
}
|
||||
|
||||
var r;
|
||||
var pic;
|
||||
|
||||
function create() {
|
||||
|
||||
pic = game.add.sprite(game.world.centerX, 550, 'trsi');
|
||||
var pic = game.add.sprite(game.world.centerX, 550, 'trsi');
|
||||
|
||||
pic.anchor.setTo(0.5, 1);
|
||||
|
||||
// By default Sprites ignore the crop setting, you have to explicitly enable it like this:
|
||||
pic.cropEnabled = true;
|
||||
|
||||
r = new Phaser.Rectangle(0, 0, 200, pic.height);
|
||||
// Set the crop rect width to zero
|
||||
pic.crop.width = 0;
|
||||
|
||||
game.add.tween(r).to( { x: pic.width - 200 }, 3000, Phaser.Easing.Bounce.Out, true, 0, 1000, true);
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
// Apply the new crop Rectangle to the sprite
|
||||
pic.crop = r;
|
||||
// Here we'll tween the crop rect, from a width of zero to full width, and back again
|
||||
game.add.tween(pic.crop).to( { width: pic.width }, 3000, Phaser.Easing.Bounce.Out, true, 0, 1000, true);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,27 +1,23 @@
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create, update: update });
|
||||
var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create });
|
||||
|
||||
function preload() {
|
||||
game.load.image('trsi', 'assets/pics/trsipic1_lazur.jpg');
|
||||
}
|
||||
|
||||
var r;
|
||||
var pic;
|
||||
|
||||
function create() {
|
||||
|
||||
pic = game.add.sprite(game.world.centerX, 550, 'trsi');
|
||||
var pic = game.add.sprite(game.world.centerX, 550, 'trsi');
|
||||
|
||||
pic.anchor.setTo(0.5, 1);
|
||||
|
||||
r = new Phaser.Rectangle(0, 0, pic.width, 0);
|
||||
// By default Sprites ignore the crop setting, you have to explicitly enable it like this:
|
||||
pic.cropEnabled = true;
|
||||
|
||||
game.add.tween(r).to( { height: pic.height }, 3000, Phaser.Easing.Bounce.Out, true, 0, 1000, true);
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
// Apply the new crop Rectangle to the sprite
|
||||
pic.crop = r;
|
||||
// Set the crop rect height to zero
|
||||
pic.crop.height = 0;
|
||||
|
||||
// Here we'll tween the crop rect, from a height of zero to full height, and back again
|
||||
game.add.tween(pic.crop).to( { height: pic.height }, 3000, Phaser.Easing.Bounce.Out, true, 0, 1000, true);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user