我有一个视图控制器,我添加了一个glView,然后我只是添加到100个精灵的场景进行测试,并在这行代码中出错,这对于任何设备中的ios 6和7,用xcode编译5
/** Appends an object. Bahaviour undefined if array doesn't have enough capacity. */
void ccArrayAppendObject(ccArray *arr, id object)
{
arr->arr[arr->num] = CC_ARC_RETAIN(object); <-- bad access
arr->num++;
}
这就是我设置导演的方式
CCDirector *director = [CCDirector sharedDirector];
if([director isViewLoaded] == NO)
{
// Create the OpenGL view that Cocos2D will render to.
CCGLView *glView = [CCGLView viewWithFrame:[[[UIApplication sharedApplication] keyWindow] bounds]
pixelFormat:kEAGLColorFormatRGB565
depthFormat:0
preserveBackbuffer:NO
sharegroup:nil
multiSampling:NO
numberOfSamples:0];
[director setView:glView];
[director setAnimationInterval:1.0f/60.0f];
[director enableRetinaDisplay:YES];
[director setProjection:kCCDirectorProjection2D];
}
[CCTexture2D setDefaultAlphaPixelFormat:kCCTexture2DPixelFormat_RGBA4444];
CCFileUtils *sharedFileUtils = [CCFileUtils sharedFileUtils];
[sharedFileUtils setEnableFallbackSuffixes:NO]; // Default: NO. No fallback suffixes are going to be used
[sharedFileUtils setiPhoneRetinaDisplaySuffix:@"-hd"]; // Default on iPhone RetinaDisplay is "-hd"
[sharedFileUtils setiPadSuffix:@"-ipad"]; // Default on iPad is "ipad"
[sharedFileUtils setiPadRetinaDisplaySuffix:@"-ipadhd"]; // Default on iPad RetinaDisplay is "-ipadhd"
director.delegate = (id)self;
[self addChildViewController:director];
[self.view addSubview:director.view];
[self.view sendSubviewToBack:director.view];
[director didMoveToParentViewController:self];
layer =[IntroLayer scene];
if(director.runningScene)
[director replaceScene:layer];
else
[director runWithScene:layer];
这就是我在现场init上的内容
+(CCScene *) scene
{
CCScene *scene = [CCScene node];
for (int i =0; i < 100; i++) {
CCSprite *bowSprite = [CCSprite spriteWithFile:@"icon_clock.png"];
bowSprite.position = ccp(200, 200);
[scene addChild:bowSprite];
}
return scene;
}
如果有人有任何线索,那将是非常有用的
提前感谢!