此刻我正確地找到了屏幕上物體和光標的距離和旋轉。XNA 2D點對象隨時間變化的光標
Vector2 direction = podType[podIndex]._Position - MouseCursorInWorld;
mousePoint = (float)(Math.Atan2(-direction.X, direction.Y));
這工作得很好,下一步我拿了搞清楚我如何可以慢慢旋轉當前方向到鼠標位置是使用百分比的正常工作,但有1個大問題,就是我想要修復
percent = mousePoint/mousePoint * increment;
if(percent < mousePoint)increment += 0.01f;
if (percent > mousePoint) increment -= 0.01f;
正如你可以在這裏看到百分比是總旋轉光標的百分比,如果旋轉更少或更多,然後移動到該增量,直到達到100%,這意味着它的正確的百分比面向光標。
問題是因爲左側是負面的,右側是正面的,我的完整旋轉達到3.1和-3.1,所以當我將光標移動到最底部某處並從最右側移動到最左側時繼續其朝向光標的路徑,它向右旋轉,因爲當前鼠標點值爲負2.2它目前是正值1.5
是否有某種方式可以包裹旋轉因此它沒有負值和正值的角度?還是有更好的技術,我可以使用其他的,然後我現在是一個?謝謝你的時間:)
究竟是我在找什麼謝謝你本傑明:D如果你有興趣爲什麼即時通訊試圖做到這一點的宇宙飛船遊戲我想要一些飛船旋轉慢一點,然後其他飛船,我不希望他們即刻。再次感謝幫助我:) – user1109013 2011-12-22 07:29:49