gpt4 book ai didi

iOS Coco2D 错误

转载 作者:行者123 更新时间:2023-11-29 04:25:04 25 4
gpt4 key购买 nike

当我点击添加了 CCSPrite、钩子(Hook)的 Action 方法时,这段代码会生成错误,并且我重写该钩子(Hook)以绘制一条附加到钩子(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,我重写了绘制方法

 @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

最佳答案

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

关于iOS Coco2D 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12431576/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com