2012-01-11 43 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

相关问题