StefanWeck Posted August 2, 2014 Share Posted August 2, 2014 Hey everybody, I'm currently making a roguelike game which (ofcourse) features a tilemap. Like so: 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: 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. Quote Link to comment Share on other sites More sharing options...
Sebi Posted August 2, 2014 Share Posted August 2, 2014 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. Quote Link to comment Share on other sites More sharing options...
StefanWeck Posted August 2, 2014 Author Share Posted August 2, 2014 Makes sense, then how would I got about adding the mouse cursor? An Sprite object that I store somewhere and that I keep changing the position of? Quote Link to comment Share on other sites More sharing options...
Sebi Posted August 2, 2014 Share Posted August 2, 2014 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. Quote Link to comment Share on other sites More sharing options...
StefanWeck Posted August 3, 2014 Author Share Posted August 3, 2014 Cool. I'm already using the SpriteBatch for rendering the tilemap and lightmap. Map chunks will be introduced whenever i'll notice performance issues, maps aren't that big now. Thanks! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.