我想旋轉我的對象像搖動骰子。 請建議最簡單的方式在我的iPhone應用程序中實現它。 任何類型的示例代碼或文檔。對象的3D旋轉
Q
對象的3D旋轉
1
A
回答
2
如果要做到這一點,而不使用OpenGL,你可以使用一個UIImageView和設置一系列動畫圖像。通過創建一系列圖像,您可以創建「滾動骰子」效果。這裏是如何做到這一點的例子:
// create a UIImageView
UIImageView *rollDiceImageMainTemp = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"rollDiceAnimationImage1.png"]];
// position and size the UIImageView
rollDiceImageMainTemp.frame = CGRectMake(0, 0, 100, 100);
// create an array of images that will represent your animation (in this case the array contains 2 images but you will want more)
NSArray *savingHighScoreAnimationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"rollDiceAnimationImage1.png"],
[UIImage imageNamed:@"rollDiceAnimationImage2.png"],
nil];
// set the new UIImageView to a property in your view controller
self.viewController.rollDiceImage = rollDiceImageMainTemp;
// release the UIImageView that you created with alloc and init to avoid memory leak
[rollDiceImageMainTemp release];
// set the animation images and duration, and repeat count on your UIImageView
[self.viewController.rollDiceImageMain setAnimationImages:savingHighScoreAnimationImages];
[self.viewController.rollDiceImageMain setAnimationDuration:2.0];
[self.viewController.rollDiceImageMain.animationRepeatCount:3];
// start the animation
[self.viewController.rollDiceImageMain startAnimating];
// show the new UIImageView
[self.viewController.view addSubview:self.rollDiceImageMain];
您可以修改創建和設置,包括大小,位置,數量的圖像,持續時間,重複計數等需要。我用UIImageView的這個特性來創建簡單的動畫效果,它效果很好!
請讓我知道,如果你試試這個,如果它符合你的需求。另外,發佈任何後續問題。
巴特
3
1
不錯的例子,但你認爲這是可以旋轉/控制與觸摸手勢旋轉?
相關問題
- 1. Java中旋轉對象3d
- 2. WPF中的3D對象旋轉
- 3. 在3d中檢測對象的旋轉
- 4. iOS的 - 在scenekit旋轉3D對象
- 5. 匹配對象的3D旋轉
- 6. cocos3d中的3d對象旋轉問題
- 7. 通過設備旋轉旋轉簡單的3d對象
- 8. 在2D場景中旋轉3D對象
- 9. 如何在Java 3D中旋轉對象?
- 10. Open GL Android 3D對象旋轉問題
- 11. Unity 3D旋轉游戲對象
- 12. Actionscript 2.0給對象3D旋轉?
- 13. 我可以旋轉3D車對象嗎
- 14. 將iPhone旋轉應用於3d對象
- 15. 圍繞中心旋轉3D對象
- 16. 旋轉後移動3D對象
- 17. 如何在C#3D中旋轉對象?
- 18. 修復旋轉3D對象Perl代碼
- 19. 獲取iPhone旋轉和方向以實時旋轉3d對象
- 20. Javascript 3D將獨立對象旋轉到其他對象內
- 21. Starling 3D旋轉
- 22. 3D中的旋轉
- 23. JavaFX的3D旋轉
- 24. 在3D中反轉旋轉,使對象始終面向相機?
- 25. Unity:旋轉3D對象以對齊2D等距字段
- 26. 使用openGL中的觸摸屏控制3D對象的旋轉
- 27. 如何創建旋轉的3d對象c#
- 28. 3d對象上的旋轉增量關閉
- 29. 如何創建一個保持旋轉的3D對象?
- 30. Iphone上的OpenGl ES - 顯示和旋轉3D對象