【问题标题】:Netbeans game works in compiler, but build doesn't function the sameNetbeans 游戏在编译器中工作,但构建功能不同
【发布时间】:2014-06-13 21:36:04
【问题描述】:

我以前从未有过修复与构建相关的问题的经验,所以当 Jmonkey 引擎决定生成一个无法在编译器中运行的构建时,我没有(现在仍然没有)真的知道该怎么做了。 Jmonkey 引擎运行在 netbeans 之上,但在这个特定的游戏中,我们主要使用 Nifty GUI,因为只有一个 3D 对象(地球)。

没有错误消息 - 构建“成功”,游戏运行没有错误。问题是玩家无法从类菜单移动到恶意软件中心或游戏开始的地方。我将发布我的构建日志、类菜单和恶意软件中心。

即使您对 Jmonkey 没有任何直接经验,您能否向我解释为什么会发生这种情况以及我可能需要做些什么来解决它?注意:我没有控制台知识,因此该顺序的任何帮助可能需要一些解释。

谢谢。

我希望我可以提供更小的代码段来重现问题,但我实际上并不知道问题是什么,因此我所能做的就是发布这两个类。但是,我将在此处发布您可能应该注意的代码部分。不过,如果您想要完整的课程,请查看链接。

链接和代码

构建日志: http://pastebin.com/bgaVNvKi

班级菜单: http(冒号)//pastebin(dot)com/9ZBJkGhi

--仅限课程菜单的重要部分--

nifty.fromXml("Interface/NiftyGUI/MalwareHub.xml","start", MH);
//^^ How I reach the Malware Hub.

private MalwareHub MH;

MH = Main.getMalwareHub();
Main.getApplication().getStateManager().attach(MH);

//^^ Value of MH

恶意软件中心完整代码: http://pastebin.com/AnuTWQP0

--仅重要部分--

public class MalwareHub extends AbstractAppState implements ScreenController {

    public MalwareHub() {

        day = Time.getDayRate();
        timekeeper = 0;
        upgradeTimekeeper = 0;
        //We add the functionality necessary to let the player rotate the globe.
        inputManager = Main.getApplication().getInputManager();
        initKeys();

        gameStarted = false;


    }

    @Override
    public void onStartScreen() {
        System.out.println("Screen Started");
    }

    @Override
    public void onEndScreen() {
        System.out.println("Screen Ended");
    }

