Problem with picking and destroy in function

Discussion and feedback on Construct 2

Post » Tue Jan 07, 2014 4:58 am

Hello,

I stomped on something weird..

I do in a function..

+ Pick All ObjectA.. Destroy..

Then somewhere after i do..

For Each ObjectA.. and it still find something in the loop.. why ?

It is because the object is kept in memory before the next tick ? I expected that the loop find nothing since i ordered to destroy all of them before that event. It seem to happen only in functions.

Here a screen... in a mini sample.

http://www.mediafire.com/view/ivqiw8x4yjcc3le/Bug.png

Here a demo..

http://www.mediafire.com/download/c2pva1vo43bxbfh/PickingBugWithFunctions.capx

Thanks!Rushino2014-01-07 05:33:15
B
16
S
5
G
1
Posts: 190
Reputation: 2,489

Post » Tue Jan 07, 2014 6:00 am

B
11
S
2
G
1
Posts: 202
Reputation: 1,580

Post » Tue Jan 07, 2014 6:02 am

Yeah seem like construct 2 haven't finished destroying them when the for each loop is reach. I have put a wait to fix it.. but is there another way to fix that ? problem with the wait is that its only apply to next action.Rushino2014-01-07 06:02:43
B
16
S
5
G
1
Posts: 190
Reputation: 2,489

Post » Tue Jan 07, 2014 9:07 am

It's that way on purpose. So that you can still do all the maintenance on the object you destroyed, like access the instance variables, spawn an explosion at one of it's image points, or a variety of other things.

So usually it's a good thing.
B
239
S
62
G
33
Posts: 903
Reputation: 40,562

Post » Wed Jan 08, 2014 4:16 am

Alright. That increase my understanding of Construct 2 at the same time. Hehe. I have been able to avoid using wait.. i just had to put a flag telling the app that in the next tick.. do the rest of the operations. So this enable to destroy in the first set and then do other stuff with the new instances.

Thanks for you guys help.
B
16
S
5
G
1
Posts: 190
Reputation: 2,489


Return to Construct 2 General

Who is online

Users browsing this forum: PavleNikolic and 16 guests