mirror of
https://github.com/wassname/phaser.git
synced 2026-09-11 12:31:29 +08:00
Sprite.crop() now takes a Phaser.Rectangle instead of explicit parameters.
Phaser.Image is a brand new display object perfect for logos, backgrounds, etc. You can scale, rotate, tint and blend and Image, but it has no animation, physics body or input events. Previously if you used Sprite.crop() it would crop all Sprites using the same base image. It now takes a local copy of the texture data and crops just that.
This commit is contained in:
+17
-2
@@ -1,4 +1,5 @@
|
||||
|
||||
// var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create, update: update, render: render });
|
||||
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render });
|
||||
|
||||
function preload() {
|
||||
@@ -9,6 +10,7 @@ function preload() {
|
||||
|
||||
var image;
|
||||
var image2;
|
||||
var r;
|
||||
|
||||
function create() {
|
||||
|
||||
@@ -16,6 +18,10 @@ function create() {
|
||||
|
||||
image2 = game.add.image(32, 250, 'pic');
|
||||
|
||||
r = new Phaser.Rectangle(0, 0, 100, 100);
|
||||
|
||||
image2.crop(r);
|
||||
|
||||
game.input.onDown.add(tint, this);
|
||||
|
||||
}
|
||||
@@ -28,12 +34,21 @@ function tint() {
|
||||
|
||||
function update() {
|
||||
|
||||
// image.angle += 1;
|
||||
if (r && r.width < 300)
|
||||
{
|
||||
r.width += 1;
|
||||
image2.crop(r);
|
||||
}
|
||||
else
|
||||
{
|
||||
image2.crop();
|
||||
r = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function render() {
|
||||
|
||||
// game.debug.renderText(sprite.position.y, 32, 32);
|
||||
game.debug.renderText(image2.width, 32, 32);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user