Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8302285
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T17:15:05+00:00 2026-06-08T17:15:05+00:00

I’m creating a small multiplayer game and I am trying to find how to

  • 0

I’m creating a small multiplayer game and I am trying to find how to get the direction the mouse is compared to where the character is…

For example, if the Character is at Point A, I would like the direction the character is facing to change so it is facing the direction at where the mouse is.

I’ve created the direction movieclips for my character by following as a guide:

degrees

I’ve tried numerous online code/suggestions/howtos and none of them work for me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T17:15:07+00:00Added an answer on June 8, 2026 at 5:15 pm

    You can use a function like this to determine the degree angle:

    public static function polarAngle(point:Point, center:Point=null):Number
    {
        if (!center)
            center = new Point(0, 0);
    
        var degrees:Number = Geometry.rad2deg(Math.atan2(point.y - center.y, point.x - center.x));
    
        if (degrees < 0)
            degrees += 360;
    
        return degrees;
    }
    

    Using this function, point is the point of the mouse in comparison to center which is the registration point or center of your character.

    So, this can be called such as:

    var angle:Number = polarAngle(new Point(mouseX, mouseY),
                                  new Point(character.x, character.y));
    

    I would recommend using Flash native coordinate system – values from 0 to 180 represent clockwise rotation; values from 0 to -180 represent counterclockwise rotation.

    polar

    Per translating these to a cardinal direction system, there’s probably elegant algorithms such as using the dot product; however, you could brute force:

    if ((angle < 22.5) || (angle > 337.5))
        return "e";
    if (angle < 67.5)
        return "se";
    if (angle < 112.5)
        return "s";
    if (angle < 157.5)
        return "sw";
    if (angle < 202.5)
        return "w";
    if (angle < 247.5)
        return "nw";
    if (angle < 292.5)
        return "n";
    if (angle < 337.5)
        return "ne";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I would like to count the length of a string with PHP. The string
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I am trying to render a haml file in a javascript response like so:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.