user471 Posted April 19, 2014 Share Posted April 19, 2014 Withgame.add.tween(foo.scale).to({ x: 2, y: 2})Foo increases from a top left corner. What is the simplest way to change it, so foo grows from its center? Link to comment Share on other sites More sharing options...
XekeDeath Posted April 19, 2014 Share Posted April 19, 2014 Change the anchor point to 0.5, 0.5. Note that this will change the visual position of the sprite as well. Link to comment Share on other sites More sharing options...
user471 Posted April 19, 2014 Author Share Posted April 19, 2014 Change the anchor point to 0.5, 0.5. Note that this will change the visual position of the sprite as well.What can I do with Groups? They don't have anchors. Link to comment Share on other sites More sharing options...
powerfear Posted April 19, 2014 Share Posted April 19, 2014 What can I do with Groups? They don't have anchors.You can try tweening the group position at the same time that you scale it up. So it will look like its scaling from the center.game.add.tween(foo.scale).to({ x: 2, y: 2});game.add.tween(foo.position).to({ x: -foo.width, y: -foo.height});This may not be perfect but tweak some parameter arround and you should have it working as you like. There might be a simpler way for group but this is the first thing I can think about. Link to comment Share on other sites More sharing options...
rich Posted April 20, 2014 Share Posted April 20, 2014 To do it for a Group you'd change the pivot point instead to be the coordinate you want it to scale based on (given in pixels, not percentage) Link to comment Share on other sites More sharing options...
user471 Posted April 20, 2014 Author Share Posted April 20, 2014 To do it for a Group you'd change the pivot point instead to be the coordinate you want it to scale based on (given in pixels, not percentage)There is nothing pivot related in group documentation.http://docs.phaser.io/Phaser.Group.html Link to comment Share on other sites More sharing options...
rich Posted April 20, 2014 Share Posted April 20, 2014 Doesn't mean it doesn't exist though Link to comment Share on other sites More sharing options...
user471 Posted April 20, 2014 Author Share Posted April 20, 2014 Doesn't mean it doesn't exist though Is it some sort of undocumented feature or just incorrect documentation? Link to comment Share on other sites More sharing options...
qdrj Posted April 20, 2014 Share Posted April 20, 2014 Is it some sort of undocumented feature or just incorrect documentation?Here is inheritance tree for Phaser.Group; Phaser.Group -> PIXI.DisplayObjectContainer -> PIXI.DisplayObject And PIXI.DisplayObject has property "pivot: PIXI.Point" Link to comment Share on other sites More sharing options...
user471 Posted April 20, 2014 Author Share Posted April 20, 2014 Here is inheritance tree for Phaser.Group; Phaser.Group -> PIXI.DisplayObjectContainer -> PIXI.DisplayObject And PIXI.DisplayObject has property "pivot: PIXI.Point" But there is similar DisplayObject properties like alpha, scale and they are in documentation. What is the difference? Link to comment Share on other sites More sharing options...
ethanyoung Posted December 13, 2014 Share Posted December 13, 2014 You can try tweening the group position at the same time that you scale it up. So it will look like its scaling from the center.game.add.tween(foo.scale).to({ x: 2, y: 2});game.add.tween(foo.position).to({ x: -foo.width, y: -foo.height});This may not be perfect but tweak some parameter arround and you should have it working as you like. There might be a simpler way for group but this is the first thing I can think about.game.add.tween(sprite.scale).to( { x: 2, y: 2 }, tweenTime, Phaser.Easing.Linear.None, true, 0, 1000, true);game.add.tween(sprite.position).to( { x: sprite.position.x - sprite.width / 2, y: sprite.position.y - sprite.height / 2}, tweenTime, Phaser.Easing.Linear.None, true, 0, 1000, true );This works for me. You just need to calculate the position of the scaled sprite. It is: origin.x - (scale.width - origin.width) / 2 (in this case scale.width = 2 * origin.width). The same formula for Y axis. MichaelD 1 Link to comment Share on other sites More sharing options...
Recommended Posts