d0nkeykong Posted December 8, 2014 Share Posted December 8, 2014 How can I set the bounds of an graphics object that is added as a child to a sprite?When I check the height, it is always 32.BigButton = function ( game, x, y, width, cornerRadius, label ) { var width = width; var height = 40; var x = x; var y = y; var radius = 6; var padding = 20; var self = this; Phaser.Sprite.call(this, game, 0, 0); // Create background var graphics = game.make.graphics(0, 0); // Add text var style = { font: "18px din_lightregular", fill: "#ffffff", align: "center"}; var text = new Phaser.Text(game, x, y, label, style); // Position relative to x/y text.x = x + width / 2 - text.width / 2; text.y = y + height / 2 - text.height / 2; height = text.height + padding; // draw the rounded rectangle graphics.beginFill(0x662D91); graphics.drawRoundedRect(x, y, width, height, cornerRadius); graphics.endFill(); // Add graphics and text to sprite this.addChild(graphics); this.addChild(text); game.add.existing(this);};BigButton.prototype = Object.create(Phaser.Sprite.prototype);BigButton.prototype.constructor = BigButton;Thanks in advance. Link to comment Share on other sites More sharing options...
Recommended Posts