我对cocos2d非常新。我正在使用cocos2d在android中开发一个应用程序..在那,
public class BaseLayer extends CCLayer {
ChildLayer cl = new ChildLayer();
this.addChild(cl); ------------------------------>
}
public class ChildLayer extends CCLayer {
public ChildLayer() {
CCLayer.node();
}
.
.
}
在此,箭头行抛出Null指针异常.. 错误日志在下面..
E/AndroidRuntime(982): FATAL EXCEPTION: GLThread 8
11-26 12:50:33.364: E/AndroidRuntime(982): java.lang.NullPointerException
11-26 12:50:33.364: E/AndroidRuntime(982): at org.cocos2d.nodes.CCSprite.draw(CCSprite.java:871)
11-26 12:50:33.364: E/AndroidRuntime(982): at org.cocos2d.nodes.CCNode.visit(CCNode.java:674)
11-26 12:50:33.364: E/AndroidRuntime(982): at org.cocos2d.nodes.CCNode.visit(CCNode.java:680)
11-26 12:50:33.364: E/AndroidRuntime(982): at org.cocos2d.nodes.CCNode.visit(CCNode.java:680)
11-26 12:50:33.364: E/AndroidRuntime(982): at org.cocos2d.nodes.CCNode.visit(CCNode.java:680)
11-26 12:50:33.364: E/AndroidRuntime(982): at org.cocos2d.nodes.CCDirector.drawCCScene(CCDirector.java:683)
11-26 12:50:33.364: E/AndroidRuntime(982): at org.cocos2d.nodes.CCDirector.onDrawFrame(CCDirector.java:651)
11-26 12:50:33.364: E/AndroidRuntime(982): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1332)
11-26 12:50:33.364: E/AndroidRuntime(982): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1116)
11-26 12:50:34.023: E/libEGL(982): call to OpenGL ES API with no current context (logged once per thread)
我不知道如何解决这个问题..我不知道为什么会发生这种情况..因为我对Cocos2d不是很熟悉..请帮我解决这个问题。有人请帮帮我..
答案 0 :(得分:1)
这已经解决了..在构造函数中,我调用了超类构造函数,如CCLayer.node()而不是super() 我改变了,问题解决了。