I am developing an application in which there is one round dice like: When I click on the center of the image it rotates
in first image is before rotation means initial state and second image is after rotation image and in this number 3 is shown on the result pointer. My problem is how to detect that the result if the dice roll is number 3.I want the number which appears on the result arrow.
On button click I do :-
create a random number which acts like a angle. and rotate the image to that angle.
-(IBAction)diceButtonClicked:(id)sender
{
float angle=arc4random()%360;
NSLog(@"%f",angle);
toAngle=angle;
if (fromAngle+toAngle<360) {
toAngle=fromAngle+toAngle;
}
else
{
if (toAngle<30) {
toAngle=angle+30;
}
else
{
toAngle=angle;
}
}
[self rotateDiceMethod];
}
My logic for image rotation:-
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.5];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
diceNumbers.transform = CGAffineTransformRotate(startTransform,toAngle);
[UIView commitAnimations];
startTransform=diceNumbers.transform;
fromAngle=toAngle;
Please anybody help me how to know which is the result of my dice or what approach should I follow to do achieve my required functionality.
Any suggestions will be highly appreciated. Thanks in advance!