2012-01-11 24 views
2

我的應用程序在模擬器和其他設備上正常工作。我有最新iOS更新的iPhone 4,並且該應用拒絕在我的設備上運行。Objective C - 應用程序可以在模擬器和其他iPhone上運行,但不會在我自己的iPhone上運行4

這似乎是圍繞視網膜顯示圖像的問題。錯誤噴涌我得到試圖在手機上運行時是:

2012-01-11 09:27:47.404 rr_game1[1569:707] cocos2d: cocos2d v1.0.1 
2012-01-11 09:27:47.413 rr_game1[1569:707] cocos2d: Using Director Type:CCDirectorDisplayLink 
2012-01-11 09:27:47.845 rr_game1[1569:707] cocos2d: OS version: 5.0.1 (0x05000100) 
2012-01-11 09:27:47.849 rr_game1[1569:707] cocos2d: GL_VENDOR: Imagination Technologies 
2012-01-11 09:27:47.853 rr_game1[1569:707] cocos2d: GL_RENDERER: PowerVR SGX 535 
2012-01-11 09:27:47.856 rr_game1[1569:707] cocos2d: GL_VERSION: OpenGL ES-CM 1.1 IMGSGX535-63.14.2 
2012-01-11 09:27:47.861 rr_game1[1569:707] cocos2d: GL_MAX_TEXTURE_SIZE: 2048 
2012-01-11 09:27:47.864 rr_game1[1569:707] cocos2d: GL_MAX_MODELVIEW_STACK_DEPTH: 16 
2012-01-11 09:27:47.867 rr_game1[1569:707] cocos2d: GL_MAX_SAMPLES: 4 
2012-01-11 09:27:47.871 rr_game1[1569:707] cocos2d: GL supports PVRTC: YES 
2012-01-11 09:27:47.874 rr_game1[1569:707] cocos2d: GL supports BGRA8888 textures: YES 
2012-01-11 09:27:47.877 rr_game1[1569:707] cocos2d: GL supports NPOT textures: YES 
2012-01-11 09:27:47.880 rr_game1[1569:707] cocos2d: GL supports discard_framebuffer: YES 
2012-01-11 09:27:47.883 rr_game1[1569:707] cocos2d: compiled with NPOT support: NO 
2012-01-11 09:27:47.886 rr_game1[1569:707] cocos2d: compiled with VBO support in TextureAtlas : YES 
2012-01-11 09:27:47.889 rr_game1[1569:707] cocos2d: compiled with Affine Matrix transformation in CCNode : YES 
2012-01-11 09:27:47.892 rr_game1[1569:707] cocos2d: compiled with Profiling Support: NO 
2012-01-11 09:27:48.012 rr_game1[1569:707] Game manager singleton, init 
2012-01-11 09:27:48.031 rr_game1[1569:707] cocos2d: WARNING: Image (1024 x 4096) is bigger than the supported 2048 x 2048 
2012-01-11 09:27:48.035 rr_game1[1569:707] cocos2d: Couldn't add image:grid.png in CCTextureCache 
2012-01-11 09:27:48.047 rr_game1[1569:707] cocos2d: WARNING: Image (1024 x 4096) is bigger than the supported 2048 x 2048 
2012-01-11 09:27:48.050 rr_game1[1569:707] cocos2d: Couldn't add image:bg-circuits.png in CCTextureCache 
2012-01-11 09:27:48.054 rr_game1[1569:707] *** Assertion failure in -[CCParallaxNode addChild:z:parallaxRatio:positionOffset:], /Users/kevin/code/rr_game1/rr_game1/libs/cocos2d/CCParallaxNode.m:91 
2012-01-11 09:27:48.058 rr_game1[1569:707] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Argument must be non-nil' 

奇怪的是,它是令人作嘔的圖像是在應用程序。

Screenshot of resources dir

再次,應用程式適用於其它設備和在模擬器。下面是加載圖像的代碼:

backgroundNode = [CCParallaxNode node]; 
[self addChild:_backgroundNode z:-1]; 

