Picking problem

For questions about using Classic.

Post » Sat Jan 29, 2011 11:53 pm

I'm having a problem with picking. I have an event in which I'm randomly generating a level. There are multiple sub-events and loops. As a final sub-event, I want to change some properties of all objects that were created in the event. Unfortunately, the Construct selection list appears to have filtered out all objects, so the last actions have no effect.

In the referenced CAP file, you can see how I'm creating some sprites and then trying to change them all at the end. The only sprite affected by the changes is the one created in the top-level event. Changing the last sub-event to a foreach loop doesn't work, either.

What can I do to fix this, aside from duplicating the last event in all the individual places where I'm creating a sprite?

[url:1h6orb5w]http://dl.dropbox.com/u/18659416/picking%20problem.cap[/url:1h6orb5w]
B
2
G
3
Posts: 20
Reputation: 890

Post » Sun Jan 30, 2011 12:19 am

When you create an object it becomes the only picked object for the remainder of that event. After that the object cannot be picked until the next tick (or frame).

A way around it is to do the actions on the next tick, or in our case tick 1.

[code:2zpv0m47]+ System: TickCount Equal to 1
-> Sprite: Rotate 90 degrees clockwise
-> Sprite: Set filter to Red
[/code:2zpv0m47]

[url:2zpv0m47]http://dl.dropbox.com/u/5426011/fixed/ex_pick.cap[/url:2zpv0m47]
B
79
S
24
G
54
Posts: 4,746
Reputation: 40,755

Post » Sun Jan 30, 2011 12:46 am

[quote="R0J0hound":19osglkt]When you create an object it becomes the only picked object for the remainder of that event. After that the object cannot be picked until the next tick (or frame).[/quote:19osglkt]

Is this accurate? I thought it was like this:

[quote="Ashley":19osglkt]The way it is, though, is that when you create an object, it doesn't really exist until the end of the next top level event or trigger.[/quote:19osglkt]
B
21
S
6
G
10
Posts: 1,024
Reputation: 7,445

Post » Sun Jan 30, 2011 1:59 am

[quote="R0J0hound":3sjij4qr]When you create an object it becomes the only picked object for the remainder of that event.[/quote:3sjij4qr]

In this context, does event mean the top-level event, or does it also include sub-events?

[quote="R0J0hound":3sjij4qr]After that the object cannot be picked until the next tick (or frame).[/quote:3sjij4qr]

It sounds like this makes what I want to do fundamentally impossible. You simply can't create a bunch of objects in subevents, and pick them all in another subevent later on.

[quote="R0J0hound":3sjij4qr]A way around it is to do the actions on the next tick, or in our case tick 1.[/quote:3sjij4qr]

That sounds like a reasonable solution. I'll try it out.
B
2
G
3
Posts: 20
Reputation: 890

Post » Sun Jan 30, 2011 2:06 am

[quote="PixelRebirth":2w7zvkwe][quote="R0J0hound":2w7zvkwe]When you create an object it becomes the only picked object for the remainder of that event. After that the object cannot be picked until the next tick (or frame).[/quote:2w7zvkwe]

Is this accurate? I thought it was like this:

[quote="Ashley":2w7zvkwe]The way it is, though, is that when you create an object, it doesn't really exist until the end of the next top level event or trigger.[/quote:2w7zvkwe][/quote:2w7zvkwe]
From my experience, it seems to be like ROJOhound says. You can't, for example, access a pv of a newly created sprite until the next tick. I still think, the object is created at the end of the tick, and all you do in the creation event is just buffered.
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

Post » Sun Jan 30, 2011 3:32 am

[quote="tulamide":1d18pjc8][quote="PixelRebirth":1d18pjc8][quote="R0J0hound":1d18pjc8]When you create an object it becomes the only picked object for the remainder of that event. After that the object cannot be picked until the next tick (or frame).[/quote:1d18pjc8]

Is this accurate? I thought it was like this:

