How do I draw a line that follows the mouse?

0 favourites
  • 6 posts
From the Asset Store
solution for games like "fruit ninja" and drawing applications
  • Hello,

    I'm trying to make it so that the line will stretch and follow the position of the mouse until it touches another hexagon. The line will then stick itself to the hexagon but still follow the mouse until the button is released. Kind of like how you unlock your phone by connecting the dots.

    Any help will be greatly appreciated!

  • You can use R0J0hound plugin call Canvas and draw path or anything you want. Give credit to R0J0hound if you do use his plugin

  • Thank you so much for replying. I just checked out R0J0's canvas, but I'm not sure if I can use that to achieve what I want.

    I'm trying to do something like this: (sorry they took down my youtube link...)

    Something like the game Line Zeta, Thousand Memories or Pokopang

    Where the line connects from one hexagon to another and links together, but before it does so it follows the mouse/finger.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Add a variable to your line

    On click > Create line

    Left button is pressed & line.variable = 0 > Set line width to distance(Line.X, Line.Y, Mouse.X, Mouse.Y).

    Anything after the mouse on hexagon is doable too, on mouse hovering hexagon > set line.variable to 1 and set line width to distance between line and hexagon, then create another line etc..

  • Too much talking, here is the example capx.

  • Oh my god this seems like exactly what I need! I'll give it a try immediately thank you so much Sisyphus!

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