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

將 scene2d.ui 與 libgdx 一起使用:皮膚從何而來?

Using scene2d.ui with libgdx: where does the skin come from?(將 scene2d.ui 與 libgdx 一起使用:皮膚從何而來?)
本文介紹了將 scene2d.ui 與 libgdx 一起使用:皮膚從何而來?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

我已了解 libgdx 的 scene2d 功能,包括 UI 元素,但我不能讓他們工作.他們似乎都使用了一個皮膚對象,我該如何創建一個?

I've read about libgdx's scene2d features, including the UI elements, but I can't get them to work. They all seem to use a skin object, how do I create one?

我已經完成了創建簡單 libgdx 的 不錯的教程在桶中捕捉雨滴的游戲,我通過加載帶有紋理圖集的圖像創建了一個簡單的棋盤游戲應用程序.但是,scene2d 聽起來是一種更好的方式來控制棋盤游戲應用程序中的移動棋子以及任何按鈕和菜單.

I've gone through the nice tutorial that creates a simple libgdx game catching raindrops in a bucket, and I've created a simple board game app by loading images with a texture atlas. However, scene2d sounds like a better way to control the moving pieces in a board game app, as well as any buttons and menus.

推薦答案

要加載皮膚,您可以從 libgdx 測試項目中使用的示例皮膚文件開始.

To load a skin, you can start with the sample skin files used in the libgdx test project.

  1. Atlaspack 文件
  2. Json 文件
  3. Atlaspack 圖片
  4. 字體文件

this question 中有更多細節,我發現我必須將文件移動到資產以避免 HTML 版本中的錯誤.(如果我將文件留在 assets 文件夾中,我會看到一條錯誤消息,例如GwtApplication: exception: Error reading file data/uiskin.json.")

There's a bit more detail in this question, and I found that I had to move the files into a subdirectory of assets to avoid a bug in the HTML version. (If I leave files in the assets folder, I see an error message like, "GwtApplication: exception: Error reading file data/uiskin.json.")

我發布了一個顯示單個按鈕的完整示例,并且有趣的代碼都在 游戲類.該示例非常簡單,您只需要兩個成員變量來保存場景和按鈕.

I posted a complete example that displays a single button, and the interesting code is all in the game class. The example is so simple that you only need two member variables to hold the scene and the button.

private Stage stage;
private TextButton button;

要創建皮膚,您只需加載數據文件.

To create the skin, you just load the data file.

Skin skin = new Skin(Gdx.files.internal("data/uiskin.json"));

將按鈕連接到舞臺.

stage = new Stage();
button = new TextButton("Click Me!", skin);
stage.addActor(button);

將監聽器連接到按鈕,并注冊舞臺以接收事件.

Wire a listener into the button, and register the stage to receive events.

button.addListener(new ClickListener() {
    @Override
    public void clicked(InputEvent event, float x, float y) {
        button.setText("Clicked!");
    }
});
Gdx.input.setInputProcessor(stage);

render() 方法基本上是對 stage.draw() 的調用.

The render() method is basically a call to stage.draw().

Gdx.gl.glClearColor(1, 1, 1, 1);
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);

stage.act(Math.min(Gdx.graphics.getDeltaTime(), 1 / 30f));
stage.draw();

那么你只需要在調整屏幕大小時對屏幕進行布局.

Then you just need to layout the screen when it resizes.

button.setPosition(
        (width-button.getWidth())/2, 
        (height-button.getHeight())/2);

如果您的屏幕更復雜,請考慮使用 Table.

If your screen is more complicated, consider using a Table.

如果您想使用不同的字體,可以使用 生成字體文件和圖像文件希羅.完成后,您必須獲取新字體圖像并使用 TexturePacker 將其與其他 皮膚資源.

If you want to use a different font, you can generate the font file and image file using Hiero. After you've done that, you'll have to take the new font image and use the TexturePacker to repack it with the other skin assets.

這篇關于將 scene2d.ui 與 libgdx 一起使用:皮膚從何而來?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

相關文檔推薦

Parsing an ISO 8601 string local date-time as if in UTC(解析 ISO 8601 字符串本地日期時間,就像在 UTC 中一樣)
How to convert Gregorian string to Gregorian Calendar?(如何將公歷字符串轉換為公歷?)
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 日之前日期的日歷到日期轉換.公歷到儒略歷切換)
java Calendar setFirstDayOfWeek not working(java日歷setFirstDayOfWeek不起作用)
Java: getting current Day of the Week value(Java:獲取當前星期幾的值)
主站蜘蛛池模板: 久久精品福利视频 | 欧美精品一区二区三区在线 | 亚洲第一av | 欧美一区二区三区视频 | 91麻豆精品国产91久久久更新资源速度超快 | 国产日韩欧美一区 | 国产福利视频在线观看 | 亚洲精品一 | 91精品国产91久久久久久密臀 | 免费三级av | 狠狠操天天操 | 精品国产高清一区二区三区 | ww 255hh 在线观看 | 成人一区二| 亚洲一区在线播放 | 成人精品在线视频 | 免费一二区 | 狠狠久久综合 | 国产一区二区三区www | 亚洲视频一区在线观看 | 久久国产精品一区二区 | 中文字幕在线观看国产 | 精品久久久久久 | 久久久久久久久久影视 | 日韩欧美在线视频 | 久久久久久国产免费视网址 | 在线免费毛片 | 国产一在线观看 | 国产一区二区免费在线 | 91中文在线观看 | 狠狠躁18三区二区一区 | 99久久久久 | 91精品国产91久久久久久最新 | 午夜免费观看网站 | 久久久国产精品 | 成人做爰www免费看视频网站 | 欧美精品久久 | 99精品一区二区三区 | 国产a区 | 91在线精品一区二区 | 91美女在线|