    @Override
    public void bind(Nifty NIFTY, Screen SCREEN) {
        //Actual Screens
        nifty = NIFTY;
        screen = SCREEN;

        //Correct instantiations of other xml files
        UA = Main.getUpgradeAbility();
        UE = Main.getUpgradeEffect();
        UIV = Main.getUpgradeInfectionVector();
        PH = Main.getPopupHandler();

        //I initialize a lot of Main variables.
        app = Main.getApplication();
        assetManager = app.getAssetManager();
        n = new Node("Globe");
        cam = app.getCamera();
        onMalwareHub = true;

        //<editor-fold desc="Show the beginning popup" defaultstate="collapsed">
        if(!gameStarted){      
            System.out.println("Beginning window shown");
            PH.showWindow("Welcome. You have recently posted a piece of malware online that does nothing but will soon be upgraded by you. "
                  + "Use these upgrades to increase infectivity, complete new and more powerful effects, and conquer the world.", "");
        }
        //</editor-fold>

        //We're here
        gameStarted = true;

        UpgradeButton=screen.findElementByName("MalwareButton");

        //We are going to create the globe.
        //<editor-fold defaultstate="collapsed" desc="It's 'Global'">        
        //In order to do this, first, we need to transform it to fit whatever device they're using.        
        //Here we create the actual sphere, with the radius being slightly smaller than the smallest side of whatever device is being used.
        globe = assetManager.loadModel("Models/World/World_Globe.obj");

        globeGeometry = new Geometry();

        //Attach the texture
        globeMaterial = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
        globeMaterial.setTexture("ColorMap", assetManager.loadTexture("Models/World/Globe_Txtr.png"));
        globe.setMaterial(globeMaterial);

        //Set move the globe to the right location and center it.
        globe.setLocalTranslation(0, 1, 0);
        globe.center();

        //Attach the globe, scale it down (cuz its big), then translate the node to the same spot as the globe so we don't start revolving around 0,0,0.
        n.attachChild(globe); //Attach it to the node
        n.scale(0.02f); //Scale the globe down    
        n.setLocalTranslation(0, 1, 0);

        //Starring... the globe!
        cam.lookAt(new Vector3f(0, 0, 0), Vector3f.UNIT_Y);
        cam.update();

        //Now we must give it some light!
        //<editor-fold defaultstate="collapsed" desc="Light">
        DirectionalLight sun2 = new DirectionalLight();
        sun2.setDirection(new Vector3f(0, 1, 0).normalizeLocal());
        sun2.setColor(ColorRGBA.White);
        n.addLight(sun2);

        DirectionalLight sun3 = new DirectionalLight();
        sun3.setDirection(new Vector3f(0, 0, 1).normalizeLocal());
        sun3.setColor(ColorRGBA.White);
        n.addLight(sun3);

        DirectionalLight sun4 = new DirectionalLight();
        sun4.setDirection(new Vector3f(1, 0, 0).normalizeLocal());
        sun4.setColor(ColorRGBA.White);
        n.addLight(sun4);

        DirectionalLight sun5 = new DirectionalLight();
        sun5.setDirection(new Vector3f(-1, 0, 0).normalizeLocal());
        sun5.setColor(ColorRGBA.White);
        n.addLight(sun5);

        DirectionalLight sun6 = new DirectionalLight();
        sun6.setDirection(new Vector3f(0, -1, 0).normalizeLocal());
        sun6.setColor(ColorRGBA.White);
        n.addLight(sun6);

        DirectionalLight sun7 = new DirectionalLight();
        sun7.setDirection(new Vector3f(0, 0, -1).normalizeLocal());
        sun7.setColor(ColorRGBA.White);
        n.addLight(sun7);
        //</editor-fold>

        Main.getRN().attachChild(n); //Finally, attach the node to the root node.

        //</editor-fold>

        //Initialize text variables
        //<editor-fold defaultstate="collapsed" desc="Initialize Text Renderers">
        governmentInvestigationText = screen.findElementByName("GovernmentInvestigationText").getRenderer(TextRenderer.class);
        computersInfectedText = screen.findElementByName("InfectedText").getRenderer(TextRenderer.class);
        moneyMadeText = screen.findElementByName("MoneyText").getRenderer(TextRenderer.class);
        destructionDoneText = screen.findElementByName("DestructionText").getRenderer(TextRenderer.class);
        //</editor-fold>


    }

更新

http(冒号)//puu(dot)sh/9su8k/3910c2365a(dot)png

在弄清楚如何使用命令提示符后,我发现了一个“非法参数异常”。它抱怨给定的根路径“C:\Users\Dean\Dist\Assets\Interface”不是一个目录,但是我在编译器中没有得到它。那有什么意思?我把这个从 ClassMenu 转移到 MalwareHub。

附:我在 main 中将 Assets/Interface 注册为我的资产管理器的定位器。

【问题讨论】:

  • 首先,如果您必须绕过过滤器来发布您的问题,这很好地表明您应该做一些不同的事情。在这种特殊情况下,我们更希望所有相关代码都嵌入到问题中。其次,如果您希望任何人真正帮助您,请不要给我们 1100 行代码/消息。没有人有时间或耐心花那么多时间筛选别人的代码来寻找错误。您应该构建一个具有等效错误的小代码示例,然后将其提供给我们。另外,如果您的代码编译,您的构建日志可能无关紧要。
  • :( 抱歉。如果你能告诉我这里可能发生的事情,那就太好了;我宁愿自己做,但我不知道是什么导致了问题只弄乱了构建。而且我真的不知道代码的哪一部分弄乱了,所以除了给你这两个类之外,我无法重新创建错误。不管我已经将代码发布到问题中并尝试包括“重要部分”
  • 这本身不是一个答案,而是一些值得考虑的事情的建议。 (1)NiftyGui 吞下所有异常。这(imo)真的很愚蠢,但就这样吧。这意味着您应该在 nifty 和您的代码之间放置某种自定义错误处理。 (2) 大多数时候,当我遇到代码在 IDE 中工作但在其他任何地方都没有的问题时,这是因为没有捆绑所有需要的资源。您是使用 AssetManager 还是使用传统的 java 加载图像等。如果稍后您需要确保包含包含您的图像的文件夹以及 JAR
  • 重新更新;是什么产生了这个异常? (什么是堆栈跟踪)。所有 JMonkey 都喜欢 / 路径分隔符而不是 `` 分隔符
  • 从ClassMenu转到MalwareHub时出现异常。

标签: java netbeans build jmonkeyengine nifty-gui


【解决方案1】:

http://puu.sh/9wml6/50eed968f8.png

实际发生的事情是我注册了我之前谈到的那个定位器,我不应该这样做。 随后,在我的 xml 中,我(不小心)忘记将 Interface/ 放在文件名前面。这在编译器中有效,因为从 Jmonkey 的角度来看,Assets/Interface 是一个实际的文件夹,但在构建中,所有内容都应该从 assets.jar 中访问。这就是它抱怨 Assets/Interface 文件夹不存在的原因。

感谢您的帮助!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-09-02
    • 1970-01-01
    • 2018-10-30
    • 1970-01-01
    • 2015-09-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多