[quote="Ashley":1d18pjc8]The way it is, though, is that when you create an object, it doesn't really exist until the end of the next top level event or trigger.[/quote:1d18pjc8][/quote:1d18pjc8]
From my experience, it seems to be like ROJOhound says. You can't, for example, access a pv of a newly created sprite until the next tick. I still think, the object is created at the end of the tick, and all you do in the creation event is just buffered.[/quote:1d18pjc8]

I do think Ashley said what he said for a reason. Look at this overly simplistic example:

[url:1d18pjc8]http://dl.dropbox.com/u/2306601/blinky.cap[/url:1d18pjc8]

When you press X, a Sprite is being created at the center of the screen. But with the current event order, you won't see anything. It's immediately being destroyed by the second event. However if you switch the event order, the sprite briefly appears before being destroyed. Which means it already existed and could be picked before the next tick - according to my very own logic. Otherwise it shouldn't have blinked when you switch the order. Unless something is going on I'm not getting, which is always a good chance. Still Ashley said what he said! :P
B
21
S
6
G
10
Posts: 1,024
Reputation: 7,445

Post » Sun Jan 30, 2011 3:48 am

You can get around this by using a function. Functions are able to make condition checks on newly created objects if called in the same event after the object is created (using remember picked objects - that's important!). Also note if you create two instances of the same object in one event, the first created instance will be deselected upon the creation of the second instance.

Also, PR, what Ashley said is correct. It was changed from what R0J0hound described some versions ago.
Moderator
B
88
S
32
G
33
Posts: 3,005
Reputation: 27,432

Post » Sun Jan 30, 2011 4:08 am

Hey cool,
Thanks PixelRebirth, I was not aware that created objects could be picked in the next toplevel event. That will make my eventing easier than waiting till the next tick. My assumption came by trial and error, but obviously I didn't try everything.

So here's a better solution to the initial problem:
Instead of rotating the objects the next tick, just add another toplevel "Start of Layout" event.

[url:1o9bv4sz]http://dl.dropbox.com/u/5426011/fixed/ex_pick2.cap[/url:1o9bv4sz]

Cheers
B
79
S
24
G
54
Posts: 4,746
Reputation: 40,755

Post » Sun Jan 30, 2011 4:11 am

[code:37vuf9xt]+ System: Start of layout
-> Sprite: Rotate 90 degrees clockwise
-> Sprite: Set filter to
[/code:37vuf9xt]

Nothing wrong with another start of layout, after all events are run in order, even in start of layout.
Speaking of...
From my perspective both Ash, and Rojo are correct.
The second, third, and fourth events are subevents, and have nothing to do with each other.
If the second, and third were somehow picked in the top tier then the 4th would.
But your dealing with multiple instances, and you have to come at it from the left side, or conditional picking of the equation.

Edit:
Rojo beat me to it. :P
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767

Post » Sun Jan 30, 2011 8:48 am

[quote="PixelRebirth":3v5zn9nb]
I do think Ashley said what he said for a reason. Look at this overly simplistic example:

[url:3v5zn9nb]http://dl.dropbox.com/u/2306601/blinky.cap[/url:3v5zn9nb]

When you press X, a Sprite is being created at the center of the screen. But with the current event order, you won't see anything. It's immediately being destroyed by the second event. However if you switch the event order, the sprite briefly appears before being destroyed. Which means it already existed and could be picked before the next tick - according to my very own logic. Otherwise it shouldn't have blinked when you switch the order. Unless something is going on I'm not getting, which is always a good chance. Still Ashley said what he said! :P[/quote:3v5zn9nb]
Thanks for the example :)
I understand the logic and agree with the creation. But, well, why can't I access a pv then until the next tick? Doesn't make sense.

EDIT: All the top level and subevent explanations, they don't make sense. I was following your logic (that I feel is correct, if I can see the object it must exist) and played around. Now look at this example. The sprite is created in a subevent and immediatly exists - but the pv is not accessible. I get a headache :(
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 8 guests