dchhetri Posted December 14, 2013 Share Posted December 14, 2013 Sounds simple, but from the docs, I can't seem to find a phaser interface todo so, without having to use game.debug or manually change the fillStyle for the context. Anyone know how? Link to comment Share on other sites More sharing options...
JackBid Posted December 14, 2013 Share Posted December 14, 2013 Sounds simple, but from the docs, I can't seem to find a phaser interface todo so, without having to use game.debug or manually change the fillStyle for the context. Anyone know how?I think the only way to do this is to use game.debug:var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { create: create, render: render });var floor;function create() { floor = new Phaser.Rectangle(0, 550, 800, 50);}function render () { game.debug.renderRectangle(floor,'#0fffff');}Is there a particular reason why you do not want to use game.debug? Link to comment Share on other sites More sharing options...
dchhetri Posted December 14, 2013 Author Share Posted December 14, 2013 I think the only way to do this is to use game.debug:var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { create: create, render: render });var floor;function create() { floor = new Phaser.Rectangle(0, 550, 800, 50);}function render () { game.debug.renderRectangle(floor,'#0fffff');}Is there a particular reason why you do not want to use game.debug? From the name I assumed it wasn't necessarily meant to be used for production but just for debugging. Link to comment Share on other sites More sharing options...
rich Posted December 15, 2013 Share Posted December 15, 2013 Correct, don't use it for live and it only works in Canvas mode. If you need rectangle primitives in-game then use a Graphics object, as nothing else will work in WebGL. There's an example showing how to use it. Link to comment Share on other sites More sharing options...
jerome Posted December 15, 2013 Share Posted December 15, 2013 maybe this example will help :http://gametest.mobi/phaser/examples/_site/view_full.html?d=display&f=graphics.js&t=graphics Link to comment Share on other sites More sharing options...
cbrwizard Posted June 2, 2017 Share Posted June 2, 2017 Hey, also starting with Phaser and just came up with the same question. This is the only info I found on the internets that a Rectangle shouldn't be used in production. Maybe this should be noted in the docs? https://photonstorm.github.io/phaser-ce/Phaser.Rectangle.html Like "Note: for production use a Graphics object, as nothing else will work in WebGL". Link to comment Share on other sites More sharing options...
samme Posted June 2, 2017 Share Posted June 2, 2017 You can use BitmapData#rect or Graphics#drawRect. Both work in CANVAS and WEBGL. Link to comment Share on other sites More sharing options...
ForgeableSum Posted July 11, 2017 Share Posted July 11, 2017 Or just use a sprite with whatever color you want as an image texture. That would be the best from a performance point of view. If you create a graphics object, you're creating a whole new webgl call. Bitmap data would be even worse on performance than graphics as you're creating a whole new canvas object. Link to comment Share on other sites More sharing options...
Recommended Posts