Line between two objects on different parallax layers

Get help using Construct 2

Post » Thu Oct 22, 2015 4:08 pm

How would one go about creating and maintaining a line between two objects on different layers with different parallax scrolling values?

Currently I'm using code:


System: Every tick -> LineSprite : Set position to Object1 (image point 0)

System : Every tick ->
LineSprite set width to distance(Object1.X, Object1.Y, Object2.X, Object2.Y)
LineSprite set angle to angle(Object1.X, Object1.Y, Object2.X, Object2.Y) degrees


Object 1 and LineSprite are on layer1 (parallax 100,100) while Object2 resides on layer0 (parallax 50,50) When the viewport scrolls the Object1 end of the line stays where supposed to but the Object2 end doesn't. Any ideas how to get this to work and how to adjust the line angle/width to get it to attach to correct Object2 position (even when the layout is scrolling)? Thanks!
B
32
S
9
G
4
Posts: 133
Reputation: 4,350

Post » Thu Oct 22, 2015 4:19 pm

Using these expressions:

LayerToCanvasX(layer, x, y)
LayerToCanvasY(layer, x, y)
Calculate the canvas co-ordinates above a position in layout co-ordinates for a given layer.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Thu Oct 22, 2015 11:36 pm

@LittleStain Thanks, I got closer and the angle is now correct but I can't get the end/width of the line to match with Object2 position. I must have something setup wrong here, can you elaborate a little more on how to implement it?
Here's a capx of my attempt: https://dl.dropboxusercontent.com/u/163 ... rline.capx
B
32
S
9
G
4
Posts: 133
Reputation: 4,350

Post » Wed Aug 24, 2016 9:24 pm

hi @Waltuo , maybe it's too late! but anyway... just add "/ 2" to line width action.

"distance(Object1.Xpos, Object1.Ypos, Object2.Xpos, Object2.Ypos) / 2"

Hope it helps.
B
3
Posts: 1
Reputation: 177


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 17 guests