Jump to content

Interactive Tiles


StefanWeck
 Share

Recommended Posts

Hey everybody,

 

I'm currently making a roguelike game which (ofcourse) features a tilemap. Like so:

 

tweet_new_variation.png

 

I've started this project without PIXI.js and i've recently started converting everything to PIXI. I've got the tilemap, camera and rendering all entities etc working.

But now I have one question. I want to have a mouse over on tiles. If it's a floor tile it has to show a mouse cursor and if there are entities on the tile it has to show a tooltip describing the entity: 

 

tweet_new_ui.png

 

Only question is, do I accomplish this by making every tile interactive and attaching functions to it, or is the best solution to manually track the mouse position and calculate at which tile the user is pointing ( like I did it before ).

 

Thanks in advance,

 

Stefan.

 

Link to comment
Share on other sites

I'd track the mouseposition instead of attaching events to each sprite.

If you attach an event to each sprite, then on each move PIXI will loop through all interactive sprites to figure out if your mouse is over that sprite or not. There's no point in doing that.

Link to comment
Share on other sites

Exactly. Just toggle the visible property of your selector/cursor when needed.

Also, you should use a SpriteBatch for your map and optional create map chunks to reduce the amount of PIXI Sprites.

Your goal should be to use as few sprites as possible for your map to make the rendering faster. That alone will force you to avoid sprite events.

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...