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.

Newcomers AppGameKit Corner / [SOLVED] delete objects of which IDs are stored in an Array

Author
Message
nob
User Offline
Joined: 27th Dec 2019
Location: Reunion Island
Posted: 11th Jan 2020 13:20
hi all,
i try to delete some objects of which IDs are stored in an Array.
The array is declared as Global in the "main.agc" and i call a function in the main loop from my "myFunction.agc" file:



That doesn't work... objects are still there
Could you tell me what is missing?
Thx!

The author of this post has marked a post as an answer.

Go to answer

Scraggle
Moderator
16
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 11th Jan 2020 14:55
This post has been marked by the post author as the answer.
This:

Should be this:

or this:
nob
User Offline
Joined: 27th Dec 2019
Location: Reunion Island
Posted: 11th Jan 2020 15:57
Thanks Scraggle , obviously in this way, now it works
Qugurun
Valued Member
5
Years of Service
User Offline
Joined: 8th Dec 2014
Location: Tyumen, Russia
Posted: 11th Jan 2020 23:48 Edited at: 11th Jan 2020 23:51
You still need to add .remove () or .length=-1.
Or for dim add undim

blink0k
Moderator
7
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 12th Jan 2020 01:41
You also need to decrement the counter (i) after you remove the element
nob
User Offline
Joined: 27th Dec 2019
Location: Reunion Island
Posted: 12th Jan 2020 14:17
Quote: "You also need to decrement the counter (i) after you remove the element"


The counter is decremented in the Scraggle/Qugurun codes, no? ...or i missed something?
Qugurun
Valued Member
5
Years of Service
User Offline
Joined: 8th Dec 2014
Location: Tyumen, Russia
Posted: 12th Jan 2020 15:34
Everything seems fine to me. I don’t know what else needs to be reduced.
Scraggle
Moderator
16
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 12th Jan 2020 16:19
The code is fine. I think Blink has misread what is happening.
Quote: "You also need to decrement the counter (i) after you remove the element"

The element is not being removed, we are just deleting objects pointed to by the element.
blink0k
Moderator
7
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 12th Jan 2020 19:03
Sorry guys, my bad. I thought it was going from 0 to length rather than the other way

Login to post a reply

Server time is: 2020-07-04 14:14:21
Your offset time is: 2020-07-04 14:14:21