0
給定以下代碼,爲什麼圓形和矩形圖像顯示得如此分開?爲什麼具有相同setPosition點的精靈顯示得如此之遠?
CGPoint center = ccp(winSize.width/2, winSize.height/2);
[rectangle setPosition:center];
[circle setPosition:ccp(winSize.width/2, winSize.height/2)];
下面是用於創建矩形代碼:
glEnable(GL_LINE_SMOOTH);
glColor4ub(255, 255, 255, 255);
glLineWidth(2);
CGPoint vertices2[] = { ccp(79,299), ccp(134,299), ccp(134,229), ccp(79,229) };
ccDrawPoly(vertices2, 4, YES);
-(id) init {
if((self = [super init])) {
CGSize winSize = [CCDirector sharedDirector].winSize;
[CCTexture2D setDefaultAlphaPixelFormat:kCCTexture2DPixelFormat_RGB565];
background = [CCSprite spriteWithFile:@"blue-shooting-stars.png"];
background.anchorPoint = ccp(0,0);
[CCTexture2D setDefaultAlphaPixelFormat:kCCTexture2DPixelFormat_Default];
Circle *circle = [[Circle alloc] init];
[circle setPosition:ccp(winSize.width/2.0f, winSize.height/2.0f)];
CGPoint center = ccp(winSize.width/2.0f, winSize.height/2.0f);
Rectangle *rectangle = [[Rectangle alloc] init];
[rectangle setPosition:center];
[self addChild:circle];
[self addChild:rectangle];
}
return self;
}
這些圖像,或者你正在繪製的東西? – HalR
如果他們是你正在繪製的東西,那麼矩形的繪圖代碼看起來像什麼(圓看起來相當不錯) – HalR
繪製圓和矩形。當矩形實際上在屏幕上時,它看起來像一個矩形:)即使我刪除了圓,矩形仍保持在相同的位置,我想我會預期它現在處於與圓相同的位置。 –