I am creating a custom CCSprite
class to display a custom image and set its own position as well as handle other drawing tasks. Currently I have no other code running in the custom class but the initializer, which should set the image file and the position of the sprite. Here is my - (id)init
method
- (id)init
{
if (!(self = [super initWithFile:@"runnerImage.png"]))
return nil;
//set our texture to the runner image ^^^
//set our initial position
CGSize size = [[CCDirector sharedDirector] winSize];
self.position = CGPointMake(size.width/2, size.height-RUNNER_OFFSET); //centered x and offseted by RUNNER_OFFSET
return self;
}
Currently the app crashes after running this code. (I have determined this with break points and commenting out lines.) Any idea why? This is the section I am calling it from:
myRunner = [[Runner alloc] init];
[self addChild:myRunner];
//schedule an update each frame
That is in a CCLayer
subclass's - init
method.
Here is the console log:
2010-07-31 09:16:32.730
CubeRacer[849:207] cocos2d: cocos2d
v0.99.4-rc2 2010-07-31 09:16:32.733
CubeRacer[849:207] cocos2d: Using
Director Type:CCDisplayLinkDirector
2010-07-31 09:16:33.064
CubeRacer[849:207] cocos2d: GL_VENDOR:
Apple Computer, Inc. 2010-07-31
09:16:33.065 CubeRacer[849:207]
cocos2d: GL_RENDERER: Apple Software
Renderer 2010-07-31 09:16:33.065
CubeRacer[849:207] cocos2d:
GL_VERSION: OpenGL ES-CM 1.1 APPLE
2010-07-31 09:16:33.066
CubeRacer[849:207] cocos2d:
GL_MAX_TEXTURE_SIZE: 2048 2010-07-31
09:16:33.067 CubeRacer[849:207]
cocos2d: GL_MAX_MODELVIEW_STACK_DEPTH:
16 2010-07-31 09:16:33.068
CubeRacer[849:207] cocos2d: GL
supports PVRTC: YES 2010-07-31
09:16:33.068 CubeRacer[849:207]
cocos2d: GL supports BGRA8888
textures: NO 2010-07-31 09:16:33.071
CubeRacer[849:207] cocos2d: GL
supports NPOT textures: YES 2010-07-31
09:16:33.072 CubeRacer[849:207]
cocos2d: GL supports
discard_framebuffer: YES 2010-07-31
09:16:33.072 CubeRacer[849:207]
cocos2d: compiled with NPOT support:
NO 2010-07-31 09:16:33.073
CubeRacer[849:207] cocos2d: compiled
with VBO support in TextureAtlas : YES
2010-07-31 09:16:33.074
CubeRacer[849:207] cocos2d: compiled
with Affine Matrix transformation in
CCNode : YES 2010-07-31 09:16:33.074
CubeRacer[849:207] cocos2d: compiled
with Profiling Support: NO Program
received signal: “EXC_BAD_ACCESS”.
Thanks for any help!
Update
After some more research I found this may be a looping problem but I am unsure.
The superclasses initializer that I am calling calls [self init]
. Would that call the - (id)init
method of my subclass or of the CCSprite
class? If it calls my subclass then that is the obvious problem. Check my comment for a link to the discussion I found of this.