MrSnrub Posted March 14, 2018 Share Posted March 14, 2018 Hi, I am trying to create a sprite whose texture comes from a graphic object, but each time I try to do it I get the missing image (green box with a slash). Could you point out what I'm doing wrong? I have tried the following two ways function create () { var graphics = this.add.graphics(); var color = 0xffff00; var thickness = 2; var alpha = 1; graphics.lineStyle(thickness, color, alpha); graphics.strokeRect(32, 32, 256, 256); graphics.generateTexture("test"); graphics.destroy(); sprite = this.add.sprite(400, 300, this.textures.get("test")); } function create () { var graphics = this.add.graphics(); var color = 0xffff00; var thickness = 2; var alpha = 1; graphics.lineStyle(thickness, color, alpha); graphics.strokeRect(32, 32, 256, 256); var texture = graphics.generateTexture(); graphics.destroy(); sprite = this.add.sprite(400, 300, texture); } Thank you Link to comment Share on other sites More sharing options...
AntonioIsas Posted October 18, 2018 Share Posted October 18, 2018 Hi, Once you register the texture in the manager you just need to call it by its key, In your first example just change the last row for sprite = this.add.sprite(400, 300, "test"); Link to comment Share on other sites More sharing options...
Recommended Posts