Jump to content

Revived sprites not going where I told them to go?


GreatBigBore
 Share

Recommended Posts

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

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

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