Line between two objects on different parallax layers

0 favourites
  • 4 posts
From the Asset Store
solution for games like "fruit ninja" and drawing applications
  • 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!

  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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: ... rline.capx

  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)