Jump to content

Reuse rendered Phaser.Graphics?


datvm
 Share

Recommended Posts

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

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

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.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...