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 6007185
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:38:43+00:00 2026-05-23T01:38:43+00:00

Does anyone know why it will not rotate the sprite? – (void)ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent

  • 0

Does anyone know why it will not rotate the sprite?

- (void)ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
    UITouch *touch = [touches anyObject];

        CGPoint center = CGPointMake(CGRectGetMidX([[touch view] bounds]), CGRectGetMidY([[touch view] bounds]));

        CGPoint firstLocation = [touch previousLocationInView:[touch view]];
        CGPoint location = [touch locationInView:[touch view]];

        CGPoint currentTouchPoint = [[CCDirector sharedDirector] convertToGL:location];
        CGPoint previousTouchPoint = [[CCDirector sharedDirector] convertToGL:firstLocation];

        CGPoint line2Start = currentTouchPoint;
        CGPoint line1Start = previousTouchPoint;
        CGPoint line2End = CGPointMake(center.x + (center.x - line2Start.x), center.y + (center.y - line2Start.y));
        CGPoint line1End = CGPointMake(center.x + (center.x - line1Start.x), center.y + (center.y - line1Start.y));

        CGFloat a = line1End.x - line1Start.x;
        CGFloat b = line1End.y - line1Start.y;
        CGFloat c = line2End.x - line2Start.x;
        CGFloat d = line2End.y - line2Start.y;

        CGFloat line1Slope = (line1End.y - line1Start.y) / (line1End.x - line1Start.x);
        CGFloat line2Slope = (line2End.y - line2Start.y) / (line2End.x - line2Start.x);

        CGFloat degs = acosf(((a*c) + (b*d)) / ((sqrt(a*a + b*b)) * (sqrt(c*c + d*d))));

        CGFloat angleInRadians = (line2Slope > line1Slope) ? degs : -degs;

        [g setRotation:angleInRadians];
}

- (void)ccTouchEnded:(UITouch *)touch withEvent:(UIEvent *)event
{
    UIGestureRecognizer *recognizer;
    [recognizer setState:UIGestureRecognizerStateEnded];
}

G is the sprite in [g setRotation:angleInRadians];

Then, when I add in this

[[touch view] setTransform:CGAffineTransformRotate([[touch view] transform], [grinder rotation])];

It rotates the entire scene! Any help, please?

Thank You!

  • 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-05-23T01:38:43+00:00Added an answer on May 23, 2026 at 1:38 am

    Dude

    below is the link for the ui-kit but it will work fine for cocos2d as well
    You need to take care of the coordination system

    1)For cocos2d origin is bottom left corner

    2)For UIKit origin is upper left corner

    “Rotate image by Dragging”

    Hope This help You
    Good Luck

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

Sidebar

Related Questions

Does anyone know why this will not compile? I've tried both VS 2008 and
Does anyone know why my tabcontrol will not display on this form? Have a
Does anyone know if there will ever be a true 64-bit version of Cygwin?
Does anyone know of an algorithm that will merge treenodes in the following way?
Does anyone know of a resource that will tell me the sequence of locks
Does anyone know when a tool will be available to manage a SQL Azure
Does anyone know what error message will be displayed when someone tries to run
Does anyone know if views states (used in Silverlight) will be available in next
Does anyone know of any (free) tools that will convert an old Delhi 5
Does anyone know the correct way to explicitly specify which rules Gendarme will use?

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.