caymanbruce Posted March 10, 2017 Report 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. Quote Link to comment Share on other sites More sharing options...
rroylance Posted March 10, 2017 Report 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. Quote Link to comment Share on other sites More sharing options...
caymanbruce Posted March 10, 2017 Author Report 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. Quote Link to comment Share on other sites More sharing options...
rroylance Posted March 10, 2017 Report 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? Quote Link to comment Share on other sites More sharing options...
samme Posted March 10, 2017 Report 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.