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.

AppGameKit Classic Chat / Deleting sprites/tweens when you don't know the ID that AGK has assigned to them

Author
Message
Scifictus
9
Years of Service
User Offline
Joined: 7th Feb 2015
Location:
Posted: 15th Feb 2015 18:16
I may have seen this answered on a previous post or somewhere in the AppGameKit reference material but I cannot for the life of me find it again!

If I am creating many sprites/tweens and allowing AppGameKit to assign the IDs (rather than specifying them myself) how to I add a loop to my code that will go through all sprites IDs and, based on my criteria (e.g. the tween has finished playing or the sprite has gone off the screen) delete those sprites/tweens. If I don't know how many IDs AppGameKit has assigned I dont know how to end my For/next loop e.g.

For t = 1 to (what?)
if getspritey(t) > 1080 then delete...
if gettweenplaying(t) = 0 the delete...
next t

- does AppGameKit create IDs using the lowest available ID and therefore as I delete sprites those IDs will be re-used and I can therefore assume that there will not be an ID higher than the total number of sprites on screen?
- I think I read you should run the above loop backwards (form highest ID to lowest) so that sprite IDs arent reshuffled after each deletion?

Obviously I dont want to create a loop that goes through unessecarily high iterations just because I dont know how high the IDs go.

Thanks lovely forum people!
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 15th Feb 2015 20:57
This is the thread you are looking for.

Quidquid latine dictum sit, altum sonatur
Dead Pixel
9
Years of Service
User Offline
Joined: 27th Nov 2014
Location:
Posted: 16th Feb 2015 00:33
Just spotted this thread.....

On page 149 of "Hands On AppGameKit BASIC" the author states that ID's, if assigned automatically, start at 10001.

//******************************
// Coding In BASIC using AppGameKit V2
//******************************
Scifictus
9
Years of Service
User Offline
Joined: 7th Feb 2015
Location:
Posted: 16th Feb 2015 12:49
Ah yes that's the thread I was thinking of - thanks Batvink.

Good to know Dead Pixel - thanks.
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 16th Feb 2015 12:54
Quote: "ID's, if assigned automatically, start at 10001."


It's also very useful that if you delete sprites, the IDs don't get reassigned to future sprites created. This will only happen if you manage to use all 4 billion IDs.

Quidquid latine dictum sit, altum sonatur

Login to post a reply

Server time is: 2024-11-25 17:55:16
Your offset time is: 2024-11-25 17:55:16