Если вы хотите сделать это без использования 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 для создания простых эффектов анимации, и она прекрасно работает!
Пожалуйста, дайте мне знать, если вы попробуете это, и если это работает для ваших нужд. Кроме того, отправьте любые последующие вопросы.
Bart