GreatBigBore Posted October 20, 2016 Share Posted October 20, 2016 I have a pool of 500 sprites I created with createMultiple(). They're food for my main characters. When the character eats a piece of food, another piece appears in a random location. Or, that's the idea. When the character eats the food, I kill the food sprite and choose a new, random location, but then reviving it is problematic. They behave perfectly when I first bring them into the world, but I revive them, they don't go where I told them to. I'm setting the body position and the sprite position, with no luck. Not only does it go to the wrong place, the vast majority of the time it goes to the world boundary (top and left, never bottom and right -- no idea what that means), so I have a bunch of food lined on the top and left sides of my screen. I'm certain I'm doing something wrong, but I have no idea what. Anyone have any advice? Wild guesses? Link to comment Share on other sites More sharing options...
samme Posted October 20, 2016 Share Posted October 20, 2016 Use sprite.reset() instead of revive? Link to comment Share on other sites More sharing options...
GreatBigBore Posted October 20, 2016 Author Share Posted October 20, 2016 1 minute ago, samme said: Use sprite.reset() instead of revive? Will try that. Also, I realized that I'm killing sprites and reviving them on the same update cycle. I wondered if that might be a problem, so I changed the revive code to wait a couple of ticks, and problem solved. But I'll try reset too -- I might learn something. Thanks much. Link to comment Share on other sites More sharing options...
GreatBigBore Posted October 20, 2016 Author Share Posted October 20, 2016 I take it back; my solution didn't work. But reset seems promising. My code doesn't like it, so I'll have to make some adjustments, but it seems promising. Thanks! Link to comment Share on other sites More sharing options...
Recommended Posts