mirror of
https://github.com/wassname/phaser.git
synced 2026-07-28 11:23:50 +08:00
Fixed scale, flippedX/Y and rotation so they all work from a single setTransform in any combination, taking the origin into account. Phew!
This commit is contained in:
@@ -12,13 +12,17 @@
|
||||
game.stage.backgroundColor = 'rgb(0,0,100)';
|
||||
// Here we'll assign the new sprite to the local fuji variable
|
||||
//fuji = game.add.sprite(game.stage.centerX - 160, game.stage.centerY - 100, 'fuji');
|
||||
fuji = game.add.sprite(100, game.stage.centerY - 100, 'fuji');
|
||||
//fuji.scale.x = 2;
|
||||
//fuji.scale.y = 2;
|
||||
fuji = game.add.sprite(200, 200, 'fuji');
|
||||
// sets origin to the center of the sprite (half the width and half the height)
|
||||
fuji.origin.setTo(160, 100);
|
||||
fuji.scale.x = 2;
|
||||
fuji.scale.y = 2;
|
||||
//fuji.texture.flippedX = true;
|
||||
fuji.texture.flippedY = true;
|
||||
//fuji.origin.setTo(160, 100);
|
||||
//fuji.rotation = 45;
|
||||
game.add.tween(fuji.scale).to({
|
||||
x: 0
|
||||
}, 3000).start();
|
||||
game.add.tween(fuji.position).to({
|
||||
rotation: 360
|
||||
}, 3000).start();
|
||||
|
||||
@@ -22,15 +22,18 @@
|
||||
|
||||
// Here we'll assign the new sprite to the local fuji variable
|
||||
//fuji = game.add.sprite(game.stage.centerX - 160, game.stage.centerY - 100, 'fuji');
|
||||
fuji = game.add.sprite(100, game.stage.centerY - 100, 'fuji');
|
||||
fuji = game.add.sprite(200, 200, 'fuji');
|
||||
|
||||
//fuji.scale.x = 2;
|
||||
//fuji.scale.y = 2;
|
||||
// sets origin to the center of the sprite (half the width and half the height)
|
||||
fuji.origin.setTo(160, 100);
|
||||
|
||||
fuji.scale.x = 2;
|
||||
fuji.scale.y = 2;
|
||||
//fuji.texture.flippedX = true;
|
||||
fuji.texture.flippedY = true;
|
||||
|
||||
//fuji.origin.setTo(160, 100);
|
||||
//fuji.rotation = 45;
|
||||
|
||||
//game.add.tween(fuji.scale).to({ x: 0 }, 3000).start();
|
||||
game.add.tween(fuji.position).to({ rotation: 360 }, 3000).start();
|
||||
|
||||
// We set the origin of the Sprite to be the center so that the scaling happens around the center, not the left-hand side
|
||||
|
||||
Reference in New Issue
Block a user