javalibgdxtexturestexturepacker

Split parameter in a texture atlas file?


How exactly works the split parameter in a skin.atlas file. Libgdx texture packer creates these from 9-patches I believe. I need to manually add these sometimes (when using the texturepacker in the linked tag or when manually inserting/editing a texture) and cant seem to figure it out how they exactly work. Sometimes a single pixel makes my elements disappear or does not fill the split.

Here is a example files:

roundtext138.png
format: RGBA8888
filter: Nearest,Nearest
repeat: none
button
  rotate: false
  xy: 0, 0
  size: 46, 46
  split: 22, 22, 22, 22
  orig: 46, 46
  offset: 0, 0
  index: -1

Solution

  • The Libgdx texture packer should generate the split/padding parameters you see in the atlas from the metadata in the .9.png file. Those numbers represent the startX, endX, startY, endY of the stretchable area (the middle section of the 9-element grid). See the source code that generates the splits array for more details. (You can see the splits information being written out to the atlas in TexturePacker.java.)