iOS Coco2D错误

时间:2012-09-14 20:31:28

标签: ios cocos2d-iphone

当我点击添加CCSPrite的Action方法时,这段代码会产生错误,钩子和我覆盖Hook以绘制附加到钩子的一行。

    -(void)Action
{
 // Create the hook
Hook *hook = [Hook spriteWithTexture:[[CCTextureCache sharedTextureCache]   textureForKey:@"hook2_small.png"]];
 hook.position = ccp(self.fishToCatch.position.x, self.fishToCatch.position.y - 10);
  [self addChild:hook];


// Create appropriate move and move finished actions for hook and fish
 id fishMove = [CCMoveTo actionWithDuration:0.5 position:ccp(200, 433 - self.fishToCatch.contentSize.height/2)];
 id fishMoveDone = [CCCallFuncN actionWithTarget:self selector:@selector(spriteMoveFinished:)];
id updateScore = [CCCallFuncN actionWithTarget:self selector:@selector(updateScore:)];


 id hookMove = [CCMoveTo actionWithDuration:0.5 position:ccp(200, 433 - self.fishToCatch.contentSize.height/2 - 10)];
id hookMoveDone = [CCCallFuncN actionWithTarget:self selector:@selector(spriteMoveFinished:)];

 // Run the actions
 [hook runAction:[CCSequence actions: hookMove, hookMoveDone, nil]];
 [self.fishToCatch runAction:[CCSequence actions: fishMove, fishMoveDone, updateScore, nil]];

[[SimpleAudioEngine sharedEngine] playEffect:@"splash.mp3"];
 self.fishToCatch = nil;
}

Hook是CSprite,我覆盖了draw方法

 @implementation Hook

 - (void)draw
  {

   [super draw];
   glEnable(GL_LINE_STRIP);
   glLineWidth(1.0);

   ccDrawColor4F(14.0/255.0,118.0/255.0,188.0/255.0,1.0f);

   ccDrawLine(ccp(self.contentSize.width - 15, self.contentSize.height), ccp(253 - self.position.x,459 - self.position.y));

   // ccDrawLine(ccp(0,0), ccp(100, 100));

  }
 @end

我看到的错误是

OpenGL error 0x0500 in -[CCGLView swapBuffers] 280
OpenGL error 0x0500 in -[CCGLView swapBuffers] 280
OpenGL error 0x0500 in -[CCGLView swapBuffers] 280
 OpenGL error 0x0500 in -[CCGLView swapBuffers] 280
OpenGL error 0x0500 in -[CCGLView swapBuffers] 280
OpenGL error 0x0500 in -[CCGLView swapBuffers] 280
 OpenGL error 0x0500 in -[CCSprite draw] 532
OpenGL error 0x0500 in -[CCSprite draw] 532
OpenGL error 0x0500 in -[CCSprite draw] 532

1 个答案:

答案 0 :(得分:1)

glLineWidth()是一个OpenGL ES 1.1函数。如果您使用的是cocos2d 2.x,它可以解释OpenGL错误。您不能在OpenGL ES 2.0应用程序中使用OpenGL ES 1.1函数。

相关问题