Add child node to a node throws "null pointer exception"

Problems with Canvas, OpenGL, etc...

Add child node to a node throws "null pointer exception"

Postby Sakthi Sai » Sat Nov 26, 2011 11:51 am

Hi,
I am very much new to cocos2d.. I am developing an application in android using cocos2d.. In that,

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..

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..
Sakthi Sai
Freshman
Freshman
 
Posts: 8
Joined: Wed Nov 23, 2011 9:28 am

Top

Re: Add child node to a node throws "null pointer exception"

Postby Sakthi Sai » Mon Nov 28, 2011 1:47 pm

Hello friends,
I have been stuck on this problem for more than 2 days. Please help me to fix it. Give me some suggestion.
Sakthi Sai
Freshman
Freshman
 
Posts: 8
Joined: Wed Nov 23, 2011 9:28 am

Re: Add child node to a node throws "null pointer exception"

Postby Sakthi Sai » Wed Nov 30, 2011 6:27 am

Hi,
This is solved.. In constructor,I have called the super class constructor like CCLayer.node() instead of super()
I changed that and the problem is solved..
Sakthi Sai
Freshman
Freshman
 
Posts: 8
Joined: Wed Nov 23, 2011 9:28 am

Re: Add child node to a node throws "null pointer exception"

Postby Sakthi Sai » Wed Nov 30, 2011 6:29 am

How to mark this as solved..
Sakthi Sai
Freshman
Freshman
 
Posts: 8
Joined: Wed Nov 23, 2011 9:28 am

Top

Return to Android 2D/3D Graphics - OpenGL Problems

Who is online

Users browsing this forum: No registered users and 4 guests