mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-20 09:16:01 +08:00
[libgdx] Add second physics test to tests
This commit is contained in:
parent
02773518b1
commit
cceaf31107
@ -44,10 +44,7 @@ cp -f ../sack/export/sack-pma.png "$ROOT/spine-libgdx/spine-libgdx-tests/assets/
|
||||
|
||||
rm -f "$ROOT/spine-libgdx/spine-libgdx-tests/assets/celestial-circus/"*
|
||||
mkdir -p "$ROOT/spine-libgdx/spine-libgdx-tests/assets/celestial-circus/"
|
||||
cp -f ../celestial-circus/export/celestial-circus-pro.json "$ROOT/spine-libgdx/spine-libgdx-tests/assets/celestial-circus/"
|
||||
cp -f ../celestial-circus/export/celestial-circus-pro.skel "$ROOT/spine-libgdx/spine-libgdx-tests/assets/celestial-circus/"
|
||||
cp -f ../celestial-circus/export/celestial-circus-pma.atlas "$ROOT/spine-libgdx/spine-libgdx-tests/assets/celestial-circus/"
|
||||
cp -f ../celestial-circus/export/celestial-circus-pma.png "$ROOT/spine-libgdx/spine-libgdx-tests/assets/celestial-circus/"
|
||||
cp -f ../celestial-circus/export/* "$ROOT/spine-libgdx/spine-libgdx-tests/assets/celestial-circus/"
|
||||
|
||||
echo "spine-cocos2d-objc"
|
||||
rm "$ROOT/spine-cocos2d-objc/Resources/"*
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 466 KiB |
@ -0,0 +1,168 @@
|
||||
celestial-circus.png
|
||||
size: 1024, 1024
|
||||
filter: Linear, Linear
|
||||
scale: 0.5
|
||||
arm-back-down
|
||||
bounds: 944, 3, 48, 103
|
||||
arm-front-down
|
||||
bounds: 241, 56, 45, 98
|
||||
bench
|
||||
bounds: 2, 94, 237, 60
|
||||
body-bottom
|
||||
bounds: 674, 8, 193, 156
|
||||
rotate: 90
|
||||
collar
|
||||
bounds: 822, 352, 59, 33
|
||||
ear
|
||||
bounds: 997, 185, 25, 35
|
||||
eye-back-shadow
|
||||
bounds: 1004, 978, 18, 12
|
||||
eye-front-shadow
|
||||
bounds: 1004, 992, 30, 18
|
||||
rotate: 90
|
||||
eye-reflex-back
|
||||
bounds: 822, 341, 10, 9
|
||||
eye-reflex-front
|
||||
bounds: 525, 699, 13, 9
|
||||
rotate: 90
|
||||
eye-white-back
|
||||
bounds: 956, 963, 16, 20
|
||||
eye-white-front
|
||||
bounds: 551, 179, 28, 22
|
||||
eyelashes-down-back
|
||||
bounds: 980, 325, 14, 7
|
||||
rotate: 90
|
||||
eyelashes-down-front
|
||||
bounds: 979, 1003, 19, 8
|
||||
rotate: 90
|
||||
eyelashes-top-back
|
||||
bounds: 997, 118, 23, 12
|
||||
rotate: 90
|
||||
eyelashes-top-front
|
||||
bounds: 956, 985, 37, 21
|
||||
rotate: 90
|
||||
feathers-front
|
||||
bounds: 2, 2, 90, 108
|
||||
rotate: 90
|
||||
fringe-middle-back
|
||||
bounds: 980, 222, 42, 65
|
||||
fringe-side-back
|
||||
bounds: 944, 222, 34, 117
|
||||
fringe-side-front
|
||||
bounds: 989, 289, 33, 116
|
||||
hair-back-1
|
||||
bounds: 289, 2, 166, 383
|
||||
rotate: 90
|
||||
hair-back-2
|
||||
bounds: 887, 341, 100, 356
|
||||
hair-back-4
|
||||
bounds: 832, 11, 110, 328
|
||||
hair-hat-shadow
|
||||
bounds: 944, 108, 112, 51
|
||||
rotate: 90
|
||||
hat-front
|
||||
bounds: 112, 22, 121, 70
|
||||
leg-front
|
||||
bounds: 554, 699, 323, 400
|
||||
rotate: 90
|
||||
logo-brooch
|
||||
bounds: 505, 170, 20, 31
|
||||
mouth
|
||||
bounds: 279, 26, 28, 8
|
||||
rotate: 90
|
||||
nose
|
||||
bounds: 279, 15, 8, 9
|
||||
nose-shadow
|
||||
bounds: 834, 341, 9, 10
|
||||
rotate: 90
|
||||
nose.-highlight
|
||||
bounds: 551, 171, 5, 6
|
||||
pupil-back
|
||||
bounds: 505, 699, 13, 18
|
||||
rotate: 90
|
||||
pupil-front
|
||||
bounds: 112, 5, 15, 22
|
||||
rotate: 90
|
||||
rope-back
|
||||
bounds: 989, 407, 13, 615
|
||||
rope-front
|
||||
bounds: 989, 407, 13, 615
|
||||
skirt
|
||||
bounds: 2, 714, 550, 308
|
||||
sock-bow
|
||||
bounds: 235, 14, 42, 40
|
||||
spine-logo-body
|
||||
bounds: 997, 143, 16, 40
|
||||
star-big
|
||||
bounds: 527, 171, 22, 30
|
||||
star-medium
|
||||
bounds: 1015, 173, 7, 10
|
||||
star-small
|
||||
bounds: 674, 2, 4, 6
|
||||
rotate: 90
|
||||
underskirt
|
||||
bounds: 2, 156, 556, 285
|
||||
rotate: 90
|
||||
underskirt-back
|
||||
bounds: 289, 170, 542, 214
|
||||
rotate: 90
|
||||
wing-back
|
||||
bounds: 505, 203, 182, 315
|
||||
rotate: 90
|
||||
wing-front
|
||||
bounds: 505, 387, 380, 310
|
||||
|
||||
celestial-circus_2.png
|
||||
size: 1024, 1024
|
||||
filter: Linear, Linear
|
||||
scale: 0.5
|
||||
arm-back-up
|
||||
bounds: 490, 683, 104, 145
|
||||
rotate: 90
|
||||
arm-front-up
|
||||
bounds: 162, 23, 96, 145
|
||||
body-top
|
||||
bounds: 2, 2, 158, 166
|
||||
chest
|
||||
bounds: 744, 878, 130, 117
|
||||
cloud-back
|
||||
bounds: 490, 789, 252, 206
|
||||
cloud-front
|
||||
bounds: 2, 170, 406, 245
|
||||
rotate: 90
|
||||
face
|
||||
bounds: 876, 879, 116, 128
|
||||
rotate: 90
|
||||
feathers-back
|
||||
bounds: 266, 578, 57, 57
|
||||
fringe-middle-front
|
||||
bounds: 260, 105, 75, 63
|
||||
glove-bottom-back
|
||||
bounds: 325, 584, 64, 51
|
||||
glove-bottom-front
|
||||
bounds: 391, 585, 59, 61
|
||||
rotate: 90
|
||||
hair-back-3
|
||||
bounds: 249, 241, 87, 335
|
||||
hair-back-5
|
||||
bounds: 378, 646, 110, 349
|
||||
hair-back-6
|
||||
bounds: 266, 637, 110, 358
|
||||
hand-back
|
||||
bounds: 573, 622, 75, 59
|
||||
hand-front
|
||||
bounds: 637, 712, 67, 75
|
||||
hat-back
|
||||
bounds: 260, 23, 80, 56
|
||||
rotate: 90
|
||||
head-back
|
||||
bounds: 744, 768, 128, 108
|
||||
jabot
|
||||
bounds: 249, 170, 88, 69
|
||||
leg-back
|
||||
bounds: 2, 578, 262, 417
|
||||
neck
|
||||
bounds: 338, 511, 49, 71
|
||||
rope-front-bottom
|
||||
bounds: 490, 628, 53, 81
|
||||
rotate: 90
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 696 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 458 KiB |
@ -0,0 +1,109 @@
|
||||
/******************************************************************************
|
||||
* Spine Runtimes License Agreement
|
||||
* Last updated July 28, 2023. Replaces all prior versions.
|
||||
*
|
||||
* Copyright (c) 2013-2023, 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.lwjgl3.Lwjgl3Application;
|
||||
import com.badlogic.gdx.graphics.GL20;
|
||||
import com.badlogic.gdx.graphics.OrthographicCamera;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
|
||||
import com.esotericsoftware.spine.Skeleton.Physics;
|
||||
import com.esotericsoftware.spine.utils.TwoColorPolygonBatch;
|
||||
|
||||
/** Demonstrates loading, animating, and rendering a skeleton.
|
||||
* @see SkeletonAssetManagerTest */
|
||||
public class PhysicsTest2 extends ApplicationAdapter {
|
||||
OrthographicCamera camera;
|
||||
TwoColorPolygonBatch batch;
|
||||
SkeletonRenderer renderer;
|
||||
SkeletonRendererDebug debugRenderer;
|
||||
|
||||
TextureAtlas atlas;
|
||||
Skeleton skeleton;
|
||||
AnimationState state;
|
||||
|
||||
public void create () {
|
||||
camera = new OrthographicCamera();
|
||||
batch = new TwoColorPolygonBatch();
|
||||
renderer = new SkeletonRenderer();
|
||||
renderer.setPremultipliedAlpha(true); // PMA results in correct blending without outlines.
|
||||
debugRenderer = new SkeletonRendererDebug();
|
||||
debugRenderer.setBoundingBoxes(false);
|
||||
debugRenderer.setRegionAttachments(false);
|
||||
|
||||
atlas = new TextureAtlas(Gdx.files.internal("celestial-circus/celestial-circus-pma.atlas"));
|
||||
SkeletonBinary binary = new SkeletonBinary(atlas); // This loads skeleton JSON data, which is stateless.
|
||||
binary.setScale(0.2f); // Load the skeleton at 60% the size it was in Spine.
|
||||
SkeletonData skeletonData = binary.readSkeletonData(Gdx.files.internal("celestial-circus/celestial-circus-pro.skel"));
|
||||
|
||||
skeleton = new Skeleton(skeletonData); // Skeleton holds skeleton state (bone positions, slot attachments, etc).
|
||||
skeleton.setPosition(250, 100);
|
||||
|
||||
AnimationStateData stateData = new AnimationStateData(skeletonData); // Defines mixing (crossfading) between animations.
|
||||
state = new AnimationState(stateData); // Holds the animation state for a skeleton (current animation, time, etc).
|
||||
state.setAnimation(0, "swing", true);
|
||||
state.setAnimation(1, "eyeblink-long", true);
|
||||
}
|
||||
|
||||
public void render () {
|
||||
float delta = Gdx.graphics.getDeltaTime();
|
||||
state.update(delta); // Update the animation time.
|
||||
|
||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
||||
|
||||
state.apply(skeleton); // Poses skeleton using current animations. This sets the bones' local SRT.
|
||||
skeleton.update(delta);
|
||||
skeleton.updateWorldTransform(Physics.update); // Uses the bones' local SRT to compute their world SRT.
|
||||
|
||||
// Configure the camera, SpriteBatch, and SkeletonRendererDebug.
|
||||
camera.update();
|
||||
batch.getProjectionMatrix().set(camera.combined);
|
||||
debugRenderer.getShapeRenderer().setProjectionMatrix(camera.combined);
|
||||
|
||||
batch.begin();
|
||||
renderer.draw(batch, skeleton); // Draw the skeleton images.
|
||||
batch.end();
|
||||
|
||||
debugRenderer.draw(skeleton); // Draw debug lines.
|
||||
}
|
||||
|
||||
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 Lwjgl3Application(new PhysicsTest2());
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user