Picking problem

Forum Home Forum Home > Construct Classic > Construct Classic Discussion > Help & Support using Construct Classic
 Post Reply Post Reply Page  12>
Author
865 Rep
Post Options Post Options   Quote MikeWyatt Quote  Post ReplyReply Direct Link To This Post Topic: Picking problem
    Posted: 29 Jan 2011 at 11:53pm
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]
Back to Top
7,061 Rep
Post Options Post Options   Quote R0J0hound Quote  Post ReplyReply Direct Link To This Post Posted: 30 Jan 2011 at 12:19am
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]
Back to Top
4,019 Rep
Post Options Post Options   Quote PixelRebirth Quote  Post ReplyReply Direct Link To This Post Posted: 30 Jan 2011 at 12:46am
[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]
Back to Top
865 Rep
Post Options Post Options   Quote MikeWyatt Quote  Post ReplyReply Direct Link To This Post Posted: 30 Jan 2011 at 1:59am
[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.
Back to Top
5,270 Rep
Post Options Post Options   Quote tulamide Quote  Post ReplyReply Direct Link To This Post Posted: 30 Jan 2011 at 2:06am
[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.
Back to Top
4,019 Rep
Post Options Post Options   Quote PixelRebirth Quote  Post ReplyReply Direct Link To This Post Posted: 30 Jan 2011 at 3:32am
[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
Back to Top

Moderator
11,948 Rep
Post Options Post Options   Quote Arima Quote  Post ReplyReply Direct Link To This Post Posted: 30 Jan 2011 at 3:48am
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.
Back to Top
7,061 Rep
Post Options Post Options   Quote R0J0hound Quote  Post ReplyReply Direct Link To This Post Posted: 30 Jan 2011 at 4:08am
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
Back to Top
16,524 Rep
Post Options Post Options   Quote newt Quote  Post ReplyReply Direct Link To This Post Posted: 30 Jan 2011 at 4:11am
[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
Back to Top
5,270 Rep
Post Options Post Options   Quote tulamide Quote  Post ReplyReply Direct Link To This Post Posted: 30 Jan 2011 at 8:48am
[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 :(
Back to Top
 Post Reply Post Reply Page  12>

Forum Jump Forum Permissions View Drop Down