Animation frame based on mouse position?

Get help using Construct 2

Post » Sun Feb 10, 2013 8:46 pm

I'm trying to change an animation frame based on the mouse's position relative to the object.

I believe I've been through all the events and actions and searched Google multiple times. I just can't find a combination or answer that'll do what I'm looking for.

Here's a couple of frames of my player object:


As you can see, "Set angle toward position" just doesn't cut it
Say the mouse is at an angle of 90 relative to the object, it would show the first picture. And so on...

How would I go about doing something like this?
B
3
Posts: 2
Reputation: 554

Post » Mon Feb 11, 2013 8:16 pm

@Wakey

One non mathematical way of doing it, is to create 4 triangle sprites. One representing North South East West (imagine creating a giant X over the middle of the screen)

Then use

On mouse over "North" set animation to "player north" etc

then make the triangles invisible so you can't see them.

Here's an awesome sketch
http://imgur.com/h1mb2mU

This assumes your player is always in the center of the screen though.justifun2013-02-11 20:20:01
B
50
S
21
G
8
Posts: 844
Reputation: 10,299

Post » Mon Feb 11, 2013 8:22 pm

If the player ISNT in the center of the screen, here's another way of doing it.

create 4 events

mouseAbsolute.X > player. X
AND
mouseAbsolute Y > player.Y

-> set animation player to "north"

MouseAbsoute.X < player.Y
AND
mouseAbsolute.Y < player.Y

set animation player to "south"

etc etc

Make a event check all 4 locations based on the players postion, top left, top right, bottom left, bottom right.

then change the animation based on that.

only 1 will be true at any given time.
B
50
S
21
G
8
Posts: 844
Reputation: 10,299

Post » Mon Feb 11, 2013 8:33 pm

Or You could check if angle between sprite and mouse is between certain value.
ImageImageImageImage
B
140
S
58
G
36
Posts: 2,547
Reputation: 31,170

Post » Mon Feb 11, 2013 8:49 pm

Check out this thread. I think that'll cover what you need.
B
27
S
8
G
8
Posts: 903
Reputation: 8,452


Return to How do I....?

Who is online

Users browsing this forum: Kagubro, Solomon and 32 guests