Something that's been bugging me (capx)

Discussion and feedback on Construct 2

Post » Wed May 04, 2016 4:47 am

Check out this capx

https://drive.google.com/open?id=0BwvuQqGQSOpMUEoyNE13TEVkdXc

It makes 100 randomly placed squares, then 100 randomly placed circles

then it checks for circles that overlap squares and destroy those circles.

But the check doesn't work unless I wait a bit before checking. Try with the wait event not disabled.

This means Construct is executing the check before it creates the objects, unless I put a pause manually.

Is there a way to force a redraw when it's called? Is there some way I can do this without putting in a pause? If there are nested loops going on this can be a huge pain and prone to mystery bugs with our events.

If I had 2 requests they would be force redraw and a way to break out of a loop or function.
Follow my CZero development on twitter https://twitter.com/CaptainZeroGame
B
66
S
17
G
5
Posts: 172
Reputation: 8,476

Post » Wed May 04, 2016 6:00 am

Intuitively if event A is put below another event B... barring some loop or something, one would think event A would happen AFTER event B.

In Construct, it appears the events kind of happen whenever they want. It seems like the order of actions within a single event happen in order, but this isn't really true either if they have sub events...

I need some way to tame this wild beast.
Follow my CZero development on twitter https://twitter.com/CaptainZeroGame
B
66
S
17
G
5
Posts: 172
Reputation: 8,476

Post » Wed May 04, 2016 6:29 am

r102-breaking-change-questions_p615230?#p615230

For example, if you added another On start of layout event at the top level, it would work. Like so:

Image

Very common gotcha, not documented in the manual at all, but a pretty well known issue. I wish they would add an explanation somewhere in the manual, maybe in the how events works section.
Mistakes were made.
B
54
S
28
G
115
Posts: 1,705
Reputation: 65,083

Post » Wed May 04, 2016 6:35 am

Each for loop runs in the same time, it won't wait for one to finish before starting another.
B
137
S
33
G
17
Posts: 1,560
Reputation: 20,802

Post » Wed May 04, 2016 6:46 am

I'm pretty sure loops run in their entirety, in order, within the tick it is called before the next frame is drawn... unless specifically broken up to run across multiple frames....
Mistakes were made.
B
54
S
28
G
115
Posts: 1,705
Reputation: 65,083

Post » Wed May 04, 2016 6:56 am

glerikud wrote:Each for loop runs in the same time, it won't wait for one to finish before starting another.


Perhaps for after startup which I haven't try out.

But for the rest of the time, my experience is that for loops, they run based on the order from top to down.
B
36
S
18
G
11
Posts: 248
Reputation: 8,694

Post » Wed May 04, 2016 7:01 am

OP.

All objects in Construct 2 need one tick before you can call them outside of their own private subevents after creation.
This is well documented in the official guide which I recommended you to glance through at least once.
I saw your capx and you could just wait 1 tick.
If you don't want them to be seen before elimination, just set all of them as invisible on creation and only make the remainders visible after removal is done.
B
36
S
18
G
11
Posts: 248
Reputation: 8,694

Post » Wed May 04, 2016 7:18 am

Definitely glanced at the official guide once or twice. I'd like to control when a tick happens. Force a tick, if you will. Other engines have a "sync" or "redraw" command for similar reasons. "wait" is tricky if you have nested loops with functions called from them.

For example if you "wait" within a loop the loop will keep going outside the sub event where the wait takes place thus skipping iterations before deciding to execute the actions after the wait within the loop.

For
==>subevent
====>action 1
====>wait 1
====>action 2

it will do the remainder of your loop and action 1s... then do all the action 2s...

Not

do action 1,
wait,
do action 2,
loop

as one might expect from any language.

This is a great feature and it's awesome that it works that way don't get me wrong, but it's not a good substitute for updating when you want it to.
Follow my CZero development on twitter https://twitter.com/CaptainZeroGame
B
66
S
17
G
5
Posts: 172
Reputation: 8,476

Post » Wed May 04, 2016 7:33 am

Rule is this: you can not pick a newly created object in a condition until the next top level event.

R0J0hound documented this in a nice way:
picking-problem_p517685?#p517685
I agree that this should be added to the manual in this way.

The newly created object is a selected object in the actions following the create action though.


So all you got to do is make the pick condition part of a new top level event. This is why a second 'on layout' works.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Wed May 04, 2016 4:19 pm

Since I have you here... Another common problem is, say you want to then pick all the red squares that are overlapping EACH OTHER and take out any so there is only one red square in any spot (without destroying both or all squares in these cases).

What's the best practice for A colliding with A?
Follow my CZero development on twitter https://twitter.com/CaptainZeroGame
B
66
S
17
G
5
Posts: 172
Reputation: 8,476

Next

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 4 guests