owenconti 0 Report post Posted July 5, 2014 I'm very new to Phaser, so please bare with me. Is this the easiest way to create a solid-colored rectangle?this.completionSprite = game.add.graphics( 0, 0 );this.completionSprite.beginFill(0xFFFF00, 1);this.completionSprite.bounds = new PIXI.Rectangle(0, 0, 200, 200);this.completionSprite.drawRect(0, 0, 200, 200);I originally tried that without the 3rd line, but my Rectangle ended up being greater than 200x200 (around 220px, as if there was 10px padding on it) Am I doing something wrong? Why do I have to set the x/y/width/height twice? Share this post Link to post Share on other sites
titmael 11 Report post Posted July 5, 2014 http://examples.phaser.io/_site/view_full.html?d=display&f=graphics.js&t=graphics is it what you want ?What do you mean solid ? With physics ? Share this post Link to post Share on other sites
lukaMis 15 Report post Posted July 5, 2014 Is this the easiest way to create a solid-colored rectangle? 1.) Drawvar drawnObject;var width = 100 // example;var height = 100 // example;var bmd = game.add.bitmapData(width, height); bmd.ctx.beginPath();bmd.ctx.rect(0, 0, width, height);bmd.ctx.fillStyle = '#ffffff';bmd.ctx.fill();drawnObject = game.add.sprite(game.world.centerX, game.world.centerY, bmd);drawnObject.anchor.setTo(0.5, 0.5); 1 Lypzis reacted to this Share this post Link to post Share on other sites
lewster32 615 Report post Posted July 5, 2014 All Graphics objects by default have a 10 pixel padding. To fix this just do:this.completionSprite.boundsPadding = 0; 3 MichaelD, Jimaginary and globalkeith reacted to this Share this post Link to post Share on other sites