diff --git a/spine-libgdx/spine-libgdx-tests/assets/spineboy/frame-by-frame-death.png b/spine-libgdx/spine-libgdx-tests/assets/spineboy/frame-by-frame-death.png new file mode 100644 index 000000000..80cac6115 Binary files /dev/null and b/spine-libgdx/spine-libgdx-tests/assets/spineboy/frame-by-frame-death.png differ diff --git a/spine-libgdx/spine-libgdx-tests/assets/spineboy/frame-by-frame-walk.png b/spine-libgdx/spine-libgdx-tests/assets/spineboy/frame-by-frame-walk.png new file mode 100644 index 000000000..890fa9763 Binary files /dev/null and b/spine-libgdx/spine-libgdx-tests/assets/spineboy/frame-by-frame-walk.png differ diff --git a/spine-libgdx/spine-libgdx-tests/assets/spineboy/frame-by-frame.atlas b/spine-libgdx/spine-libgdx-tests/assets/spineboy/frame-by-frame.atlas new file mode 100644 index 000000000..e46cc5f7e --- /dev/null +++ b/spine-libgdx/spine-libgdx-tests/assets/spineboy/frame-by-frame.atlas @@ -0,0 +1,357 @@ +frame-by-frame-death.png +size:1863,362 +pma:true +spineboy-pro-death +index:1 +bounds:1,143,107,218 +offsets:171,18,280,265 +origin:215,19 +spineboy-pro-death +index:9 +bounds:1,9,155,133 +offsets:88,117,280,265 +origin:215,19 +spineboy-pro-death +index:29 +bounds:109,145,216,88 +offsets:1,15,280,265 +rotate:90 +origin:215,19 +spineboy-pro-death +index:7 +bounds:157,13,131,171 +offsets:133,94,280,265 +rotate:90 +origin:215,19 +spineboy-pro-death +index:2 +bounds:198,146,115,215 +offsets:165,26,280,265 +origin:215,19 +spineboy-pro-death +index:3 +bounds:314,149,120,212 +offsets:158,35,280,265 +origin:215,19 +spineboy-pro-death +index:8 +bounds:329,1,147,155 +offsets:109,105,280,265 +rotate:90 +origin:215,19 +spineboy-pro-death +index:28 +bounds:435,149,212,89 +offsets:3,17,280,265 +rotate:90 +origin:215,19 +spineboy-pro-death +index:5 +bounds:485,2,146,201 +offsets:132,59,280,265 +rotate:90 +origin:215,19 +spineboy-pro-death +index:17 +bounds:525,150,211,92 +offsets:16,17,280,265 +rotate:90 +origin:215,19 +spineboy-pro-death +index:4 +bounds:618,152,128,209 +offsets:146,44,280,265 +origin:215,19 +spineboy-pro-death +index:6 +bounds:687,2,149,182 +offsets:124,82,280,265 +rotate:90 +origin:215,19 +spineboy-pro-death +index:0 +bounds:747,154,82,207 +offsets:175,17,280,265 +origin:215,19 +spineboy-pro-death +index:18 +bounds:830,158,203,98 +offsets:25,12,280,265 +rotate:90 +origin:215,19 +spineboy-pro-death +index:14 +bounds:870,6,151,115 +offsets:44,28,280,265 +rotate:90 +origin:215,19 +spineboy-pro-death +index:27 +bounds:929,158,203,95 +offsets:8,17,280,265 +rotate:90 +origin:215,19 +spineboy-pro-death +index:13 +bounds:986,8,149,110 +offsets:49,75,280,265 +rotate:90 +origin:215,19 +spineboy-pro-death +index:20 +bounds:1025,159,202,112 +offsets:15,13,280,265 +rotate:90 +origin:215,19 +spineboy-pro-death +index:12 +bounds:1097,1,157,107 +offsets:55,94,280,265 +rotate:90 +origin:215,19 +spineboy-pro-death +index:19 +bounds:1138,162,199,106 +offsets:23,16,280,265 +rotate:90 +origin:215,19 +spineboy-pro-death +index:10 +bounds:1205,2,159,117 +offsets:74,118,280,265 +rotate:90 +origin:215,19 +spineboy-pro-death +index:16 +bounds:1245,163,198,104 +offsets:12,19,280,265 +rotate:90 +origin:215,19 +spineboy-pro-death +index:11 +bounds:1323,3,159,110 +offsets:63,107,280,265 +rotate:90 +origin:215,19 +spineboy-pro-death +index:21 +bounds:1350,164,197,109 +offsets:14,16,280,265 +rotate:90 +origin:215,19 +spineboy-pro-death +index:15 +bounds:1434,46,177,117 +offsets:21,19,280,265 +origin:215,19 +spineboy-pro-death +index:23 +bounds:1460,164,197,106 +offsets:18,18,280,265 +rotate:90 +origin:215,19 +spineboy-pro-death +index:24 +bounds:1567,167,194,105 +offsets:22,18,280,265 +rotate:90 +origin:215,19 +spineboy-pro-death +index:22 +bounds:1673,254,189,107 +offsets:16,17,280,265 +origin:215,19 +spineboy-pro-death +index:25 +bounds:1673,150,189,103 +offsets:25,18,280,265 +origin:215,19 +spineboy-pro-death +index:26 +bounds:1612,49,192,100 +offsets:19,18,280,265 +origin:215,19 + +frame-by-frame-walk.png +size:1227,588 +pma:true +spineboy-pro-walk +index:25 +bounds:1,499,88,202 +offsets:29,4,151,210 +rotate:90 +origin:59,3 +spineboy-pro-walk +index:11 +bounds:204,496,91,206 +offsets:28,2,151,210 +rotate:90 +origin:59,3 +spineboy-pro-walk +index:24 +bounds:411,496,91,200 +offsets:24,4,151,210 +rotate:90 +origin:59,3 +spineboy-pro-walk +index:23 +bounds:612,493,94,198 +offsets:19,4,151,210 +rotate:90 +origin:59,3 +spineboy-pro-walk +index:26 +bounds:811,493,94,204 +offsets:25,4,151,210 +rotate:90 +origin:59,3 +spineboy-pro-walk +index:10 +bounds:1016,492,95,205 +offsets:32,1,151,210 +rotate:90 +origin:59,3 +spineboy-pro-walk +index:22 +bounds:1,402,96,196 +offsets:15,4,151,210 +rotate:90 +origin:59,3 +spineboy-pro-walk +index:12 +bounds:198,399,96,207 +offsets:24,2,151,210 +rotate:90 +origin:59,3 +spineboy-pro-walk +index:27 +bounds:406,398,97,205 +offsets:22,3,151,210 +rotate:90 +origin:59,3 +spineboy-pro-walk +index:13 +bounds:612,393,99,209 +offsets:21,1,151,210 +rotate:90 +origin:59,3 +spineboy-pro-walk +index:21 +bounds:822,392,99,195 +offsets:10,4,151,210 +rotate:90 +origin:59,3 +spineboy-pro-walk +index:14 +bounds:1018,390,101,208 +offsets:18,1,151,210 +rotate:90 +origin:59,3 +spineboy-pro-walk +index:20 +bounds:1,298,103,194 +offsets:6,4,151,210 +rotate:90 +origin:59,3 +spineboy-pro-walk +index:28 +bounds:196,295,103,205 +offsets:18,3,151,210 +rotate:90 +origin:59,3 +spineboy-pro-walk +index:15 +bounds:402,293,104,207 +offsets:14,0,151,210 +rotate:90 +origin:59,3 +spineboy-pro-walk +index:9 +bounds:610,286,106,203 +offsets:29,1,151,210 +rotate:90 +origin:59,3 +spineboy-pro-walk +index:19 +bounds:814,283,108,196 +offsets:2,4,151,210 +rotate:90 +origin:59,3 +spineboy-pro-walk +index:16 +bounds:1011,282,107,205 +offsets:9,0,151,210 +rotate:90 +origin:59,3 +spineboy-pro-walk +index:17 +bounds:1,184,110,201 +offsets:3,2,151,210 +rotate:90 +origin:59,3 +spineboy-pro-walk +index:18 +bounds:203,183,111,198 +offsets:0,3,151,210 +rotate:90 +origin:59,3 +spineboy-pro-walk +index:8 +bounds:402,176,116,201 +offsets:25,1,151,210 +rotate:90 +origin:59,3 +spineboy-pro-walk +index:29 +bounds:604,168,117,204 +offsets:15,2,151,210 +rotate:90 +origin:59,3 +spineboy-pro-walk +index:7 +bounds:809,153,129,199 +offsets:16,1,151,210 +rotate:90 +origin:59,3 +spineboy-pro-walk +index:0 +bounds:1009,152,129,203 +offsets:12,2,151,210 +rotate:90 +origin:59,3 +spineboy-pro-walk +index:6 +bounds:1,45,138,197 +offsets:10,2,151,210 +rotate:90 +origin:59,3 +spineboy-pro-walk +index:1 +bounds:199,43,139,201 +offsets:6,2,151,210 +rotate:90 +origin:59,3 +spineboy-pro-walk +index:5 +bounds:401,31,144,196 +offsets:6,2,151,210 +rotate:90 +origin:59,3 +spineboy-pro-walk +index:2 +bounds:598,22,145,200 +offsets:3,1,151,210 +rotate:90 +origin:59,3 +spineboy-pro-walk +index:4 +bounds:799,4,148,197 +offsets:2,2,151,210 +rotate:90 +origin:59,3 +spineboy-pro-walk +index:3 +bounds:997,1,150,198 +offsets:0,2,151,210 +rotate:90 +origin:59,3 diff --git a/spine-libgdx/spine-libgdx-tests/src/com/esotericsoftware/spine/FrameByFrameTest.java b/spine-libgdx/spine-libgdx-tests/src/com/esotericsoftware/spine/FrameByFrameTest.java new file mode 100644 index 000000000..fe1727ba6 --- /dev/null +++ b/spine-libgdx/spine-libgdx-tests/src/com/esotericsoftware/spine/FrameByFrameTest.java @@ -0,0 +1,104 @@ +/****************************************************************************** + * Spine Runtimes License Agreement + * Last updated January 1, 2020. Replaces all prior versions. + * + * Copyright (c) 2013-2020, Esoteric Software LLC + * + * Integration of the Spine Runtimes into software or otherwise creating + * derivative works of the Spine Runtimes is permitted under the terms and + * conditions of Section 2 of the Spine Editor License Agreement: + * http://esotericsoftware.com/spine-editor-license + * + * Otherwise, it is permitted to integrate the Spine Runtimes into software + * or otherwise create derivative works of the Spine Runtimes (collectively, + * "Products"), provided that each user of the Products must obtain their own + * Spine Editor license and redistribution of the Products in any form must + * include this license and copyright notice. + * + * THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, + * BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + *****************************************************************************/ + +package com.esotericsoftware.spine; + +import com.badlogic.gdx.ApplicationAdapter; +import com.badlogic.gdx.Gdx; +import com.badlogic.gdx.backends.lwjgl.LwjglApplication; +import com.badlogic.gdx.graphics.GL20; +import com.badlogic.gdx.graphics.OrthographicCamera; +import com.badlogic.gdx.graphics.g2d.Animation; +import com.badlogic.gdx.graphics.g2d.Animation.PlayMode; +import com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch; +import com.badlogic.gdx.graphics.g2d.TextureAtlas; +import com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasSprite; + +public class FrameByFrameTest extends ApplicationAdapter { + OrthographicCamera camera; + PolygonSpriteBatch batch; + + TextureAtlas atlas; + float time; + Animation walkAnimation, deathAnimation, current; + + public void create () { + camera = new OrthographicCamera(); + batch = new PolygonSpriteBatch(); + + atlas = new TextureAtlas("spineboy/frame-by-frame.atlas"); + + walkAnimation = new Animation(1 / 20f, atlas.createSprites("spineboy-pro-walk")); + walkAnimation.setPlayMode(PlayMode.LOOP); + + deathAnimation = new Animation(1 / 20f, atlas.createSprites("spineboy-pro-death")); + + current = walkAnimation; + } + + public void render () { + time += Gdx.graphics.getDeltaTime(); + if (current == deathAnimation && current.isAnimationFinished(time)) { + current = walkAnimation; + time = 0; + } + if (Gdx.input.justTouched()) { + current = deathAnimation; + time = 0; + } + + AtlasSprite frame = current.getKeyFrame(time); + float x = Math.round(Gdx.graphics.getWidth() / 2), y = 25; + int[] origin = frame.getAtlasRegion().findValue("origin"); + x -= origin[0]; + y -= origin[1]; + frame.setPosition(x, y); + + Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); + + camera.update(); + batch.getProjectionMatrix().set(camera.combined); + + batch.begin(); + frame.draw(batch); + batch.end(); + } + + public void resize (int width, int height) { + camera.setToOrtho(false); // Update camera with new size. + } + + public void dispose () { + atlas.dispose(); + } + + public static void main (String[] args) throws Exception { + new LwjglApplication(new FrameByFrameTest()); + } +}