_backgroundGrid1 = [CCSprite spriteWithFile:@"grid.png"]; 
_backgroundCircuits1 = [CCSprite spriteWithFile:@"bg-circuits.png"]; 

_backgroundGrid1.anchorPoint = CGPointMake(0,0); 
_backgroundCircuits1.anchorPoint = CGPointMake(0,0); 
CGPoint gridSpeed = ccp(0.05, 0.05); 
CGPoint circuitSpeed = ccp(0.1, 0.1); 

[_backgroundNode addChild:_backgroundGrid1 z:1 parallaxRatio:gridSpeed positionOffset:ccp(0,-winSize.height)]; 
[_backgroundNode addChild:_backgroundCircuits1 z:0 parallaxRatio:circuitSpeed positionOffset:ccp(0,-winSize.height)]; 

我已經刪除了我的手機應用程序,運行一個「乾淨」的Xcode重新啓動,並重新啓動我的電腦。仍然沒有運氣。我也重新配置了我的手機。我也刪除並重新添加資產到項目中。

+0

它說的圖片太大的幫助旁邊。奇怪的是,這隻發生在iPhone 4上...... – evotopid 2012-01-11 15:37:24

+0

請勿在cocos2d中使用@ 2x擴展名。改爲使用-hd後綴。請參閱:http://www.cocos2d-iphone.org/wiki/doku.php/prog_guide:how_to_develop_retinadisplay_games_in_cocos2d – LearnCocos2D 2012-01-11 20:34:02

回答

2

說實話,它確實你的日誌文件中的1024×4096的圖像尺寸遠遠大於中說,支持2048×2048:

2012-01-11 09:27:48.031 rr_game1[1569:707] cocos2d: WARNING: Image (1024 x 4096) is bigger than the supported 2048 x 2048 
2012-01-11 09:27:48.035 rr_game1[1569:707] cocos2d: Couldn't add image:grid.png in CCTextureCache 
2012-01-11 09:27:48.047 rr_game1[1569:707] cocos2d: WARNING: Image (1024 x 4096) is bigger than the supported 2048 x 2048 
2012-01-11 09:27:48.050 rr_game1[1569:707] cocos2d: Couldn't add image:bg-circuits.png in CCTextureCache 

你說在其上運行的其他設備,但什麼設備他們?如果他們不是視網膜啓用,我想象各自的圖像大小將是512x2048,因此符合2048x2048最大尺寸。

如果您的視網膜顯示圖像超出了這些尺寸,它將無法正常工作--2048x2048應該已經包含了視網膜大小的圖像。您可能需要修改您的遊戲以使用更小的尺寸。

+0

或者其他設備可能是iPhone 4S,也許?最大紋理尺寸已經增加到4096x4096。另外,如果向後兼容性值得關注,那麼值得注意的是,它是所有PowerVR MBX設備(即iPhone,iPhone 3G和相關iPod)上的1024x1024。 – Tommy 2012-01-11 17:32:42

+0

其他設備之一是另一個普通的iPhone 4,以及iPhone 4s。 – 2012-01-11 18:52:11

+0

只是做了一些更多的挖掘 - 它有問題的文件不是1024x4096 - 它的640x2292 – 2012-01-12 13:57:51

2

你應該仔細考慮將你的圖片分割成更小的塊,並且可能將它們放在精靈表中以獲得更好的性能。然後你就可以將圖像切片只需添加對方使用這樣的事情

for (int i = 0; i < amountOfSprites; i++){ 
     CCSprite *sprite = [CCSprite spriteWithSpriteFrameName:spriteName]; 
     sprite.anchorPoint = ccp(0,0); 

     sprite.position = ccp((i * sprite.contentSize.width),0); 


     [yourBatchNode addChild:sprite]; 
    } 

如果您需要創建精靈表看看這個指南http://www.raywenderlich.com/2361/how-to-create-and-optimize-sprite-sheets-in-cocos2d-with-texture-packer-and-pixel-formats

相關問題