Create object at last instance in family?

Get help using Construct 2

Post » Tue Feb 14, 2012 6:29 pm

So something like:

System.EveryTick
System.Compare2Values(Distance(?,?)>?)
     -> Create train.

But I dont get what im comparing.
B
29
S
12
G
7
Posts: 740
Reputation: 7,849

Post » Tue Feb 14, 2012 6:36 pm

No worries, I got yer back.

http://db.tt/Sz5JgAG3

In the "Train - Pick furthest from (0,0)" event, I added, "Train - X is less than (scrollx + WindowWidth/2) + 100)". That intimidating expression, "scrollx + WindowWidth/2", just means the edge of the screen, since scrollx is the center and WindowWidth/2 is, well, half of the window's width!

So if the last train is within 100 pixels of the edge of the screen (but still OFF screen), create the new train car. Seems to work right now, but like I said, it might not work once it gets faster and faster. If it doesn't, just change that "+100" to something bigger, like 500.
B
20
S
9
G
6
Posts: 607
Reputation: 6,112

Post » Tue Feb 14, 2012 6:43 pm

Thanks!!!!! I had a play with changing the speed, add a event to add 1 to speed, like on click or something, It holds up pretty well hurts your eyes though.

But thanks!
B
29
S
12
G
7
Posts: 740
Reputation: 7,849

Post » Tue Feb 14, 2012 6:51 pm

Haha no problem man.
B
20
S
9
G
6
Posts: 607
Reputation: 6,112

Post » Tue Feb 14, 2012 7:02 pm

just keep a gloabal variable called 'lastCar' and everytime you spawn a new 'train' set this variable to train.UID

then

+train.UID = lastCar
+train.X+train.Width/2 < windowidth+50
   -> spawn a new train
   -> lastCar = train.UID
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Tue Feb 14, 2012 8:39 pm

@Yann thanks for this, but it really confused me. Can I see it in a example please? Thanks.
B
29
S
12
G
7
Posts: 740
Reputation: 7,849

Previous

Return to How do I....?

Who is online

Users browsing this forum: lemo, theosciandra and 26 guests