Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7989193
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T12:41:02+00:00 2026-06-04T12:41:02+00:00

I am developing an application in which there is one round dice like: When

  • 0

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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T12:41:04+00:00Added an answer on June 4, 2026 at 12:41 pm

    You know the exact amount of angle rotated.
    The simplest way is to detect the rotated angle and get corresponding value.

    For example:

    - (int)getDiceValue  {
       // Total 6 number, so 360/6 = 60 deg for each number and make sure totalRotatedAngle is from 0 to 359
       if (totalRotatedAngle < 30 || totalRotatedAngle >= 300)  {return 1;}
       else if (totalRotatedAngle >= 30 && totalRotatedAngle < 90)  {return 6;}
       ...
    }
    

    One more thing, CGAffineTransformRotate take radian values as argument. So you have to convert you rotate angle from degree to radian before transformation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am developing one application in which there is an imageview...in which i want
We've been developing an Android application which includes Google Adsense. However there seems to
I'm currently developing a cross-platform C application. Is there any compiler macro which is
I`m developing an application which receives data from my GPS device like coordinates, speed
I am developing a Cocoa application which involves a chat element. One approach I've
I am developing an Android application which needs an image to be transmitted from
I am developing a Flex application in which I would like to simulate roughly
I'm developing one android application in which I'm using one customized ListView which extends
I am new to iphone development. I am developing one iphone application in which
I'm developing an application in which distributed components talk to one another over a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.