Page 1 of 6

Pick All / Create Bug

PostPosted: Fri Jun 24, 2016 8:22 pm
by Prominent
Problem Description
Created objects aren't picked.

Attach a Capx
https://1drv.ms/u/s!AhHSZHEulqh_gTlThpxipQKQXDNY

Description of Capx
Created objects, and tries to pick them all, then rotate them all

Steps to Reproduce Bug
  • run and see which objects are rotated

Observed Result
Only one Sprite is rotated.

Expected Result
All Sprites should be rotated.

Affected Browsers
  • Chrome: (YES)
  • FireFox: (YES)
  • Internet Explorer: (YES)

Operating System and Service Pack
vista sp2

Construct 2 Version ID
r227

Re: Pick All / Create Bug

PostPosted: Sat Jun 25, 2016 1:42 am
by rexrainbow
It is not a bug. New created instances will not be put into SOL until next tick.
Add system: wait 0 after system: create , then you can pick all instances.

Re: Pick All / Create Bug

PostPosted: Sat Jun 25, 2016 2:52 am
by R0J0hound
They'll be put in the SOL before the next tick. It can be picked in the next top level event.

Re: Pick All / Create Bug

PostPosted: Sat Jun 25, 2016 2:55 am
by Prominent
When you create an object, that object immediately gets picked. If it can be picked immediately after creation, why can't it be picked at any other time?

Re: Pick All / Create Bug

PostPosted: Sat Jun 25, 2016 11:19 am
by R0J0hound
There are three lists internally:
Instance list
New list
Sol list

By default the sol list will be the instance list, which you then filter. When you create an object it's added to the new list and the sol is set to it. The pick all sets the sol to the instance list and since the new list isn't added yet those objects aren't picked. Then at the next "top level" event the new list is merged into the instance list.

You can search the forum for "top level" for some more discussions/explanations of this. In one of the change logs had a fix where before "pick all" would pick the new ones too. This was fixed to prevent cases of infinite loops.

Alternatively the pick by uid can pick objects from the new list. It's the exception to the rule.

Re: Pick All / Create Bug

PostPosted: Sat Jun 25, 2016 5:22 pm
by Prominent
That's weird. Why change that to prevent infinite loops? Users can still create infinite loops. If it was possible for pick all to include new objects, that makes more sense to keep it that way than to have it not pick them.
I want to know the reason against it.

Re: Pick All / Create Bug

PostPosted: Sat Jun 25, 2016 6:20 pm
by R0J0hound
The version this was changed:
https://www.scirra.com/construct2/releases/r102

A discussion about it with input from ashley:
r102-breaking-change-questions_t73647

Re: Pick All / Create Bug

PostPosted: Sat Jun 25, 2016 7:19 pm
by Prominent
That doesn't explain why you can't use Pick All as another sub-event inside the created objects event to include the new objects.
If the issue was new objects being included in events outside the sub-event (the sibling sub-events), then shouldn't it be alright to include the new objects in the nested sub-events ?

Re: Pick All / Create Bug

PostPosted: Sun Jun 26, 2016 12:47 pm
by tunepunk
I had a similar problem calling a function which sorts zOrder after an object was created. The function would sort everything except the created sprite, even though the function picked all. Function is top level event, bug or by design?

On colission
-> Create Sprite
-> call function

function picks all. sorts z-order.
did not work. the newly created object is not sorted with the rest.

On created (new top level event)
-> call function

function picks all. sorts z-order.
did not work. the newly created object is not sorted with the rest.

I can't get the created sprite to sort with the rest of the objects, even after calling a function.
wait 0 works but creates ugly unsorted graphics glitch for a fraction of a secondbefore it's sorted correctly.

Re: Pick All / Create Bug

PostPosted: Sun Jun 26, 2016 6:02 pm
by Prominent
Yes, I noticed that too in my attempt to find a solution to the problem. Functions don't seem to act like top-level events, so they can't select the newly creates objects.
In many cases, using a Wait is not an option, as it disrupts the flow of the program, causing things to become unsynchronized. You then have to create more variables/etc and methods to check when to do things.
If you could pick the newly created objects (perhaps only in the nested sub-events?), it would solve these problems and help make the events simpler/cleaner.