Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

2D All the way! / Deleting and recreating sprites

Author
Message
MarkE
20
Years of Service
User Offline
Joined: 1st Apr 2006
Location:
Posted: 1st Apr 2006 09:16
Hi,

I have use the "sprite exist()" function to control sprite movement on the screen.
eg if sprite exist(int) = 1
sprite int, sprite x(int) + 10, sprite y(int),image_numer
endif
I have used "delete sprite" to remove the sprite from the screen after a collision. however I then wish to reuse the sprite again. It displays OK but it will not move because "sprite exist()" returns 0 even though the sprite is displayed on the screen.

How can I reset this value so that "sprite exist()" will return 1?
Zergei
21
Years of Service
User Offline
Joined: 9th Feb 2005
Location: Everywhere
Posted: 1st Apr 2006 16:35 Edited at: 1st Apr 2006 16:36
Instead of deleting the sprite, try hidding it. The command is "hide sprite", and "show sprite" tos how it again.
MarkE
20
Years of Service
User Offline
Joined: 1st Apr 2006
Location:
Posted: 3rd Apr 2006 15:10
I have tried using hide sprite and show but the sprite still exists and still moves around the screen. This is using up cpu time on unnecessary processes.

Is there any way to overload existing functions or create new functions that can access the private attributes of the sprite class?

If so, how, because I could use a sprite hidden() function that returns one if the sprite is hidden. thanks
X Trade
22
Years of Service
User Offline
Joined: 19th Feb 2004
Location: near bristol, UK
Posted: 10th Apr 2006 03:51
sounds like a bug, surly - if the sprite is deleted and re-created... then surly there is a new sprite and thus it exists..

personally i do think there should be a way to find hidden objects/sprites (sprite hidden()), but there isn't unfortunately..

one simple way around this is to use an array, e.g.:



obviously, a similar technique could be applied to deleting sprites if you wish

www.AoFP.co.uk
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 10th Apr 2006 11:27
You could flip them or mirror them, and then hide them. Sounds odd, but then you could ignore all the flipped, or mirrored sprites, because there is a check for this situation.

Login to post a reply

Server time is: 2026-07-01 21:22:24
Your offset time is: 2026-07-01 21:22:24