gcardozo Posted July 7, 2017 Share Posted July 7, 2017 Hi, when I create an empty image, I always get a 32x32 pixels image. //As you can see, I'm not passing any 'key' this.img = this.game.add.image(x, y); Then, even after adding a rectangle to my Phaser.Image, its size is still 32x32. this.rect = new Phaser.Graphics(game); this.rect.beginFill(color, alpha); this.rect.drawRect(0, 0, 200, 100); this.rect.endFill(); this.img.addChild(this.rect); And if I manually set the image width and height properties, it would scale the image children. So, how can I create an empty Phaser.Image of a specific size? Edit: I'm not sure this is the right way of doing it, but I guess I could give this image a texture with the size I need. Link to comment Share on other sites More sharing options...
samme Posted July 8, 2017 Share Posted July 8, 2017 When you omit key the object gets the default texture, which is 32 × 32 transparent. this.img = this.game.add.image(x, y); this.img.texture === Phaser.Cache.DEFAULT; //-> true You can make a transparent image of the size you want in your image editor and use that. Also this may work: this.img = this.game.add.image(x, y, this.make.renderTexture(200, 100)); gcardozo and quiphop 2 Link to comment Share on other sites More sharing options...
Skeptron Posted July 10, 2017 Share Posted July 10, 2017 this.game.add.sprite(x, y, ""); Link to comment Share on other sites More sharing options...
Recommended Posts