• Editor
  • frame width

Related Discussions
...

Hi,

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

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.

9달 후

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?

12일 후

No, I haven't gotten to it. You'll have to use code similar to the above for now.