Please help with BALL AND CHAIN capx. :(

Get help using Construct 2

Post » Sun Oct 29, 2017 4:52 am

R0J0hound wrote:Fixed end version. Basically pulls one way, minus the last, then pulls the other way.
https://www.dropbox.com/s/ecjsc9mmn509i ... .capx?dl=1


Excellent capxs guys.

I don't know what's happening here:

chain.index*(loopindex("i")?-dir:dir)
particularly the ("i")?-dir:dir part but I'm gonna study this example.
It's impressive how you managed to do it without a second image point for the links as well.
"The intent is to provide subscribers with a sense of pride and accomplishment for unlocking different features...."
B
42
S
18
G
32
Posts: 832
Reputation: 20,807

Post » Sun Oct 29, 2017 4:57 am

A ? B : C is called ternary operator.
It basically means "if A is true, then B, else C"

So this formula reads:
chain.index* (IF loopindex("i")=1 THEN -dir ELSE dir)
Last edited by dop2000 on Sun Oct 29, 2017 5:53 am, edited 1 time in total.
Image

Did I help to fix a problem in your game? You can buy me a cup of coffee :) If you'd like to hire me, please see this post
B
19
S
9
G
158
Posts: 2,386
Reputation: 84,399

Post » Sun Oct 29, 2017 5:51 am

Also to explain why I used that:
Chain.index is the order of the objects in the chain. 0 on one end up to say 10 on the other.
Used with "for each ordered" it will loop over the objects from one end to the other.
We can also make it loop backwards by multiplying chain.index by -1.

I used the "dir" variable to specify what direction to use. In the first capx the direction is chosen so the end being dragged is first.

For the fixed end version it loops twice. Once one direction, then once the other. You could just as well duplicate the loop event and use this instead if that helps.
For each chain ordered chain.index*dir
--- do stuff
For each chain ordered chain.index*-dir
--- do stuff

I used equations to cram it all together. It probably would be more readable utilizing functions. Maybe.
B
101
S
39
G
134
Posts: 5,591
Reputation: 85,520

Post » Sun Oct 29, 2017 6:15 am

dop2000 wrote:A ? B : C is called ternary operator.
It basically means "if A is true, then B, else C"


I see. Thanks for explaining. :D

R0J0hound wrote:For each chain ordered chain.index*dir
--- do stuff
For each chain ordered chain.index*-dir
--- do stuff
I used equations to cram it all together. It probably would be more readable utilizing functions. Maybe.

Nice! I'm learning new stuff everyday!
I was actually going for that approach as well however I did not know how I would be positioning the chainlinks for the second loop using their second image points as reference points.

Thanks again, guys!
"The intent is to provide subscribers with a sense of pride and accomplishment for unlocking different features...."
B
42
S
18
G
32
Posts: 832
Reputation: 20,807

Post » Tue Oct 31, 2017 9:16 pm

dop2000 wrote:A

R0J0hound wrote:Also to explain why I used that:
Chain.index is the order of the objects in the chain. 0 on one end up to say 10 on the other.
Used with "for each ordered" it will loop over the objects from one end to the other.


Hi guys I'm sorry to be revisiting this yet again but would you happen to know a way to create new chain links?

The loop seems to be [for each chain order] using the family.
I'm going to assume The order would be something like: Dot A Link 1,2,3...Link2-Dot B

Newly spawned links seem to stick to the current active Dot and produce a weird effect. How do I spawn a link such that it sequences itself in between all link and link2?
"The intent is to provide subscribers with a sense of pride and accomplishment for unlocking different features...."
B
42
S
18
G
32
Posts: 832
Reputation: 20,807

Post » Tue Oct 31, 2017 11:02 pm

Link2 is purely cosmetic. It always is at the end no matter what.
To add a new link it should be simple as creating a link object and setting the index to where you want it.
So if the front has an index of 0 and the next link has a index of 1 you could give the new one an index of 0.5 to add it to the front.

Index can be any value, just as long one is greater than the previos
B
101
S
39
G
134
Posts: 5,591
Reputation: 85,520

Previous

Return to How do I....?

Who is online

Users browsing this forum: ghzmxls, guannstar and 21 guests