A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: circumference?...

  1. #1
    Senior Member
    Join Date
    Oct 2008
    Posts
    120

    circumference?...

    I'm trying to figure out how to place a bullet mc at the tip of my gun depending on its rotation...?

  2. #2
    Senior Member
    Join Date
    May 2006
    Location
    Manhattan
    Posts
    246
    x = circle's center + cos( angle ) * radius;
    y = circle's center + sin( angle ) * radius;
    where angle is in radians
    ps: circumference is the length of a circle's perimeter.

  3. #3
    Senior Member
    Join Date
    Oct 2008
    Posts
    120
    I've set it up like this...

    ammo._x = _root.gun._x + Math.cos(_root.gun._rotation) * 50;
    ammo._y = _root.gun._y + Math.sin(_root.gun._rotation) * 50;

    and it's not working correctly? what did I do wrong?

    the guns x and y would be the center, and the gun is 50 pixels long so 50 would be the radius right?

  4. #4
    Senior Member
    Join Date
    May 2006
    Location
    Manhattan
    Posts
    246
    MovieClip's _rotation property is in degrees, not radians. So you need to convert to radians:
    radians = degrees * pi / 180

  5. #5
    Senior Member
    Join Date
    Oct 2008
    Posts
    120
    oh snap thats right ty ty!
    works perfectly!

  6. #6
    Member
    Join Date
    Feb 2010
    Posts
    59
    I think tangent would be better to use. and use ATAN2() to get degrees

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