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

將 scene2d.ui 與 libgdx 一起使用:皮膚從何而來(lái)?

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

問(wèn)題描述

限時(shí)送ChatGPT賬號(hào)..

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

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?

我已經(jīng)完成了創(chuàng)建簡(jiǎn)單 libgdx 的 不錯(cuò)的教程在桶中捕捉雨滴的游戲,我通過(guò)加載帶有紋理圖集的圖像創(chuàng)建了一個(gè)簡(jiǎn)單的棋盤(pán)游戲應(yīng)用程序.但是,scene2d 聽(tīng)起來(lái)是一種更好的方式來(lái)控制棋盤(pán)游戲應(yīng)用程序中的移動(dòng)棋子以及任何按鈕和菜單.

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 測(cè)試項(xiàng)目中使用的示例皮膚文件開(kāi)始.

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 中有更多細(xì)節(jié),我發(fā)現(xiàn)我必須將文件移動(dòng)到資產(chǎn)以避免 HTML 版本中的錯(cuò)誤.(如果我將文件留在 assets 文件夾中,我會(huì)看到一條錯(cuò)誤消息,例如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.")

我發(fā)布了一個(gè)顯示單個(gè)按鈕的完整示例,并且有趣的代碼都在 游戲類(lèi).該示例非常簡(jiǎn)單,您只需要兩個(gè)成員變量來(lái)保存場(chǎng)景和按鈕.

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;

要?jiǎng)?chuàng)建皮膚,您只需加載數(shù)據(jù)文件.

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

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

將按鈕連接到舞臺(tái).

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

將監(jiān)聽(tīng)器連接到按鈕,并注冊(cè)舞臺(tái)以接收事件.

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() 方法基本上是對(duì) stage.draw() 的調(diào)用.

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();

那么你只需要在調(diào)整屏幕大小時(shí)對(duì)屏幕進(jìn)行布局.

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

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

如果您的屏幕更復(fù)雜,請(qǐng)考慮使用 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.

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

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

相關(guān)文檔推薦

Parsing an ISO 8601 string local date-time as if in UTC(解析 ISO 8601 字符串本地日期時(shí)間,就像在 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:獲取當(dāng)前星期幾的值)
主站蜘蛛池模板: 亚洲3p | 国产伦精品一区二区三区精品视频 | 91免费视频 | 国产日韩欧美激情 | 欧美二区在线 | 综合国产 | 欧美日韩看片 | 欧美日韩久久久久 | 日韩黄 | 激情婷婷 | 日本久久久久久久久 | 国产亚洲精品91 | 成人免费一区二区三区牛牛 | 日韩高清av | 天天干天天色 | 一级黄色毛片免费 | 二区在线观看 | 婷婷免费视频 | 国产精品久久久久久久久久久新郎 | 99re| 91综合网| 国产乱xxav| 一区二区三区韩国 | 男女视频在线看 | 色偷偷噜噜噜亚洲男人 | 久久香蕉网 | 亚洲国产精品一区二区第一页 | 亚洲a人 | 成年精品 | 污片在线免费观看 | www.99热 | 中文字幕一区在线观看视频 | 黄色一级片aaa | 国产91在线 | 欧美 | 国产精品久久久久久久久久三级 | 国产精品久久久久无码av | 在线精品亚洲欧美日韩国产 | 久久久久久久久久久久亚洲 | 国产精品九九九 | 国产成年人小视频 | 精品av天堂毛片久久久借种 |