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

Get help using Construct 2

Post » Thu Oct 02, 2014 9:50 pm

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!
B
12
S
4
G
2
Posts: 132
Reputation: 1,749

Post » Thu Oct 02, 2014 9:55 pm

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
B
11
S
2
G
1
Posts: 68
Reputation: 777

Post » Thu Oct 02, 2014 11:38 pm

Something like this?

lazerline.capx
You do not have the required permissions to view the files attached to this post.
B
46
S
23
G
7
Posts: 459
Reputation: 6,763

Post » Thu Oct 02, 2014 11:57 pm

Minor wrote:Something like this?

lazerline.capx


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.
B
12
S
4
G
2
Posts: 132
Reputation: 1,749

Post » Fri Oct 03, 2014 11:00 am

If you change the action from "On released" to "Button down" in the example it works like the laser follows the mouse.
B
46
S
23
G
7
Posts: 459
Reputation: 6,763


Return to How do I....?

Who is online

Users browsing this forum: brunopalermo, Nicolas951, tarek2 and 14 guests