A problem with inner logic

Bugs will be moved here once resolved.

Post » Sun Aug 19, 2012 1:22 pm

link to a project file

Steps:
1)run it
2)move the bottom sprite to a grid cell (for example, (0, 0) cell)
3)delete the last section "System: For each Sprite4..." and reproduce steps 1 and 2
4)compare results

This last section means "replace all the Sprite4 objects with Sprite3 ones without repeating". The previous section "System: For each Sprite4. Sprite4 is not overlapping Sprite2" deletes every Sprite4 object which is not inside the grid.
So some Sprite4 objects are already deleted but the program obviously places extra Sprite3 objects.
B
2
Posts: 4
Reputation: 258

Post » Sun Aug 19, 2012 2:47 pm

When you destroy a sprite it doesn't actually get destroyed until the next top level event. So in your case it will be destroyed at event 17.
B
54
S
28
G
18
Posts: 1,520
Reputation: 24,990

Post » Sun Aug 19, 2012 5:17 pm

do you want to say that it is not a bug and it will never be corrected?
B
2
Posts: 4
Reputation: 258

Post » Sun Aug 19, 2012 6:04 pm

@ramones is right - the 'destroy' action actually means 'flag this instance to be destroyed at the end of the next top-level event', because for various reasons the engine cannot truly destroy an object halfway through an event. So the objects will continue to exist and be looped over after a destroy action in a subevent. Does that explain your problem?

A workaround could be to set a 'destroyed' instance variable on the object, and when destroying an instance also set 'destroyed' to true. Then only loop over objects where 'destroyed' is false.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,518

Post » Sun Aug 19, 2012 7:30 pm

so if it is not a bug then how to replace this code correctly?
B
2
Posts: 4
Reputation: 258

Post » Sun Aug 19, 2012 7:36 pm

@Gargo - did you try the workaround I suggested?
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,518

Post » Sun Aug 19, 2012 9:48 pm

Now I ask about it. As I understand it is such a common problem that some common solutions exist, isn't it?
B
2
Posts: 4
Reputation: 258

Post » Sun Aug 19, 2012 10:52 pm

The implementation of Ashley's workaround using a boolean variable.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,998
Reputation: 57,791

Post » Mon Aug 20, 2012 2:39 pm

Closing since this is difficult to fix in the engine and a workaround has been provided.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,518


Return to Closed bugs

Who is online

Users browsing this forum: Yahoo [Bot] and 2 guests