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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:31:22+00:00 2026-05-25T18:31:22+00:00

I try to display image to the Screen at Retina iPhone. So I used

  • 0

I try to display image to the Screen at Retina iPhone.
So I used this code.

#define ScreenWidth 960
#define ScreenHeight 640

void ConvertCoordf(float* x, float* y)  
{  
    int height = ScreenHeight;  
    if ( height / 2 > *y )  
        *y += (height / 2 - *y) * 2;  
    else if ( height / 2 < *y )  
        *y -= (*y - height / 2) * 2;      
}

void DISPLAY_UPDATE(char *name, int x , int y , int startx, int starty , int w , int h ,float rotation)  
{  
    CCSprite *sprite = [[CCSprite spriteWithFile:[NSString stringWithUTF8String:name] rect:CGRectMake(startx, starty, w, h)] retain];  
    float drawX = x, drawY = y;   
    CGSize size = [sprite contentSize];

    int nWidth = size.width;
    int nHeight = size.height;
    drawX = drawX + nWidth/2;
    drawY = drawY - nHeight/2;

    ConvertCoordf(&drawX, &drawY);
    drawY -= nHeight;
    [sprite setPosition:ccp(drawX, drawY)];
    [sprite setAnchorPoint:CGPointMake(0.5, 0.5)];
    [sprite setRotation:rotation];
    [_mainLayer addChild:sprite];
    [sprite release];
}

Unfortunately, the image doesn’t display correctly.
The image’s position is wrong.
But in other iphone, it display correct.
What’s the matter?
What’s the problem in this coordinate convert?

Screenshots

enter image description here

enter image description here

  • 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-25T18:31:23+00:00Added an answer on May 25, 2026 at 6:31 pm

    This is completely wrong:

    #define ScreenWidth 960
    #define ScreenHeight 640
    

    The correct values of these macros:

    #define ScreenWidth 480
    #define ScreenHeight 320
    

    This is because you are not working with pixels. You are working with points and the system will calculate the pixels for you. This means the iPhone screen is always 480×320 points. You can also use pixels, but then you have to check the documentation.
    Soon I will add here a link to the description of this problem in the documentation.


    Edit added documentation link: Points Versus Pixels

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

Sidebar

Related Questions

I am using the following code to try and display in a time in
Since yesterday, I try to run a sample of code to display a chart
friends, i am using following code to display bitmap on screen and having next
Because of lack of screen space, i try to display description (UILabel appearing right
I want to display a splash screen animation where an image fades in and
When i try to run this simple game. it says: screen.blit(plumbers,(50 + M ,337
This is code i am using to fetch image form url but i am
Is it possible to display images next to items in FlyoutAnchor submenu? I try
I'm try display data from column points , SELECT * from table ORDER by
I am a total beginner to Objective C. Currently I try to display 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.