[英]Libgdx getting Animation width and height with atlas
我從libgdx開始,我想獲取動畫的大小。 我嘗試過:
width = atlas.findRegion("Idle_").getTexture().getWidth();
但是它給我的是“ 2048”,即精靈表格的寬度。 我使用“ gdx-texturepacker-3.2.0”將所有資產都放在一個帶有.atlas文件的Spritesheet中。
.atlas文件如下所示:
robotito.png
format: RGBA8888
filter: MipMap,MipMap
repeat: none
Idle_
rotate: false
xy: 1, 1117
size: 567, 556
orig: 567, 556
offset: 0, 0
index: 0
Idle_
rotate: false
xy: 1, 559
size: 567, 556
orig: 567, 556
offset: 0, 0
index: 1
我想獲得“大小:567、556”大小。 謝謝您的幫助。
從TextureRegion
的文檔中,這些可能可以幫助您:
- 公共詮釋getRegionHeight():
返回區域的高度。- 公共詮釋getRegionWidth():
返回區域的寬度。
您的“ idle_”是2個Sprite地圖集,因此您必須決定是否要使用第一個精靈或如何使用它。
TextureAtlas.AtlasRegion> tex = atlas.findRegion(“ Idle_”);
要獲取FIRST Sprite的寬度(索引0):tex.get(0).width
如果已打包,則可以通過以下方式獲取打包的值:tex.get(0).packedWidth
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.