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:
Richard Davey
2013-05-29 11:40:05 +01:00
parent 09f57fa346
commit 2a26257caa
6 changed files with 354 additions and 156 deletions
+8 -4
View File
@@ -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();
+8 -5
View File
@@ -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