r102 Breaking Change questions?

Discussion and feedback on Construct 2

Post » Sat Sep 08, 2012 7:23 pm

Breaking change: This was actually introduced in an earlier release, but was not changelogged: the way spawned or created objects are picked in subevents has changed. Newly created instances are picked in their own event, but not picked in subsequent "sibling" subevents until the end of the next top-level event. This was done for stability reasons. Post to the forum if you need more information / workarounds.

@Ashley I think this is the one that's breaking my whole game. I don't really understand this change and how to fix my game to work again. Should I create groups or add something to my sub events?

Everything is working perfectly with r99, so should I maybe stay with that, so I don't destroy anything. nemo2012-09-08 19:49:10
B
40
S
5
G
5
Posts: 405
Reputation: 5,657

Post » Sat Sep 08, 2012 8:06 pm

You probably should reorganize your events to take the change into account.

It mostly means that in the event/sub event you're creating/spawning an instance, the newly instance is picked, so the actions are applied to this newly created instance.
But if you add a sub event to the current event, the newly made instance is not picked anymore as it is not created.
You should rather end the event there (the top level event) and make a new event, picking the newly made instance (by UID or whatever...).
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,999
Reputation: 57,793

Post » Sat Sep 08, 2012 8:13 pm

It's easiest to explain with a picture:



Here an object is created in a subevent. (This also applies if an object is spawned using Sprite's 'Spawn an object' action.)

In the subevent it was created in, the created instance is picked and can be used. It is still picked in subevents underneath that. The green area highlights the area the created instance can be used.

However, after that, the instance does not really exist, and cannot be used, until the next top level event (the next event which isn't a subevent to anything else). The next green area shows the next top level event when the instance is finally created.

The area inbetween is subsequent subevents in the same event the object was created. This area is highlighted red, and the instance does not actually exist yet there. So conditions for the sprite placed there will never pick the newly created sprite instance.

The workaround is to try to do everything in the same event - nest the other events beneath the creating event if possible, so everything is moved up in to the green area.

It had to be changed this way because it was unstable to allow objects to be used that way, due to particulars in how the engine works. Some people's projects kept crashing and this change fixed them. Admittedly I did not think this would be too big an issue, especially since Construct Classic had always worked the same way. Still, hopefully once everyone adapts their projects to use the new system it will not be a problem any more.

Edit: another bug is r102 does not count triggers or events in groups as top-level events, which makes it worse. This is fixed in the next build, so it might help fix your project if you use a lot of groups.Ashley2012-09-08 20:15:07
Scirra Founder
B
359
S
214
G
72
Posts: 22,951
Reputation: 178,578

Post » Fri Jul 26, 2013 1:47 pm

This does not seem to work for me. If I create a new ball object for example, then use ball.xx in the action of the same or a sub event, it always acts on all balls, not the one I just created.   As I don't know how to pick the event I just created, I actually do this:
1) have he ball on a special layer, called "templates"
2) have a blank layer called "new"
3) create a new "ball" object on layer "new".
4) use an event condition where I say ball.isOnLayer("new")
5) then in the events actions, do this: ball.setLayer("target")

This seems to work.
B
15
S
5
G
2
Posts: 357
Reputation: 3,691

Post » Fri Jul 26, 2013 2:06 pm

[QUOTE=nutmix] This does not seem to work for me. If I create a new ball object for example, then use ball.xx in the action of the same or a sub event, it always acts on all balls, not the one I just created.   As I don't know how to pick the event I just created, I actually do this:
1) have he ball on a special layer, called "templates"
2) have a blank layer called "new"
3) create a new "ball" object on layer "new".
4) use an event condition where I say ball.isOnLayer("new")
5) then in the events actions, do this: ball.setLayer("target")

This seems to work.[/QUOTE]

@nutmix: Check this capx example you can effectively notice that only the newly created instance is affected by the "set angle" action. This is how it works.

If it doesn't work for you, you're doing something wrong so please post a new thread with a capx so we can give you a hand and please stop bumping old threads.
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,999
Reputation: 57,793


Return to Construct 2 General

Who is online

Users browsing this forum: 99Instances2Go, MatheusCastellar and 7 guests