Mouse Click movement

Get help using Construct 2

Post » Fri Nov 29, 2013 6:52 pm

Hi,

How do I make a sprite move to mouse click and it's animation change relative to mouse position (like the Lucas Arts point and click games)?
I already read the Mouse Click on How-To section, but I that didn't understood...

Thanks!
B
5
S
1
Posts: 11
Reputation: 397

Post » Fri Nov 29, 2013 7:18 pm

There is a move to mouse example when you click new project in Construct 2, but you could also use the third party plugin MoveTo you can find in the plugin section of this forum. A third way is using lerp to interpolate between the two positions, but this takes some coding to figure out, so because you seem to be new to construct I would recommend option one or two..

Because you are referring to lucasarts you probably want to scale the sprite too.

Here's a simple example of how to do that:
index.html

And here's the capx
distance-scale.capx

I've used scale, but you could also use width and height, size..LittleStain2013-11-29 19:19:06
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 » Fri Nov 29, 2013 8:14 pm

LittleStain, thanks for your help!
I saw the move to mouse example in Construct 2 and it's very easy , but how do I make the sprite changes it animation relative do mouse position?
Many thanks for your help!!!
B
5
S
1
Posts: 11
Reputation: 397

Post » Fri Nov 29, 2013 8:31 pm

compare the mouse position to the player position.

if you really want to rotate the sprite just set it's angle : angle(sprite.x,sprite.y,mouse.x,mouse.y)

if you want to mirror the sprite depending on mouse.x

system compare two values: mouse.x > player.x

if you only want to do it while moving add a condition for is moving and set the animation based on the destination.

Everything is possible, but because it's unclear to me what you are expecting I'll leave it at these three examples.
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 » Fri Nov 29, 2013 8:42 pm

Well, that should help. Thanks!
Sorry if I was unclear in my explanation, 'cause I want to archive someting like LucasArts character movement, in other words, the sprites has animations for it's front, back and side view.
But thanks again, you really helped me! :-)
B
5
S
1
Posts: 11
Reputation: 397

Post » Fri Nov 29, 2013 8:49 pm

you could set the animations based on angle of movement.

if angle is between 45 and 135 set animation to front.
if angle is between 135 and 225 set animation to side and set mirrored..
etcetera..
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 » Fri Nov 29, 2013 9:00 pm

Thank's!!!
You really really helped!!!
B
5
S
1
Posts: 11
Reputation: 397


Return to How do I....?

Who is online

Users browsing this forum: Lancifer, Sup with that? and 65 guests