MariuszP

Hi,

How can I check the total width and height of the currently displayed frame in runtime?
MariuszP
Posts: 4

Nate

float minX = Float.MAX_VALUE, minY = Float.MAX_VALUE, maxX = Float.MIN_VALUE, maxY = Float.MIN_VALUE;
for (int i = 0, n = skeleton.skeleton.getSlots().size; i < n; i++) {
   Slot slot = skeleton.getSlots().get(i);
   Attachment attachment = slot.getAttachment();
   if (attachment == null) continue;
   if (!(attachment instanceof RegionAttachment)) continue;
   RegionAttachment imageRegion = (RegionAttachment)attachment;
   imageRegion.updateWorldVertices(slot.getBone());
   float[] vertices = imageRegion.getWorldVertices();
   for (int ii = 0, nn = vertices.length; ii < nn; ii += 5) {
      minX = Math.min(minX, vertices[ii]);
      minY = Math.min(minY, vertices[ii + 1]);
      maxX = Math.max(maxX, vertices[ii]);
      maxY = Math.max(maxY, vertices[ii + 1]);
   }
}
Maybe I'll add a method to Skeleton to do this.
User avatar
Nate
Posts: 3577

DoobyDude

Sorry to drag up an old post, but was this method ever added?

Is it possible to get the current width and height of the current frame at runtime?
DoobyDude
Posts: 76

Shiu

see http://esotericsoftware.com/forum/viewtopic.php?f=3&t=1465 afraid I don't know if the method was added.
User avatar
Shiu
Posts: 804

Nate

No, I haven't gotten to it. You'll have to use code similar to the above for now.
User avatar
Nate
Posts: 3577


Return to Editor