markp Posted March 31, 2014 Share Posted March 31, 2014 I have a graphics object that I use to draw a filled square with a thick border. I can create a texture using this graphics object and generateTexture() method so that I can create square sprites. I needed to add some dynamic text layered onto the sprite so I just started with a group, added the sprite for the square and then added text. The result is text on top of the square. If I create say 100 of these groups my FPS on my test Nexus 7 is down at about 5fps. Pretty low so I thought I'd just see the effect of replacing the contents of the group with a single sprite created from a single image. I used the mushroom2.png from the example assets and achieved 60fps on the Nexus which is awesome. My conclusion is that my method of creating my dynamic square sprite with a layered piece of dynamic text in a group is not optimal for the rendering and that a single sprite would be optimal. So I have 2 questions really: 1. Can I draw a filled-in square and write a little text somehow to create a single texture in the preload method of my stage? 2. If I can create a texture, is it possible to load the texture at runtime from the variable holding the texture reference as opposed to using a url? Link to comment Share on other sites More sharing options...
markp Posted April 2, 2014 Author Share Posted April 2, 2014 I solved my issue by just using a bitmapData which exposes its own underlying canvas. I can do whatever graphics and text I want on this canvas. Loading the image drawn on the canvas is simply a case of calling the canvase method toDataUrl() and passing the return value to the second parameter of game.load.image. Link to comment Share on other sites More sharing options...
Recommended Posts