Jump to content

Show preview of calculated path


P4UL
 Share

Recommended Posts

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

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

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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