A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: [HELP] Directions

Threaded View

  1. #1
    An FKer
    Join Date
    Sep 2005
    Location
    Ontario
    Posts
    1,167

    [HELP] Directions

    Hello all you smart folk

    I am currently working on an RPG with a small group and have run into a bit of trouble

    Im not much of a action scripter, which is why Im not the one doing so in this project

    Anyways, my problem relates to the clicking and movement of the Character (I will attach the .fla)


    It works fine and everything, its just that it doesnt do diagonals. It doesnt do it because I dont know how to do the math

    I found this in a tutorial and just remade it using the exact same code , and to put it truthfully, the math makes absolutly NO sense to me

    Which is why im here

    *Attaches .Fla*



    The problem lies within this part of the code :

    if ((newy-_y)<0 and (tg>3*Math.PI/8 or tg<-3*Math.PI/8)) {
    gotoAndStop(3);
    }

    if ((newy-_y)>0 and (tg>3*Math.PI/8 or tg<-3*Math.PI/8)) {
    gotoAndStop(2);
    }

    if ((newx-_x)>0 and (jobbal>Math.cos(3*Math.PI/8))) {
    gotoAndStop(4);
    }

    if ((newx-_x)<0 and (jobbal>Math.cos(3*Math.PI/8))) {
    gotoAndStop(5);
    }



    Basically, it checks where you click the mouse and then gotoandStop's at a frame in the Character movieclip. Each frame is a different direction

    As you can see, there are only 5 directions including stop: Up, Down, Left, Right, but as you can probably guess, it looks a bit awkward on diagonals

    So if anyone could please help me out, it would be greatly appreciated, thanks
    Last edited by Osteel; 05-01-2009 at 02:39 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center