How do I give a sprite different animations based on the angle position of the mouse

Not favoritedFavorited Favorited 0 favourites
  • 4 posts
From the Asset Store
Cute cartoon girl character with Walk, Jump, and Idle animations for 2D games.
  • i have this project on making some type of top down shooter. and for the player there are 4 main animations , based on the angle position of the mouse against the player. meaning that there is a certain animation for the sprite based on the position of the mouse.

    so that:

    animation 1 : if the mouse is at a 45-135 angle of the sprite

    animation 2 : if the mouse is at a 135-225 angle of the sprite

    animation 3 : if the mouse is at a 225-315 angle of the sprite

    animation 4 : if the mouse is at a 315-45 angle of the sprite

    please insert image if possible.

    i'm sorry if it is hard to understand.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Given the image in the first post, moved to the Construct 2 How Do I forum.

  • You can do it as follows:

    I added an instance variable called "direction" to store the angle from the sprite to the mouse, then

    used a chain of conditional operators (Is statement A true ? If so do X : else is statement B true ? If so do Y : else to Z) to set the animation based on that value.

    One thing to note, 0 degrees points right, not up.

    EDIT: Can't get the image of the events to display, here's the capx:

    dropbox.com/s/2nnpw8v2w9c1guw/topdownDirection.capx

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