datvm Posted August 5, 2015 Share Posted August 5, 2015 Let look at a simple example: I draw a simple circle inside a rectangle. Now I want to draw thousands of them on the screens. Is it possible to reuse the drawn graphics then "clone" them instead of having to draw each? I just moved from LibGdx to this engine, in LibGdx, there is a Pixmap that works similar to a Texture. Is it possible in Phaser? Link to comment Share on other sites More sharing options...
Tom Atom Posted August 6, 2015 Share Posted August 6, 2015 yes, it is possible - render to RenderTexture or to BitmapData. Then use this as texture for your sprites, etc. Link to comment Share on other sites More sharing options...
datvm Posted August 6, 2015 Author Share Posted August 6, 2015 Thank you, I also found this example: http://phaser.io/examples/v2/display/generate-texture-from-graphics Just curious though, the method convert to Texture perfectly. Why do I need BitmapData, is there something better for? And, most the example, the Loader uses a url to load resources. Now that I already have Texture, how can I use it for loading Spritesheet? I mean, my graphics has 2 frames, 1 for Out and 1 for Over for button, but I can't seem to load it? Link to comment Share on other sites More sharing options...
Tom Atom Posted August 6, 2015 Share Posted August 6, 2015 I think that difference is that RenderTexture is primarily WebGL thing while BitmapData is primarily HTML5 thing. For example if using WebGL, then changed BitmapData must be uploaded into GPU while changing RenderTexture is just rendering to non-screen render target on GPU side. On the other hand Phaser has lot of ways of doing something. Then BitmapData will work if WebGL is set as renderer. You can also draw into BitmapData and process individual pixels.If you created both frames on the fly then you will probably have to create frame definitions by hand to. These are created when spriteatlas or spritesheet is loaded. Frame object basicly says, where your frame starts and how big it is. datvm 1 Link to comment Share on other sites More sharing options...
datvm Posted August 7, 2015 Author Share Posted August 7, 2015 Thank you very much! It is a bit of much work, but it does work. Link to comment Share on other sites More sharing options...
Recommended Posts