d13 Posted February 7, 2014 Share Posted February 7, 2014 Here's the setup: I have an integer array full of gid (tileset grid id numbers).Each of those gid numbers represents a single kind of item.I have nameless sprites that represent these items on the screen.For example, there might be ten sprites, and all have the gid number, "5", in the array Ok, got it? Cool!Then my question is this: If I detect a collision with one of those gid numbers in the array, how can I link it back to the specific sprite on the screen?For example, I know I'm hitting a sprite with gid of "5", but I don't know which specific sprite that is. I've thought about giving sprites an "index" property to track this, but it seems sort of messy to do that.... but then again, maybe it's the best way?Or, I could reverse look-up each sprite's xy coordinate to find its matching array index number... but maybe that's too much extra overhead?I also don't want to add more complexity by replacing the integer array with an array of sprite objects. I'm testing a few approaches, but any clever insights from any of you smart people would be most welcome! - d13. Quote Link to comment Share on other sites More sharing options...
d13 Posted February 13, 2014 Author Share Posted February 13, 2014 ... No worries, solved my own problem!The best way is just to track the sprite's index position on a map array.Once I've got that it's easy to work out everything else. 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.