Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Removing a Sprite Completely  (Read 2597 times)

0 Members and 1 Guest are viewing this topic.

rojan_neo

  • Newbie
  • *
  • Posts: 28
    • View Profile
    • http://makeagame.tumblr.com
Removing a Sprite Completely
« on: August 23, 2011, 05:22:58 pm »
I have a condition where the player collects a sprite and then a message pops up that the sprite has been collected. I have a variable keeping track if the sprite has been collected. I draw the sprite on screen only if the sprite is not collected. I check collision with the sprite and if it collided then I set the variable flag as true and the sprite is not drawn on screen.... BUT when I move the player to the previous location of the sprite I still get the pop up message even if the sprite is not there.
So Is there any way I can completely remove the sprite from my game??
I am using the collision code provided in the github page...

Thanks for your attention!!!   :)

Disch

  • Full Member
  • ***
  • Posts: 220
    • View Profile
Removing a Sprite Completely
« Reply #1 on: August 23, 2011, 08:43:40 pm »
Quote
I have a variable keeping track if the sprite has been collected. I draw the sprite on screen only if the sprite is not collected. I check collision with the sprite and if it collided then I set the variable flag as true and the sprite is not drawn on screen


From what you describe, this should work.  If the variable indicates the object no longer exists, then it wont' exist.  The only way it can come back is if you change that variable to bring it back.

I'd need to see some code in order to spot the actual problem.

Jove

  • Full Member
  • ***
  • Posts: 114
    • View Profile
    • http://www.jestofevekites.com/
Removing a Sprite Completely
« Reply #2 on: August 23, 2011, 10:34:08 pm »
Sure you're not still checking collisions after it has been hit?
Not drawing doesn't necessarily mean no collision detect.

For example, I have a variable in my renderer 'bool IsVisible'. It allows me to switch on/off the sprite's rendering for rapid flickering effects, but it's still there in every sense.
{much better code}