[英]Android cocos2d adding child node throws nullpointer exception
I am very much new to cocos2d.. I am developing an application in android using cocos2d.. In that, 我对cocos2d非常新。我正在使用cocos2d在android中开发一个应用程序。在那里,
public class BaseLayer extends CCLayer {
ChildLayer cl = new ChildLayer();
this.addChild(cl); ------------------------------>
}
public class ChildLayer extends CCLayer {
public ChildLayer() {
CCLayer.node();
}
.
.
}
In this, arrowed line throws the Null pointer exception.. Error Log is below.. 在这个,箭头行抛出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)
I dont know how to resolve this issue.. I dont know why this occurs.. Since I am not much familiar with Cocos2d.. Please help me to resolve this issue. 我不知道如何解决这个问题..我不知道为什么会发生这种情况..因为我对Cocos2d不是很熟悉..请帮我解决这个问题。 Somebody please help me.. 有人请帮帮我..
这解决了。在构造函数中,我调用了超级构造函数,如CCLayer.node()而不是super()我改变了,问题解决了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.