A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: rotation problem

  1. #1
    Member
    Join Date
    Jun 2011
    Posts
    85

    rotation problem

    Hi,

    this problem drives me crazy and I hope someone can help me out with this:

    I got an object (called tempEnemy) which is flying around and shooting.
    The problem is that I can't keep the value tempEnemy.rotateTo positive, i.e.
    it shall be between 0 and 359 degrees. Currently rotateTo ranges from:
    rotateTo < 0 (bug) && rotateTo > 0 && rotateTo > 359 (bug).

    As mentionend before I want rotateTo between 0 and 359 degrees.

    Can someone help me out with this problem please? I'm very poor in trig…

    Code:
    tempEnemy.dX = tempEnemy.destX - tempEnemy.x;
    tempEnemy.dY = tempEnemy.destY - tempEnemy.y;
    	
    //I added 180 because my tempEnemy object was looking and shooting to the wrong direction
    tempEnemy.rotateTo = (toDegrees(getRadians(tempEnemy.dX, tempEnemy.dY))) + 180;	
    						
    if (tempEnemy.rotateTo > tempEnemy.frame + 180) tempEnemy.rotateTo -= 360;
    if (tempEnemy.rotateTo < tempEnemy.frame - 180) tempEnemy.rotateTo += 360;
    													
    tempEnemy.incFrame = int((tempEnemy.rotateTo - tempEnemy.frame) / tempEnemy.rotateSpeed);

  2. #2
    Senior Member
    Join Date
    Mar 2011
    Location
    Riverside ish...
    Posts
    173
    shouldent it be 1 and 360 degrees?

    and if not then you need

    rotateTo >= 0 && rotateTo <= 359 (bug).

    I would assume...

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