mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-26 22:49:01 +08:00
[haxe] Fix Scene touch handling, fix PathConstraint
This commit is contained in:
parent
d12431d72c
commit
a7bb103ec9
@ -27,6 +27,7 @@
|
|||||||
* SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
import Scene.SceneManager;
|
||||||
import openfl.utils.Assets;
|
import openfl.utils.Assets;
|
||||||
import spine.SkeletonData;
|
import spine.SkeletonData;
|
||||||
import spine.animation.AnimationStateData;
|
import spine.animation.AnimationStateData;
|
||||||
@ -57,13 +58,16 @@ class BasicExample extends Scene {
|
|||||||
addChild(skeletonSprite);
|
addChild(skeletonSprite);
|
||||||
juggler.add(skeletonSprite);
|
juggler.add(skeletonSprite);
|
||||||
|
|
||||||
|
addText("Click anywhere for next scene");
|
||||||
|
|
||||||
addEventListener(TouchEvent.TOUCH, onTouch);
|
addEventListener(TouchEvent.TOUCH, onTouch);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onTouch(e:TouchEvent) {
|
public function onTouch(e:TouchEvent) {
|
||||||
var touch = e.getTouch(this);
|
var touch = e.getTouch(this);
|
||||||
|
trace(touch);
|
||||||
if (touch != null && touch.phase == TouchPhase.ENDED) {
|
if (touch != null && touch.phase == TouchPhase.ENDED) {
|
||||||
trace("Mouse clicked");
|
SceneManager.getInstance().switchScene(new SequenceExample());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -49,6 +49,6 @@ class Main extends Sprite {
|
|||||||
starlingSingleton.start();
|
starlingSingleton.start();
|
||||||
Starling.current.stage.color = 0x000000;
|
Starling.current.stage.color = 0x000000;
|
||||||
|
|
||||||
SceneManager.getInstance().switchScene(new BasicExample());
|
SceneManager.getInstance().switchScene(new VineExample());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
83
spine-haxe/example/src/MixAndMatchExample.hx
Normal file
83
spine-haxe/example/src/MixAndMatchExample.hx
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
* 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.
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
import spine.Skin;
|
||||||
|
import Scene.SceneManager;
|
||||||
|
import openfl.utils.Assets;
|
||||||
|
import spine.SkeletonData;
|
||||||
|
import spine.animation.AnimationStateData;
|
||||||
|
import spine.atlas.TextureAtlas;
|
||||||
|
import spine.starling.SkeletonSprite;
|
||||||
|
import spine.starling.StarlingTextureLoader;
|
||||||
|
import starling.core.Starling;
|
||||||
|
import starling.events.TouchEvent;
|
||||||
|
import starling.events.TouchPhase;
|
||||||
|
|
||||||
|
class MixAndMatchExample extends Scene {
|
||||||
|
var loadBinary = false;
|
||||||
|
|
||||||
|
public function load():Void {
|
||||||
|
var atlas = new TextureAtlas(Assets.getText("assets/mix-and-match.atlas"), new StarlingTextureLoader("assets/mix-and-match.atlas"));
|
||||||
|
var data = SkeletonData.from(loadBinary ? Assets.getBytes("assets/mix-and-match-pro.skel") : Assets.getText("assets/mix-and-match-pro.json"), atlas);
|
||||||
|
var animationStateData = new AnimationStateData(data);
|
||||||
|
animationStateData.defaultMix = 0.25;
|
||||||
|
|
||||||
|
var skeletonSprite = new SkeletonSprite(data, animationStateData);
|
||||||
|
var customSkin = new Skin("custom");
|
||||||
|
var skinBase = data.findSkin("skin-base");
|
||||||
|
customSkin.addSkin(skinBase);
|
||||||
|
customSkin.addSkin(data.findSkin("nose/short"));
|
||||||
|
customSkin.addSkin(data.findSkin("eyelids/girly"));
|
||||||
|
customSkin.addSkin(data.findSkin("eyes/violet"));
|
||||||
|
customSkin.addSkin(data.findSkin("hair/brown"));
|
||||||
|
customSkin.addSkin(data.findSkin("clothes/hoodie-orange"));
|
||||||
|
customSkin.addSkin(data.findSkin("legs/pants-jeans"));
|
||||||
|
customSkin.addSkin(data.findSkin("accessories/bag"));
|
||||||
|
customSkin.addSkin(data.findSkin("accessories/hat-red-yellow"));
|
||||||
|
skeletonSprite.skeleton.skin = customSkin;
|
||||||
|
|
||||||
|
var bounds = skeletonSprite.skeleton.getBounds();
|
||||||
|
skeletonSprite.scale = Starling.current.stage.stageHeight / bounds.height * 0.5;
|
||||||
|
skeletonSprite.x = Starling.current.stage.stageWidth / 2;
|
||||||
|
skeletonSprite.y = Starling.current.stage.stageHeight * 0.9;
|
||||||
|
skeletonSprite.state.setAnimationByName(0, "dance", true);
|
||||||
|
|
||||||
|
addChild(skeletonSprite);
|
||||||
|
juggler.add(skeletonSprite);
|
||||||
|
|
||||||
|
addEventListener(TouchEvent.TOUCH, onTouch);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function onTouch(e:TouchEvent) {
|
||||||
|
var touch = e.getTouch(this);
|
||||||
|
if (touch != null && touch.phase == TouchPhase.ENDED) {
|
||||||
|
SceneManager.getInstance().switchScene(new TankExample());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -27,6 +27,9 @@
|
|||||||
* SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
import starling.display.Quad;
|
||||||
|
import starling.geom.Rectangle;
|
||||||
|
import starling.text.TextField;
|
||||||
import starling.core.Starling;
|
import starling.core.Starling;
|
||||||
import starling.display.Sprite;
|
import starling.display.Sprite;
|
||||||
|
|
||||||
@ -60,8 +63,14 @@ class SceneManager {
|
|||||||
abstract class Scene extends Sprite {
|
abstract class Scene extends Sprite {
|
||||||
var juggler = new starling.animation.Juggler();
|
var juggler = new starling.animation.Juggler();
|
||||||
|
|
||||||
|
public var background:Quad;
|
||||||
|
|
||||||
public function new() {
|
public function new() {
|
||||||
super();
|
super();
|
||||||
|
var stageWidth = Starling.current.stage.stageWidth;
|
||||||
|
var stageHeight = Starling.current.stage.stageHeight;
|
||||||
|
background = new Quad(stageWidth, stageHeight, 0x0);
|
||||||
|
this.addChild(background);
|
||||||
Starling.current.juggler.add(juggler);
|
Starling.current.juggler.add(juggler);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,4 +81,13 @@ abstract class Scene extends Sprite {
|
|||||||
Starling.current.juggler.remove(juggler);
|
Starling.current.juggler.remove(juggler);
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function addText(text:String) {
|
||||||
|
var textField = new TextField(200, 30, text);
|
||||||
|
textField.x = 10;
|
||||||
|
textField.y = 10;
|
||||||
|
textField.format.color = 0xffffffff;
|
||||||
|
addChild(textField);
|
||||||
|
return textField;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,6 +27,7 @@
|
|||||||
* SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
|
import Scene.SceneManager;
|
||||||
import openfl.utils.Assets;
|
import openfl.utils.Assets;
|
||||||
import spine.SkeletonData;
|
import spine.SkeletonData;
|
||||||
import spine.animation.AnimationStateData;
|
import spine.animation.AnimationStateData;
|
||||||
@ -50,7 +51,7 @@ class SequenceExample extends Scene {
|
|||||||
var bounds = skeletonSprite.skeleton.getBounds();
|
var bounds = skeletonSprite.skeleton.getBounds();
|
||||||
skeletonSprite.scale = Starling.current.stage.stageWidth / bounds.width * 0.5;
|
skeletonSprite.scale = Starling.current.stage.stageWidth / bounds.width * 0.5;
|
||||||
skeletonSprite.x = Starling.current.stage.stageWidth / 2;
|
skeletonSprite.x = Starling.current.stage.stageWidth / 2;
|
||||||
skeletonSprite.y = Starling.current.stage.stageHeight * 0.9;
|
skeletonSprite.y = Starling.current.stage.stageHeight * 0.5;
|
||||||
skeletonSprite.state.setAnimationByName(0, "flying", true);
|
skeletonSprite.state.setAnimationByName(0, "flying", true);
|
||||||
|
|
||||||
addChild(skeletonSprite);
|
addChild(skeletonSprite);
|
||||||
@ -62,7 +63,7 @@ class SequenceExample extends Scene {
|
|||||||
public function onTouch(e:TouchEvent) {
|
public function onTouch(e:TouchEvent) {
|
||||||
var touch = e.getTouch(this);
|
var touch = e.getTouch(this);
|
||||||
if (touch != null && touch.phase == TouchPhase.ENDED) {
|
if (touch != null && touch.phase == TouchPhase.ENDED) {
|
||||||
trace("Mouse clicked");
|
SceneManager.getInstance().switchScene(new MixAndMatchExample());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
70
spine-haxe/example/src/TankExample.hx
Normal file
70
spine-haxe/example/src/TankExample.hx
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
* 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.
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
import Scene.SceneManager;
|
||||||
|
import openfl.utils.Assets;
|
||||||
|
import spine.SkeletonData;
|
||||||
|
import spine.animation.AnimationStateData;
|
||||||
|
import spine.atlas.TextureAtlas;
|
||||||
|
import spine.starling.SkeletonSprite;
|
||||||
|
import spine.starling.StarlingTextureLoader;
|
||||||
|
import starling.core.Starling;
|
||||||
|
import starling.events.TouchEvent;
|
||||||
|
import starling.events.TouchPhase;
|
||||||
|
|
||||||
|
class TankExample extends Scene {
|
||||||
|
var loadBinary = false;
|
||||||
|
|
||||||
|
public function load():Void {
|
||||||
|
background.color = 0xffffffff;
|
||||||
|
var atlas = new TextureAtlas(Assets.getText("assets/tank.atlas"), new StarlingTextureLoader("assets/tank.atlas"));
|
||||||
|
var skeletondata = SkeletonData.from(loadBinary ? Assets.getBytes("assets/tank-pro.skel") : Assets.getText("assets/tank-pro.json"), atlas);
|
||||||
|
var animationStateData = new AnimationStateData(skeletondata);
|
||||||
|
animationStateData.defaultMix = 0.25;
|
||||||
|
|
||||||
|
var skeletonSprite = new SkeletonSprite(skeletondata, animationStateData);
|
||||||
|
var bounds = skeletonSprite.skeleton.getBounds();
|
||||||
|
skeletonSprite.scale = Starling.current.stage.stageWidth / bounds.width;
|
||||||
|
skeletonSprite.x = Starling.current.stage.stageWidth / 2;
|
||||||
|
skeletonSprite.y = Starling.current.stage.stageHeight * 0.5;
|
||||||
|
skeletonSprite.state.setAnimationByName(0, "drive", true);
|
||||||
|
|
||||||
|
addChild(skeletonSprite);
|
||||||
|
juggler.add(skeletonSprite);
|
||||||
|
|
||||||
|
addEventListener(TouchEvent.TOUCH, onTouch);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function onTouch(e:TouchEvent) {
|
||||||
|
var touch = e.getTouch(this);
|
||||||
|
if (touch != null && touch.phase == TouchPhase.ENDED) {
|
||||||
|
SceneManager.getInstance().switchScene(new VineExample());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
70
spine-haxe/example/src/VineExample.hx
Normal file
70
spine-haxe/example/src/VineExample.hx
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
* 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.
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
import Scene.SceneManager;
|
||||||
|
import openfl.utils.Assets;
|
||||||
|
import spine.SkeletonData;
|
||||||
|
import spine.animation.AnimationStateData;
|
||||||
|
import spine.atlas.TextureAtlas;
|
||||||
|
import spine.starling.SkeletonSprite;
|
||||||
|
import spine.starling.StarlingTextureLoader;
|
||||||
|
import starling.core.Starling;
|
||||||
|
import starling.events.TouchEvent;
|
||||||
|
import starling.events.TouchPhase;
|
||||||
|
|
||||||
|
class VineExample extends Scene {
|
||||||
|
var loadBinary = false;
|
||||||
|
|
||||||
|
public function load():Void {
|
||||||
|
background.color = 0xffffffff;
|
||||||
|
var atlas = new TextureAtlas(Assets.getText("assets/vine.atlas"), new StarlingTextureLoader("assets/vine.atlas"));
|
||||||
|
var skeletondata = SkeletonData.from(loadBinary ? Assets.getBytes("assets/vine-pro.skel") : Assets.getText("assets/vine-pro.json"), atlas);
|
||||||
|
var animationStateData = new AnimationStateData(skeletondata);
|
||||||
|
animationStateData.defaultMix = 0.25;
|
||||||
|
|
||||||
|
var skeletonSprite = new SkeletonSprite(skeletondata, animationStateData);
|
||||||
|
skeletonSprite.skeleton.updateWorldTransform();
|
||||||
|
var bounds = skeletonSprite.skeleton.getBounds();
|
||||||
|
skeletonSprite.scale = Starling.current.stage.stageWidth / bounds.width;
|
||||||
|
skeletonSprite.x = Starling.current.stage.stageWidth / 2;
|
||||||
|
skeletonSprite.y = Starling.current.stage.stageHeight * 0.5;
|
||||||
|
|
||||||
|
addChild(skeletonSprite);
|
||||||
|
juggler.add(skeletonSprite);
|
||||||
|
|
||||||
|
addEventListener(TouchEvent.TOUCH, onTouch);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function onTouch(e:TouchEvent) {
|
||||||
|
var touch = e.getTouch(this);
|
||||||
|
if (touch != null && touch.phase == TouchPhase.ENDED) {
|
||||||
|
SceneManager.getInstance().switchScene(new BasicExample());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
13
spine-haxe/spine-haxe/spine/ArrayUtils.hx
Normal file
13
spine-haxe/spine-haxe/spine/ArrayUtils.hx
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
package spine;
|
||||||
|
|
||||||
|
class ArrayUtils {
|
||||||
|
public static function resize<T>(array:Array<T>, count:Int, value:T) {
|
||||||
|
if (count < 0)
|
||||||
|
count = 0;
|
||||||
|
array.resize(count);
|
||||||
|
for (i in 0...count) {
|
||||||
|
array[i] = value;
|
||||||
|
}
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -86,18 +86,16 @@ class PathConstraint implements Updatable {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
var data:PathConstraintData = _data;
|
var data:PathConstraintData = _data;
|
||||||
var percentSpacing:Bool = data.spacingMode == SpacingMode.percent;
|
var fTangents:Bool = data.rotateMode == RotateMode.tangent,
|
||||||
var rotateMode:RotateMode = data.rotateMode;
|
fScale:Bool = data.rotateMode == RotateMode.chainScale;
|
||||||
var fTangents:Bool = rotateMode == RotateMode.tangent,
|
|
||||||
fScale:Bool = rotateMode == RotateMode.chainScale;
|
|
||||||
|
|
||||||
var boneCount:Int = _bones.length;
|
var boneCount:Int = _bones.length;
|
||||||
var spacesCount:Int = fTangents ? boneCount : boneCount + 1;
|
var spacesCount:Int = fTangents ? boneCount : boneCount + 1;
|
||||||
var bones:Array<Bone> = _bones;
|
ArrayUtils.resize(_spaces, spacesCount, 0);
|
||||||
_spaces.resize(spacesCount);
|
if (fScale) {
|
||||||
|
ArrayUtils.resize(_lengths, boneCount, 0);
|
||||||
|
}
|
||||||
|
|
||||||
if (fScale)
|
var bones:Array<Bone> = _bones;
|
||||||
_lengths.resize(boneCount);
|
|
||||||
|
|
||||||
var i:Int,
|
var i:Int,
|
||||||
n:Int,
|
n:Int,
|
||||||
@ -254,7 +252,7 @@ class PathConstraint implements Updatable {
|
|||||||
|
|
||||||
private function computeWorldPositions(path:PathAttachment, spacesCount:Int, tangents:Bool):Array<Float> {
|
private function computeWorldPositions(path:PathAttachment, spacesCount:Int, tangents:Bool):Array<Float> {
|
||||||
var position:Float = this.position;
|
var position:Float = this.position;
|
||||||
_positions.resize(spacesCount * 3 + 2);
|
ArrayUtils.resize(_positions, spacesCount * 3 + 2, 0);
|
||||||
var out:Array<Float> = _positions, world:Array<Float>;
|
var out:Array<Float> = _positions, world:Array<Float>;
|
||||||
var closed:Bool = path.closed;
|
var closed:Bool = path.closed;
|
||||||
var verticesLength:Int = path.worldVerticesLength;
|
var verticesLength:Int = path.worldVerticesLength;
|
||||||
@ -277,7 +275,7 @@ class PathConstraint implements Updatable {
|
|||||||
multiplier = 1;
|
multiplier = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
_world.resize(8);
|
ArrayUtils.resize(_world, 8, 0);
|
||||||
world = _world;
|
world = _world;
|
||||||
var i:Int = 0;
|
var i:Int = 0;
|
||||||
var o:Int = 0;
|
var o:Int = 0;
|
||||||
@ -343,7 +341,7 @@ class PathConstraint implements Updatable {
|
|||||||
// World vertices.
|
// World vertices.
|
||||||
if (closed) {
|
if (closed) {
|
||||||
verticesLength += 2;
|
verticesLength += 2;
|
||||||
_world.resize(verticesLength);
|
ArrayUtils.resize(_world, verticesLength, 0);
|
||||||
world = _world;
|
world = _world;
|
||||||
path.computeWorldVertices(target, 2, verticesLength - 4, world, 0, 2);
|
path.computeWorldVertices(target, 2, verticesLength - 4, world, 0, 2);
|
||||||
path.computeWorldVertices(target, 0, 2, world, verticesLength - 4, 2);
|
path.computeWorldVertices(target, 0, 2, world, verticesLength - 4, 2);
|
||||||
@ -352,13 +350,13 @@ class PathConstraint implements Updatable {
|
|||||||
} else {
|
} else {
|
||||||
curveCount--;
|
curveCount--;
|
||||||
verticesLength -= 4;
|
verticesLength -= 4;
|
||||||
_world.resize(verticesLength);
|
ArrayUtils.resize(_world, verticesLength, 0);
|
||||||
world = _world;
|
world = _world;
|
||||||
path.computeWorldVertices(target, 2, verticesLength, world, 0, 2);
|
path.computeWorldVertices(target, 2, verticesLength, world, 0, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Curve lengths.
|
// Curve lengths.
|
||||||
_curves.resize(curveCount);
|
ArrayUtils.resize(_curves, curveCount, 0);
|
||||||
var curves:Array<Float> = _curves;
|
var curves:Array<Float> = _curves;
|
||||||
var pathLength:Float = 0;
|
var pathLength:Float = 0;
|
||||||
var x1:Float = world[0],
|
var x1:Float = world[0],
|
||||||
|
|||||||
@ -71,10 +71,10 @@ class NullAttachmentLoader : public AttachmentLoader {
|
|||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
String atlasFile("");
|
String atlasFile("");
|
||||||
String skeletonFile("/Users/badlogic/Downloads/catsanddogs2.json");
|
String skeletonFile("/Users/badlogic/workspaces/spine-runtimes/spine-haxe/example/assets/vine-pro.json");
|
||||||
String animation = "";
|
String animation = "";
|
||||||
|
|
||||||
float scale = 0.6f;
|
float scale = 1.0f;
|
||||||
SFMLTextureLoader textureLoader;
|
SFMLTextureLoader textureLoader;
|
||||||
NullAttachmentLoader nullLoader;
|
NullAttachmentLoader nullLoader;
|
||||||
Atlas *atlas = atlasFile.length() == 0 ? nullptr : new Atlas(atlasFile, &textureLoader);
|
Atlas *atlas = atlasFile.length() == 0 ? nullptr : new Atlas(atlasFile, &textureLoader);
|
||||||
@ -103,6 +103,7 @@ int main(void) {
|
|||||||
|
|
||||||
AnimationStateData stateData(skeletonData);
|
AnimationStateData stateData(skeletonData);
|
||||||
SkeletonDrawable drawable(skeletonData, &stateData);
|
SkeletonDrawable drawable(skeletonData, &stateData);
|
||||||
|
drawable.skeleton->updateWorldTransform();
|
||||||
drawable.skeleton->setPosition(320, 590);
|
drawable.skeleton->setPosition(320, 590);
|
||||||
if (animation.length() > 0) drawable.state->setAnimation(0, animation, true);
|
if (animation.length() > 0) drawable.state->setAnimation(0, animation, true);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user