hyude Posted October 1, 2014 Share Posted October 1, 2014 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 More sharing options...
lewster32 Posted October 1, 2014 Share Posted October 1, 2014 Either Graphics or BitmapData (which is basically a wrapped HTML5 canvas element) if you want to draw textures that can be used in Sprites and Images will allow you to do this. Link to comment Share on other sites More sharing options...
hyude Posted October 1, 2014 Author Share Posted October 1, 2014 I have read somewhere in this forum that using graphics for sprite texture greatly reduce performance. Is this still true? I am using Phaser version 2.1.1 Link to comment Share on other sites More sharing options...
lewster32 Posted October 1, 2014 Share Posted October 1, 2014 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 More sharing options...
Recommended Posts