Jump to content

Best way to Dynamically draw Geometric Shape


hyude
 Share

Recommended Posts

Hello.

 

I have currently developing a tile-based puzzle game.

I need to draw block/cell dynamically (the width/height and x/y count can change),

 

What is the best way to achieve this?

From what I have tried, rectangle class only used for debugging, and rendering debug.geom always draw it on top of everything.

 

Another way I can imagine is creating a sprite for block, and draw it in loop, but I still don't know how to achieve this, since there doesnt seem any way to override rendering method of a sprite.

 

Thanks.

Link to comment
Share on other sites

Yes, using Graphics will reduce performance as they have to be redrawn every frame. BitmapData on the other hand is much faster as it's just a texture, the same as using a loaded image. The only performance hit you'll take from using BitmapData is that it's not totally straightforward to use BitmapData to create a texture atlas (which will improve performance greatly if using lots of sprites and webGL) but that's not an insurmountable problem by any means.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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