久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

如何在 Swing 應(yīng)用程序中正確放置 libgdx 應(yīng)用程序

How to put properly a libgdx application inside swing application?(如何在 Swing 應(yīng)用程序中正確放置 libgdx 應(yīng)用程序?)
本文介紹了如何在 Swing 應(yīng)用程序中正確放置 libgdx 應(yīng)用程序?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

限時送ChatGPT賬號..

我正在為我的游戲創(chuàng)建關(guān)卡編輯器,但我在使用帶有 JFrame 的 LwjglCanvas 時遇到了問題.我使用 JFrame(不是 LwjglFrame)來保持引擎和關(guān)卡編輯器盡可能獨立.我有兩個 JAR:WorldEditor.jar 和 GameEngine.jar.在 WorldEditor 中,我有一個名為test"的按鈕,假設(shè)加載 GameEngine.jar(如果尚未加載)并啟動(如果已加載則重新啟動)到應(yīng)用程序主框架中.實際上,我所做的是將 WorldEditor 游戲容器(例如 JFrame 內(nèi)的 JPanel)注入游戲應(yīng)用程序,并使用 Gdx.app.postRunnable 將 lwjglcanvas 添加到注入的游戲容器中:

I'm creating a level editor for my game, and I ave a problem using LwjglCanvas with a JFrame. I use a JFrame (not a LwjglFrame) to keep engine and level editor as independent as possible. I have two JARs: WorldEditor.jar, and GameEngine.jar. Inside WorldEditor, I have a button called "test", that is suppose to load GameEngine.jar (if not already loaded) and launch (resart it if already loaded) it into the application main frame. Actually, what I do is injecting the WorldEditor game container (a JPanel inside the JFrame for example) to the game app, and use Gdx.app.postRunnable to add the lwjglcanvas to the injected game container :

世界編輯端:

JPanel _gameContainer = new JPanel(); // is inside a JFrame
MyGame game = loadGame(_gameContainer); // load the GameEngine JAR, and retrive the game

GameEngine 方面:

GameEngine side:

// container is the _gamecontainer of above
public void createGame(final Container gameContainer)  
{
    LwjglCanvas canvas = new LwjglCanvas(myapp, myconfig);
    Gdx.app.postRunnable(new Runnable()
    {
       public void run()
       {
           gameContainer.add(canvas.getCanvas());
       }
    });
}

事實是 postRunnable 從未被調(diào)用(由于應(yīng)用程序在可見之前不可見,我錯了嗎?)我已經(jīng)嘗試了很長時間,但沒有結(jié)果......

The fact is that the postRunnable is never called (due to the fact that the app doesn't before being visible, am I wrong ?) I have been trying for a long time but no result ...

有人知道我可以做些什么來解決這個問題嗎?或者至少是另一種(讓我們說更簡單)的方法來做到這一點?

Does someone have an idea of what I could do to fix this problem ? Or a least another (let's say easier) method to do that ?

推薦答案

你必須使用 SwingUtilites.invokelater 因為 postRunnable 發(fā)布到?jīng)]有運行的游戲循環(huán).我會嘗試從 MyGame 獲取一個組件并添加它.如果你返回一個組件,你就沒有一個 dep.到 LwjglCanvas.這不是很好,因為現(xiàn)在 MyGame 界面有一個 dep.揮桿,但值得一試,看看它是否能解決你的問題.

You have to use SwingUtilites.invokelater because postRunnable posts to the game loop which is not running. I would try to get a Component from MyGame and add this. If you return a Component you don't have a dep. to the LwjglCanvas. It's not that nice because now the MyGame Interface has a dep. to swing but it's worth a shot to see if its solves your problem.

這篇關(guān)于如何在 Swing 應(yīng)用程序中正確放置 libgdx 應(yīng)用程序?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Parsing an ISO 8601 string local date-time as if in UTC(解析 ISO 8601 字符串本地日期時間,就像在 UTC 中一樣)
How to convert Gregorian string to Gregorian Calendar?(如何將公歷字符串轉(zhuǎn)換為公歷?)
Java: What/where are the maximum and minimum values of a GregorianCalendar?(Java:GregorianCalendar 的最大值和最小值是什么/在哪里?)
Calendar to Date conversion for dates before 15 Oct 1582. Gregorian to Julian calendar switch(1582 年 10 月 15 日之前日期的日歷到日期轉(zhuǎn)換.公歷到儒略歷切換)
java Calendar setFirstDayOfWeek not working(java日歷setFirstDayOfWeek不起作用)
Java: getting current Day of the Week value(Java:獲取當前星期幾的值)
主站蜘蛛池模板: 欧美视频第二页 | 国产精品中文在线 | 国产中文在线观看 | 黄色片a级 | 亚洲国产精品第一区二区 | 色综久久 | 欧美男人天堂 | 久久久免费在线观看 | 日日干日日操 | 国产一区二区免费 | 五月精品视频 | 久久国产精品色av免费观看 | 久久伊人免费视频 | 夜夜骚| 国产一区二区三区免费 | 国产精品99视频 | 国产在线一区二区三区 | 欧美一级二级在线观看 | 一级国产精品一级国产精品片 | 福利精品在线观看 | 久久大陆 | 亚洲国产免费 | 久久综合影院 | 亚洲美女视频 | 亚洲精品一区二区三区蜜桃久 | 久久久国产一区二区三区四区小说 | 久久91精品国产一区二区 | 中文字幕观看 | 中国美女av | 波多野结衣精品 | 你懂的免费在线 | 伊人久久免费 | 日本又色又爽又黄的大片 | 黄色免费网站在线看 | 亚洲va在线va天堂va狼色在线 | 欧美精品乱码99久久影院 | 免费成人在线网站 | 日韩在线精品 | 一区二区三区四区五区在线视频 | 伊人网站| 欧美日韩在线视频一区二区 |