How do I stretch a sprite from object to mouse x/y?

0 favourites
  • 5 posts
From the Asset Store
This is a single chapter from the "Construct Starter Kit Collection". It is the Student Workbook for its Workshop.
  • I'd like to stretch an animated sprite /line from an object to the mouse x and y on click but I'm not sure how to go about it.

    Think laser or lightning.

    Thank you!

  • Quickly from the top of my head I think this would work...

    On mouse click, check if the mouses click X value was greater than the objects, if so it means you need to make the object wider, so get the difference between the objects X value and the mouss Click X value and then add that to the width.

    You can do the same for the Y value and change its height accordingly.

    I hope this makes sense, if not I will try and do it later and upload the capx

  • Something like this?

    [attachment=0:1xvyv5sd][/attachment:1xvyv5sd]

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Something like this?

    [attachment=0:qo4h210w][/attachment:qo4h210w]

    Fantastic!

    this is pretty close to what I had in mind.

    For lightning I was thinking about the action to take place on click rather than click release, and I think I can figure that out but how would I make the line stay opaque and follow the mouse while it's in the click down state?

    Imagine you're firing a burning laser and as long as the mouse is clicked down, the laser follows the mouse.

  • If you change the action from "On released" to "Button down" in the example it works like the laser follows the mouse.

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