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

  • Home
  • SEARCH
  • 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 8665181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:25:15+00:00 2026-06-12T17:25:15+00:00

in cocos2d, the coordinate system is pretty straightforward.. bottom left is (0,0). whenever i

  • 0

in cocos2d, the coordinate system is pretty straightforward.. bottom left is (0,0).
whenever i set the position of anything it’s fine.

lets say a layer is TouchEnabled.

when im setting the position of my sprite, it’s fine..

[crab setPosition:ccp(20, 50)];

but if i get the x and y coordinate of a touch (and assume i clicked on the sprite..):

- (void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    NSLog(@"Touches began!");
    NSArray *touchArray = [touches allObjects];
    UITouch *one = [touchArray objectAtIndex:0];
    pointOne = [one locationInView:[one view]];
    CCLOG(@"points are: %f and %f", pointOne.x, pointOne.y );
}

the y coordinate is the opposite of what cocos2d’s coordinate system suggests as the y increases from top to bottom !

so im assuming the coordinate system of the view is different than mac’s coord system.. which is quite counter intuitive.. is that correct?

thanks !

  • 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-12T17:25:16+00:00Added an answer on June 12, 2026 at 5:25 pm

    OpenGL uses a (0, 0) of bottom left while iOS and therefore UIKit which handles the touches use top left as (0, 0). It is easy to convert your point over, you just have to remember to do it.

    The correct method on cocos2d 2.0 is

    CGPoint uiKitPoint = [touch locationInView:touch.view];
    CGPoint cocos2dPoint = [[CCDirector sharedDirector] convertToGL:uiKitPoint];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In Cocos2D, I would like a sprite placed on a screen coordinate, not a
What I am trying to do is lets say my character moves off the
Using cocos2d for iPhone game development, I am confused between Layer and Scene. For
I have a cocos2d project. Everything works fine, except when I am replacing a
all, me again with another noob Cocos2d iphone question. I've set my Director to
I'm really struggling to understand cocos2d 2.0 and how its layers and coordinates work.
Cocos2d-iphone uses the -hd extension for Retina images (and other assets). The cocos2d Retina
cocos2d::CCArray *arr; cocos2d::CCSprite *foo; arr->addObject(foo); CCObject *item; CCARRAY_FOREACH(arr, item) { //how to get item->getPosition()
Cocos2D defines the static method 'actions' for the Sequence class as such: +(id) actions:
In cocos2d using TexturePacker essential version software and generate the .plist and sprite image

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.