Possible Bug when referencing "In Layout" Objects

Discussion and feedback on Construct 2

Post » Thu Mar 19, 2015 8:12 pm

I have run into a rather annoying problem.

I have a series of objects, which are in the family buildings.

I run an event so that | on start of layout & for each "buildings" >> add 1 to count_waypoint | this returns 14

There are absolutely no other references to count_waypoint, and the system only shows 7 objects total for the family "buildings"

When I switch the target family to another family "buttons_UI" which has 5 objects, count_waypoint returns 5

I have deduced, by switching the family and switching the objects within the family around, that the problem is only occuring for objects that originally start on the screen.

all building objects begin in the layout, while buttons_UI is loaded from a different layout.

** even weirder... originally this was set up to spawn a waypoint at each building, and set an instance variable (index) to count_waypoint when spawned.
However the index variables for these waypoints began at 8, so the event was running 7 times (all while adding 1 to counts_waypoint) without spawning a single waypoint. In the end there were 7 waypoints, 7 "buildings", and count_waypoint = 14....

I have had several other developers look at this, and no one can find the answer. I replicated the events in a separate project and it works fine.


Anyone know what is going on?
B
7
S
1
Posts: 15
Reputation: 482

Post » Fri Mar 20, 2015 3:04 pm

Is there a global layer involved ?
Or global objects ?


Perhaps make a small example capx with the problem ...
Who dares wins
B
56
S
16
G
21
Posts: 1,875
Reputation: 19,406

Post » Fri Mar 20, 2015 4:21 pm

Try yourfamilyname.Count rather than the for each.
If it returns 14 then you have 14 objects at that time.
Image ImageImage
B
166
S
49
G
154
Posts: 8,103
Reputation: 100,227

Post » Thu Apr 09, 2015 5:47 pm

I found the problem. I was on start of layout, going to another layout to load Global UI elements. This was causing the initial event to run, then going to the UI layout (destroying the initial objects) and then going back to the game layout and restarting the "on start of layout" event with the global variable maintaining the value from the first event trigger.
B
7
S
1
Posts: 15
Reputation: 482


Return to Construct 2 General

Who is online

Users browsing this forum: repkino and 6 guests