-1
A
回答
0
找到解決方案!
- (void)handleDragFrom:(CGPoint)start to:(CGPoint)end
{
[super handleDragFrom:start to:end];
float rotationCenterX = self.player.position.x - (self.player.contentSize.width/2);
float rotationCenterY = self.player.position.y - (self.player.contentSize.height/2);
float dXStart = start.x - rotationCenterX;
float dYStart = start.y - rotationCenterY;
float radianStart = atan2(dYStart, dXStart);
float dXEnd = end.x - rotationCenterX;
float dYEnd = end.y - rotationCenterY;
float radianEnd = atan2(dYEnd, dXEnd);
float radian = GLKMathRadiansToDegrees(radianEnd - radianStart);
self.player.rotation -= radian;
}
「開始」 和 「結束」 是從觸摸給出的兩點感動:
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [[event allTouches] anyObject];
CGPoint end = [touch locationInView:self.view];
CGPoint start = [touch previousLocationInView:self.view];
[self.scene handleDragFrom:start to:end];
}
相關問題
- 1. 在touchesMoved中查看旋轉
- 2. 得到UIView的旋轉方向touchesMoved
- 3. OpenglES 2.0 GL_POINTS消失
- 4. Android OpenGLES 2.0按鈕
- 5. Android混合OpenGLES 1.0和OpenGLES 2.0
- 6. Android OpenGLES 2.0 2D渲染
- 7. OPENGLES 2.0 PUSHMATRIX POP MATRIX實現
- 8. OpenGLES 2.0組頂點顏色
- 9. OpenGLES 2.0紋理渲染
- 10. 緩存Outputimages在OpenGLES 2.0
- 11. OpenGLES 2.0:gl_VertexID等效嗎?
- 12. OpenGL ES 2.0中的旋轉
- 13. 旋轉對象OpenGL ES 2.0
- 14. 從Opengles 1.0到Opengles 2.0的Android移植,紋理?
- 15. 在SpriteKit中使用touchesMoved旋轉獎金輪
- 16. 將畫布座標系轉換爲OpenGLES 2.0座標
- 17. 如何在OpenGLES 2.0中轉換和縮放對象
- 18. 如何旋轉iPhone攝像頭輸出OpenGLES紋理
- 19. 如何使用OpenGLes和cocos2d在3D中旋轉Sprite像'Fruit Ninja'
- 20. opengles 2.0二維場景圖實現
- 21. OpenGLES 1.1和2.0,同時支持
- 22. GLKit/OpenGLES 2.0:如何訂購基元?
- 23. OpenglES 2.0頂點着色器屬性
- 24. OpenglES 2.0 PNG阿爾法紋理重疊
- 25. 點不顯示在opengles 2.0中
- 26. 在actionscript 2.0中旋轉視頻對象
- 27. OpenGL ES 2.0:對象旋轉問題
- 28. Android OpenGL ES 2.0 - 旋轉到位
- 29. Actionscript 2.0給對象3D旋轉?
- 30. OpenGL ES 2.0中的旋轉三角形