问题描述
我在做海外游戏移植的时候遇到一个问题,经过研究,发现代码始终在g3d.bind(g);上报空指,这里是省略写法,g3d是有初始化的,打印也是有内存的,g的话,直接用paint(g)里的g,试过,自己申明一个Graphicsg,在初始化也试过,不过还是在那句上报空指。然后我直接去SDK-API,Graphics3D下直接拷贝DEMO到IDE上,还是在g3d.bind(g)这句报空指针错误,求高人解决,下面附上DOMO代码。importjavax.microedition.lcdui.Canvas;importjavax.microedition.lcdui.Display;importjavax.microedition.lcdui.Graphics;importjavax.microedition.midlet.MIDlet;importcom.mascotcapsule.micro3d.v3.ActionTable;importcom.mascotcapsule.micro3d.v3.AffineTrans;importcom.mascotcapsule.micro3d.v3.Effect3D;importcom.mascotcapsule.micro3d.v3.Figure;importcom.mascotcapsule.micro3d.v3.FigureLayout;importcom.mascotcapsule.micro3d.v3.Graphics3D;importcom.mascotcapsule.micro3d.v3.Texture;importcom.mascotcapsule.micro3d.v3.Vector3D;publicclassMyG3DExampleextendsMIDlet{publicvoidstartApp(){Displayd=Display.getDisplay(this);d.setCurrent(newMyCanvas());}publicvoidpauseApp(){}publicvoiddestroyApp(booleanb){}}classMyCanvasextendsCanvas{Graphics3Dg3d=newGraphics3D();protectedvoidpaint(Graphicsg){g.setColor(0xFFFFFF);g.fillRect(0,0,getWidth(),getHeight());Figurefigure=null;Texturetex=null;ActionTableaction=null;FigureLayoutlayout=newFigureLayout();Effect3Deffect=newEffect3D();AffineTranstrans=newAffineTrans();trans.lookAt(newVector3D(0,0,2048),newVector3D(0,0,-2048),newVector3D(0,4096,0));layout.setAffineTrans(trans);try{figure=newFigure("/figure.mbac");tex=newTexture("/figure.bmp",true);figure.setTexture(tex);action=newActionTable("/figure.mtra");figure.setPosture(action,0,0);}catch(Exceptione){}//Bindthe3DgraphicscontexttothegivenMIDPGraphicsobject.g3d.bind(g);try{g3d.renderFigure(figure,80,100,layout,effect);g3d.flush();//flushtherenderedfigure}catch(Exceptione){}//ReleasetheMIDPGraphicsobject.g3d.release(g);}}
解决方案
解决方案二:
求高人解答,QQ89348180
解决方案三:
不太清楚,帮顶查查bind()的函数
解决方案四:
空指针,就输出值来看了,看看传到哪一步值出问题的,也可以debug一下。希望对你有帮助
解决方案五:
单步调试一下