1
我有一個應用程序使用cocos2D進行迷你遊戲。 當我按下按鈕時,我會在遊戲中啓動一個cocos2D場景。CCSprite不會在iPhone 4上顯示
我嘗試在我的cocos2D場景中僅加載背景圖像(bg.png)。我正在使用精靈。
它適用於iPhone 5和iPhone 4S(iOS 6),但它不適用於iPhone 4. 在iPhone 4上,我有一個黑屏。我不明白爲什麼。
sprites-hd.png確實3762×1252,1.4 Mo.它對iPhone 4來說太大了嗎?
在我GameViewController_iPhone.m:
-(IBAction) playGame {
CCDirector *director = [CCDirector sharedDirector];
CCGLView *glView = [CCGLView viewWithFrame:[[ISAMAppDelegate_iPhone sharedISAMAppDelegate].window bounds]
pixelFormat:kEAGLColorFormatRGB565 // kEAGLColorFormatRGBA8
depthFormat:0 // GL_DEPTH_COMPONENT16_OES
];
// attach the openglView to the director
[director setView:glView];
if(! [director enableRetinaDisplay:YES])
MyLog(@"Retina Display Not supported");
[[CCDirector sharedDirector] setAnimationInterval:1.0/60];
[CCTexture2D setDefaultAlphaPixelFormat:kCCTexture2DPixelFormat_RGBA8888];
[self.view addSubview:glView];
[[CCDirector sharedDirector] runWithScene:[Game sceneWithGameViewController:self]];
}
在我Game.m:
+ (CCScene *)sceneWithGameViewController:(GameViewController_iPhone*) gvc
{
CCScene *game = [CCScene node];
Game *layer = [[Game alloc] initWithGameViewController:gvc];
[game addChild:layer];
return game;
}
- (id) initWithGameViewController:(GameViewController_iPhone*) gvc {
if(![super init]) return nil;
if((self = [super init])) {
[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"sprites.plist"];
CCSpriteBatchNode* batchNode = [CCSpriteBatchNode batchNodeWithFile:@"sprites.png" capacity:50];
[self addChild:batchNode];
CCSprite *someSprite = [CCSprite spriteWithSpriteFrameName:@"bg.png"];
[batchNode addChild:someSprite];
}
}
cocos與此無關,它是一種設備限制。 – YvesLeBorg 2013-04-07 13:06:31
你是對的,只是編輯,以避免誤傳。 – ssantos 2013-04-07 13:15:18