caymanbruce Posted March 10, 2017 Share Posted March 10, 2017 Is there a method that works even after scaling and changing screen size? I am using the "drawRect" method in Phaser.graphics but I don't know how to get the bounds of the shape. Link to comment Share on other sites More sharing options...
rroylance Posted March 10, 2017 Share Posted March 10, 2017 Is lineStyle what you're looking for? http://phaser.io/docs/2.6.2/Phaser.Graphics.html#lineStyle Calling this before you call drawRect will result in a filled rectangle with an outline. Link to comment Share on other sites More sharing options...
caymanbruce Posted March 10, 2017 Author Share Posted March 10, 2017 46 minutes ago, UncleAcid said: Is lineStyle what you're looking for? http://phaser.io/docs/2.6.2/Phaser.Graphics.html#lineStyle Calling this before you call drawRect will result in a filled rectangle with an outline. I use clear, lineStyle, drawRect and then endFill. and the parameters I use in drawRect is sprite.left, sprite.top, sprite.width, sprite.height. However when I scale the sprite it seems to only scale the texture/image attached to the sprite, the outline doesn't change with the scale. Link to comment Share on other sites More sharing options...
rroylance Posted March 10, 2017 Share Posted March 10, 2017 53 minutes ago, caymanbruce said: I use clear, lineStyle, drawRect and then endFill. and the parameters I use in drawRect is sprite.left, sprite.top, sprite.width, sprite.height. However when I scale the sprite it seems to only scale the texture/image attached to the sprite, the outline doesn't change with the scale. Ah, gotcha. I'm not sure, but you could try generating a texture from your graphics object to create a sprite with, instead of just using the graphics object? Link to comment Share on other sites More sharing options...
samme Posted March 10, 2017 Share Posted March 10, 2017 6 hours ago, caymanbruce said: I use clear, lineStyle, drawRect and then endFill. and the parameters I use in drawRect is sprite.left, sprite.top, sprite.width, sprite.height. That's the right way, you just have to redraw the graphic if the sprite changes size. Link to comment Share on other sites More sharing options...
Recommended Posts