A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: rotation help!!!

  1. #1
    Member
    Join Date
    Feb 2005
    Location
    copenhagen
    Posts
    72

    rotation help!!!

    hi i have a little problem ive spent a couple of hours on

    i have a stick id like to drag and rotate. ive followed a nice tutorial for it, and it works fine but i only want to rotate my stick 45 degrees when i click it. the tutorial i followed only alows my to rotate 180 degrees ??

    this is the code ive used

    Code:
    handle.grip.onPress = function() {
    
    	handle.onMouseMove = function() {
    
    		var angle = Math.atan2(this._parent._ymouse-this._y, this._parent._xmouse-this._x);
    
    		this._rotation = angle*180/Math.PI;
    		this.grip._rotation = -this._rotation;
    	};
    };
    handle.onMouseUp = function() {
    
    	if (this.onMouseMove) {
    		delete this.onMouseMove;
    	}
    };
    please help my i realy would like this to work!!
    - - - - - - - -

  2. #2
    Member
    Join Date
    Feb 2005
    Location
    copenhagen
    Posts
    72
    nobody ?
    - - - - - - - -

  3. #3
    Senior Member Shnitzel's Avatar
    Join Date
    May 2007
    Location
    IL
    Posts
    130
    You want it to rotate only until it reaches 45 degrees?
    Code:
    if (angle > Math.PI/4) { // Math.PI/4 is 45 degrees in radians.
    	angle = Math.PI/4; // If the angle is greater than 45 degrees, it is set to 45 degrees.
    }

  4. #4
    Member
    Join Date
    Feb 2005
    Location
    copenhagen
    Posts
    72
    thank you it works
    - - - - - - - -

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