Java 我的jMonkey粗略修改过的教程不知何故存在空指针问题?

Java 我的jMonkey粗略修改过的教程不知何故存在空指针问题?,java,java-3d,jmonkeyengine,Java,Java 3d,Jmonkeyengine,好的,这是我的代码: package test; import java.util.ArrayList; import java.util.Vector; import com.jme3.app.SimpleApplication; import com.jme3.system.AppSettings; import com.jme3.material.Material; import com.jme3.math.Vector3f; import com.jme3.scene.Geom

好的,这是我的代码:

package test;


import java.util.ArrayList;
import java.util.Vector;

import com.jme3.app.SimpleApplication;
import com.jme3.system.AppSettings;


import com.jme3.material.Material;
import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry;
import com.jme3.scene.shape.Box;
import com.jme3.math.ColorRGBA;
import com.jme3.scene.Node;


public class test extends SimpleApplication {


    public static void main(String[] args){

        AppSettings settings = new AppSettings(false);
        settings.setResolution(640,480);
        test app = new test();

        app.setSettings(settings);
        app.start();

    }


    @Override
    public void simpleInitApp() {

        ArrayList<Geometry> geos = new ArrayList<Geometry>();

        for ( int count = 0; count <= 5; count++ ) {

            double x = 10;
            double y = 10;
            double z = 10;

            Box      box = new Box( new Vector3f(count*10,count*10,count*10), (int)x, (int)y, (int)z );
            Geometry geo = new Geometry( "Box", box );
            Material mat = new Material( assetManager, "Common/MatDefs/Misc/Unshaded.j3md");

            mat.setColor( "Color", ColorRGBA.Blue );
            geo.setMaterial(mat);

            geos.add( geo );

        }

        /** Create a pivot node at (0,0,0) and attach it to the root node */
        Node pivot = new Node("pivot");
        rootNode.attachChild(pivot); // put this node in the scene

        /** Attach the two boxes to the *pivot* node. */
        for( Geometry g : geos ) {
            pivot.attachChild( g );
        }

        /** Rotate the pivot node: Note that both boxes have rotated! */
        pivot.rotate(.4f,.4f,0f);

    }




}
好的,换衣服

AppSettings settings = new AppSettings(false);


解决了我的问题。现在来找出false不起作用的原因。

false不加载默认设置,这意味着您应该手动设置它们。这可能是NPE的原因。要隐藏“设置”对话框,请使用

app.setShowSettings(false);

你的堆栈跟踪是什么?可能是某些内容被设置为null,并且只有在启动应用程序时才会被调用,这就是为什么您会在该行看到它而不是应用程序本身为null。这就是堆栈跟踪的含义吗?如果没有,如何获取它?因此实际的空指针似乎位于JmeDesktopSystem.showSettingsDialog上。你修改的教程有用吗?如果是这样,您是否删除了一行关于设置对话框的内容?它确实有效。我更改的是添加了for循环和AppSettings内容。现在,我先添加了AppSettings的东西,效果很好。然后,当我添加for循环时,它就死了。因此,在添加for循环时,我肯定做了其他事情;to AppSettings设置=新建AppSettingstrue;它是有效的。false应该不会显示splash对话框,或者我是这么想的。你见过那个页面吗?:甚至可能是那个页面?:别忘了,你有Java开源的强大功能!
AppSettings settings = new AppSettings(true);
app.setShowSettings(false);