【发布时间】:2011-09-17 17:03:07
【问题描述】:
我尝试在 Retina iPhone 的屏幕上显示图像。 所以我使用了这段代码。
#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];
}
很遗憾,图片无法正确显示。 图片位置不对。 但在其他iphone中,它显示正确。 怎么了? 这个坐标转换有什么问题?
截图
【问题讨论】:
-
一些截图会很好。
标签: objective-c xcode4 cocos2d-iphone iphone-4