[r100/101] can't pick object

Bugs will be moved here once resolved.

Post » Fri Sep 07, 2012 12:00 am

@Ashley
Wait, now I'm confused. Does this mean that the subsequent set variable call on ObjA is not going to correctly pick the newly spawned ObjA?
Event 1
-- Spawn ObjA
-- Set ObjA.MyVal = 1

What about this one:
Event 1
-- Spawn ObjA (Instance1)
-- Spawn ObjA (Instance2)
-- Event 2
-- -- Use ObjA

I'm not doing explicit PICK calls, I'm just trying to use the current SOL. On Event 2, I would expect ObjA SOL collection to only contain Instance2 since it was the latest one. Is that correct?

You mentioned that this is how it worked on Construct Classic but I really feel like this is an architecture issue that's going to happen again and again. Combined with the fact that objects of the same type cannot spawn another instance of themselves and I feel like conditional logic is going to get so messy from having to workaround these problems.

Thanks,
countofquad
B
4
Posts: 10
Reputation: 320

Post » Fri Sep 07, 2012 12:12 am

@countofquad - both your examples work correctly and the same they used to. It is only "sibling" subevents that act differently now.

You can spawn objects of the same type, but they aren't picked. It should be easy to work around using system's 'create object' instead!
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,600

Post » Sun Sep 09, 2012 12:19 am




@Ashley: That's a relief then. But what about this?

The highlighted command seems to fail, even though both Cloud and RainCloud belong to CloudFamily, I even changed it to be explicitly Cloud->SetOpacity and it still failed.

I would have expected CloudFamily SOL to be the last created instance of a sprite belonging to that family.

If this is intentional, that's really unfortunate, it seems like I'm going to have to setup lots of duplicate code in each branch.

Please advise,

Thanks!
B
4
Posts: 10
Reputation: 320

Post » Sun Sep 09, 2012 1:39 am

@countofquad - you can use the family's 'On created' trigger there to avoid code duplication.Ashley2012-09-09 01:39:49
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,600

Post » Sun Sep 09, 2012 1:47 am

@Ashley,

Thanks, I'm aware of that but the problem is that we're not guaranteed code order unless I purposely put the Event On Creation code at the bottom of the event sheet otherwise I'd have to wait for the game-loop to repeat.

Additionally, I have lots of other previously picked SOL lists for other objects which happens in this event branch code, by the way it gets to the On Event Creation which is a top-most event, all of my SOL lists are no longer guaranteed to be the same.
B
4
Posts: 10
Reputation: 320

Post » Sun Sep 09, 2012 3:24 am

What do you mean about code order? The trigger is fired inside the 'create object' action, the position of the trigger doesn't matter.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,600

Post » Sun Sep 09, 2012 5:24 pm

@Ashley:
Hmm, I think maybe an example would help clarify my question. My actual code is more complex than this, so I'm simplifying for purposes of this post.

Let's say you had the following code:
Line 1: EVENT 1
Line 2: -- Sub Event A
Line 3: -- -- Create Object A
Line 4: -- -- Do some stuff
Line 5: -- -- Create Object B
Line 6: -- -- Do some stuff

[snip]

Line 100-105: On Created Object A Event Code
Line 106-111: On Created Object B Event Code

What does the actual execution order look like for this?

Does it go:
Line 1
Line 2
Line 3 (Create Object A)
Line 100-105: (On created Object A Trigger event code)
Line 4
Line 5 (Create Object B)
Line 106-111: (On created Object B Trigger event code)
Line 6

I read this in the manual concerning triggers:
"Rather than running once per tick, this event simply runs (or "fires") upon something actually happening. In this case, the event runs when the user hits the Spacebar key on the keyboard. It is never checked any other time. Since triggers run upon an event happening, they aren't checked in top-to-bottom order like other events. This means the ordering of triggers relative to other events is not important (except relative to other triggers of the same type, since triggers still fire top-to-bottom)."

The reason that I'm concerned is what would happen if Object A's OnCreated code contained a Spawn Sprite statement for SpriteC. Would SpriteC be in the SOL at the point of Line 4?


Thanks,
-- countofquad
B
4
Posts: 10
Reputation: 320

Post » Sun Sep 09, 2012 6:01 pm

Well, I made a sample for another post, but it maybe can help in anything, maybe..

http://www.scirra.com/arcade/example/1837/dealing-with-instance-variables
ImageImageImageImageImageImage
B
93
S
20
G
12
Posts: 1,212
Reputation: 18,482

Post » Sun Sep 09, 2012 6:25 pm

@countofquad
In regard to this Q:
[quote]The reason that I'm concerned is what would happen if Object A's OnCreated code contained a Spawn Sprite statement for SpriteC. Would SpriteC be in the SOL at the point of Line 4?
[/quote]
SpriteC would not be in the SOL. The "on created" trigger only has the newly created object picked. It does not effect the SOL of the event it was created from.
B
79
S
24
G
54
Posts: 4,747
Reputation: 40,757

Post » Sun Sep 09, 2012 9:55 pm

@countofquad - your outline is correct, it will trigger 'on created' during the 'create object' action and the trigger finishes before it moves on to the next action. The 'On created' event does not affect the other event's SOL at all. Events in Construct 2 pick in isolation and it is not possible for one event to change another event's picked instances.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,600

PreviousNext

Return to Closed bugs

Who is online

Users browsing this forum: No registered users and 5 guests