A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Element rotate's to direction heading script?

  1. #1
    Junior Member
    Join Date
    Feb 2005
    Posts
    29

    Element rotate's to direction heading script?

    hi i was just wondering is anyone had a script that makes an element rotate to direction its heading? or is it not possible?

    Thx,
    Andy
    Last edited by WiZzkid; 06-15-2005 at 04:54 PM. Reason: added more

  2. #2
    Junior Member
    Join Date
    Jun 2005
    Posts
    9
    I suppose you could do something like:
    (in the starting script Set x1 and y1 to any variable that does not equal myElement.x and myElement.y. This will ensure you don't get any division by 0 errors)


    x2 = x1
    y2 = y1

    x1 = myElement.x
    y1 = myElement.y

    // Using a bit of code from one of blanius' functions:
    myElement.rotation = atan2((x1-x2),(y1-y2))

    Hopefully that should work, I'm not sure if it's entirely what you wanted though.

  3. #3
    Junior Member
    Join Date
    Feb 2005
    Posts
    29
    urrrrm i cant seem to get it to work??? it just does nothing.

    sorry i wasnt to clear in my first post what i mean it should do is , say you have made the spaceship follow the mouse around (note:using velocity NOT:"myElement.x=MouseX"()) . how would i get the spaceship turn around to the direction its heading? there must be a way? i dont know wether thats what the above codes meant to do could someone uppload an example. lol coz im still a n00b at this

    Thx
    Andy

  4. #4
    Senior Member
    Join Date
    May 2005
    Posts
    163
    Check this thread out I think it may be what you are looking for.
    http://www.flashkit.com/board/showthread.php?t=632439

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