Jump to content

Best way to draw grid overlays?


grofit
 Share

Recommended Posts

So I am just prototyping something which is more of a level editor where someone can load a tileset, then draw the level, however one of the requirements is being able to show a grid.

 

Now I watched the example of drawing lines but the mere fact it was within a debug namespace didnt really fill me with confidence that this was the best way to solve the problem. I noticed that there is the BitmapData object which seems like it may be a better fit as I can just blit out the lines on that, however as my level size will be:

(level width * tile width) * (level height * tile height)

It felt like making a bitmapdata the size of the entire level could be overkill for it, so is there some best way to be able to achieve this?

 

 

Link to comment
Share on other sites

I guess I can do it so there is only lines over the screen and offset them as the camera moves around, but that aside I am more interested on what is the recommended practice for achieving the grid.

 

From what I have read the only options seem to be making a rect which is slightly smaller then spacing them out, or doing lines however was wondering if there was some other approach

Link to comment
Share on other sites

Unless it needs to dynamically change I would just use a texture. Or a BitmapData with the grid pre-drawn to it and then texture a Sprite with that. It will always be the fastest way. You could also use a TileSprite and then use tilePosition to scroll it as the map moves. This would be fine in WebGL, a bit slower in Canvas.

Link to comment
Share on other sites

Does need to change in edit mode, the user can alter the level size and the tile size as well as change the tilesets being used.

 

Although from what you say I am already looking in the right direction so thanks for the help.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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