P4UL Posted July 27, 2016 Share Posted July 27, 2016 Hello! I have a Tilemap and two objects. The first object willl calculate the shortest path to the second one. If the player hits enter, the object will use this path. Before the player will press enter I want to show a preview of the path. How would I do this? I could simply create a new Sprite for every point in the path and set the position to that point. The path will be recalculated very often, so I would permanently destroy the path sprites and recreate them. Is there a better option to achive this? Thanks in advance! Link to comment Share on other sites More sharing options...
tips4design Posted July 27, 2016 Share Posted July 27, 2016 Never recreate sprites that you can re-use. Use sprites pool instead (eg: create 20 sprites for the points and only move them around and show/hide them instead of re-creating them). A better approach might be creating a bitmapData and drawing directly on it using lines and circles. See this: http://gamemechanicexplorer.com/#bullets-5 Link to comment Share on other sites More sharing options...
P4UL Posted July 28, 2016 Author Share Posted July 28, 2016 Thank you very much! I already used a sprite pool for bullets, but I simply forgot that I could use it for other things than bullets. The other approach with the bitmapData seems very good. I think I will use that. Thank you for the link! Link to comment Share on other sites More sharing options...
Recommended Posts