可以在cocos2d项目中使用scenekit来渲染3d对象吗?

时间:2015-08-15 17:07:23

标签: ios cocos2d-iphone scenekit

-(id) init {
    self = [super init];

    CGSize wSize = [[CCDirector sharedDirector] viewSize];
    CCSprite*imgBackground = [CCSprite spriteWithImageNamed:@"imgBackground.png"];
    imgBackground.anchorPoint = ccp(0, 0);


    [self addChild:imgBackground];





    //adding the plus button
    btnPlus = [CCButton buttonWithTitle:@"[ Plus ]" fontName:@"Georgia" fontSize:16.0f];
    btnPlus.positionType = CCPositionTypeNormalized;
    btnPlus.position = ccp(0.25f, 0.25f);
    [btnPlus setTarget:self selector:@selector(btnPlusClicked)];
    [self addChild:btnPlus];

    btnMinus = [CCButton buttonWithTitle:@"[ Minus ]" fontName:@"Georgia" fontSize:16.0f];
    btnMinus.positionType = CCPositionTypeNormalized;
    btnMinus.position = ccp(0.75f, 0.25f);
    [btnMinus setTarget:self selector:@selector(btnMinusClicked)];
    [self addChild:btnMinus];


    //view.scene = (SCNScene*)self.scene;
    UIView *overlay = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 560)];
    SCNBox* boxGeometry = [SCNBox boxWithWidth:10.0 height:10.0 length:10.0 chamferRadius:1.0];
    dScene = [[SCNScene alloc] init];

    node = [SCNNode nodeWithGeometry:boxGeometry];

    //view = [[SCNView alloc] init];
    //view.scene = dScene;

    //overlay.backgroundColor = [UIColor colorWithWhite:1 alpha:.5];
    //view = [[SCNView alloc] init];
    //view.backgroundColor =[UIColor colorWithWhite:0 alpha:.5];
    //[overlay addSubview:view];

    [[[CCDirector sharedDirector] view] addSubview:overlay];





    [dScene.rootNode addChildNode:node];
    //[self.scene addChild:node];
    //node.light = SCNLightTypeAmbient;


    return self;
}

我正在尝试使用scenekit将一个3d对象添加到cocos2d项目,因为scenekit看起来很有希望。

然而,我收到错误

OpenGL error GL_INVALID_FRAMEBUFFER_OPERATION detected at CCRenderStateGLTransition 298
OpenGL error GL_INVALID_FRAMEBUFFER_OPERATION detected at CCRenderStateGLTransition 298
OpenGL error GL_INVALID_FRAMEBUFFER_OPERATION detected at CCRenderStateGLTransition 298

任何人都知道是否可以这样做?任何建议都会很感激。谢谢!

0 个答案:

没有答案