[haxe] Rewrite core to not use OpenFL classes. Needed for compatibility with Heaps engine.

This commit is contained in:
Mario Zechner 2023-09-14 14:53:30 +02:00
parent b5c5fb6bde
commit bb3bd3ad40
74 changed files with 670 additions and 719 deletions

View File

@ -36,7 +36,7 @@ import starling.events.TouchEvent;
import starling.events.TouchPhase; import starling.events.TouchPhase;
class BasicExample extends Scene { class BasicExample extends Scene {
var loadBinary = true; var loadBinary = false;
public function load():Void { public function load():Void {
var atlas = TextureAtlas.fromAssets("assets/raptor.atlas"); var atlas = TextureAtlas.fromAssets("assets/raptor.atlas");

View File

@ -36,7 +36,7 @@ import starling.events.TouchEvent;
import starling.events.TouchPhase; import starling.events.TouchPhase;
class SequenceExample extends Scene { class SequenceExample extends Scene {
var loadBinary = true; var loadBinary = false;
public function load():Void { public function load():Void {
var atlas = TextureAtlas.fromAssets("assets/dragon.atlas"); var atlas = TextureAtlas.fromAssets("assets/dragon.atlas");

View File

@ -29,32 +29,48 @@
package spine; package spine;
import openfl.utils.ByteArray; import haxe.io.FPHelper;
import openfl.Vector; import haxe.io.Bytes;
class BinaryInput { class BinaryInput {
private var bytes:ByteArray; private var bytes:Bytes;
private var index:Int = 0;
public var strings:Vector<String> = new Vector<String>(); public var strings:Array<String> = new Array<String>();
public function new(bytes:ByteArray) { public function new(bytes:Bytes) {
this.bytes = bytes; this.bytes = bytes;
} }
public function readByte():Int { public function readByte():Int {
return bytes.readByte(); var result = bytes.get(index++);
if ((result & 0x80) != 0) {
result |= 0xffffff00;
}
return result;
} }
public function readUnsignedByte():Int { public function readUnsignedByte():Int {
return bytes.readUnsignedByte(); return bytes.get(index++);
} }
public function readShort():Int { public function readShort():Int {
return bytes.readShort(); var ch1 = readUnsignedByte();
var ch2 = readUnsignedByte();
var result = ((ch1 << 8) | ch2);
if ((result & 0x8000) != 0) {
result |= 0xFFFF0000;
}
return result;
} }
public function readInt32():Int { public function readInt32():Int {
return bytes.readInt(); var ch1 = readUnsignedByte();
var ch2 = readUnsignedByte();
var ch3 = readUnsignedByte();
var ch4 = readUnsignedByte();
var result = (ch1 << 24) | (ch2 << 16) | (ch3 << 8) | ch4;
return result;
} }
public function readInt(optimizePositive:Bool):Int { public function readInt(optimizePositive:Bool):Int {
@ -80,8 +96,8 @@ class BinaryInput {
} }
public function readStringRef():String { public function readStringRef():String {
var index:Int = readInt(true); var idx:Int = readInt(true);
return index == 0 ? null : strings[index - 1]; return idx == 0 ? null : strings[idx - 1];
} }
public function readString():String { public function readString():String {
@ -113,7 +129,7 @@ class BinaryInput {
} }
public function readFloat():Float { public function readFloat():Float {
return bytes.readFloat(); return FPHelper.i32ToFloat(readInt32());
} }
public function readBoolean():Bool { public function readBoolean():Bool {

View File

@ -29,15 +29,13 @@
package spine; package spine;
import openfl.Vector;
class BlendMode { class BlendMode {
public static var normal(default, never):BlendMode = new BlendMode(0, "normal"); public static var normal(default, never):BlendMode = new BlendMode(0, "normal");
public static var additive(default, never):BlendMode = new BlendMode(1, "additive"); public static var additive(default, never):BlendMode = new BlendMode(1, "additive");
public static var multiply(default, never):BlendMode = new BlendMode(2, "multiply"); public static var multiply(default, never):BlendMode = new BlendMode(2, "multiply");
public static var screen(default, never):BlendMode = new BlendMode(3, "screen"); public static var screen(default, never):BlendMode = new BlendMode(3, "screen");
public static var values(default, never):Vector<BlendMode> = Vector.ofArray([normal, additive, multiply, screen]); public static var values(default, never):Array<BlendMode> = [normal, additive, multiply, screen];
public var ordinal(default, null):Int; public var ordinal(default, null):Int;
public var name(default, null):String; public var name(default, null):String;

View File

@ -29,15 +29,13 @@
package spine; package spine;
import openfl.Vector;
class Bone implements Updatable { class Bone implements Updatable {
static public var yDown:Bool = false; static public var yDown:Bool = false;
private var _data:BoneData; private var _data:BoneData;
private var _skeleton:Skeleton; private var _skeleton:Skeleton;
private var _parent:Bone; private var _parent:Bone;
private var _children:Vector<Bone> = new Vector<Bone>(); private var _children:Array<Bone> = new Array<Bone>();
public var x:Float = 0; public var x:Float = 0;
public var y:Float = 0; public var y:Float = 0;
@ -230,9 +228,9 @@ class Bone implements Updatable {
return _parent; return _parent;
} }
public var children(get, never):Vector<Bone>; public var children(get, never):Array<Bone>;
private function get_children():Vector<Bone> { private function get_children():Array<Bone> {
return _children; return _children;
} }
@ -308,7 +306,7 @@ class Bone implements Updatable {
} }
} }
public function worldToLocal(world:Vector<Float>):Void { public function worldToLocal(world:Array<Float>):Void {
var a:Float = a, b:Float = b, c:Float = c, d:Float = d; var a:Float = a, b:Float = b, c:Float = c, d:Float = d;
var invDet:Float = 1 / (a * d - b * c); var invDet:Float = 1 / (a * d - b * c);
var x:Float = world[0] - worldX, y:Float = world[1] - worldY; var x:Float = world[0] - worldX, y:Float = world[1] - worldY;
@ -316,7 +314,7 @@ class Bone implements Updatable {
world[1] = (y * a * invDet - x * c * invDet); world[1] = (y * a * invDet - x * c * invDet);
} }
public function localToWorld(local:Vector<Float>):Void { public function localToWorld(local:Array<Float>):Void {
var localX:Float = local[0], localY:Float = local[1]; var localX:Float = local[0], localY:Float = local[1];
local[0] = localX * a + localY * b + worldX; local[0] = localX * a + localY * b + worldX;
local[1] = localX * c + localY * d + worldY; local[1] = localX * c + localY * d + worldY;

View File

@ -29,12 +29,10 @@
package spine; package spine;
import openfl.Vector;
class IkConstraint implements Updatable { class IkConstraint implements Updatable {
private var _data:IkConstraintData; private var _data:IkConstraintData;
public var bones:Vector<Bone>; public var bones:Array<Bone>;
public var target:Bone; public var target:Bone;
public var bendDirection:Int = 0; public var bendDirection:Int = 0;
public var compress:Bool = false; public var compress:Bool = false;
@ -55,7 +53,7 @@ class IkConstraint implements Updatable {
compress = data.compress; compress = data.compress;
stretch = data.stretch; stretch = data.stretch;
bones = new Vector<Bone>(); bones = new Array<Bone>();
for (boneData in data.bones) { for (boneData in data.bones) {
bones.push(skeleton.findBone(boneData.name)); bones.push(skeleton.findBone(boneData.name));
} }

View File

@ -29,10 +29,8 @@
package spine; package spine;
import openfl.Vector;
class IkConstraintData extends ConstraintData { class IkConstraintData extends ConstraintData {
public var bones:Vector<BoneData> = new Vector<BoneData>(); public var bones:Array<BoneData> = new Array<BoneData>();
public var target:BoneData; public var target:BoneData;
public var mix:Float = 1; public var mix:Float = 1;
public var bendDirection:Int = 1; public var bendDirection:Int = 1;

View File

@ -29,7 +29,6 @@
package spine; package spine;
import openfl.Vector;
import spine.attachments.PathAttachment; import spine.attachments.PathAttachment;
class PathConstraint implements Updatable { class PathConstraint implements Updatable {
@ -39,7 +38,7 @@ class PathConstraint implements Updatable {
private static inline var epsilon:Float = 0.00001; private static inline var epsilon:Float = 0.00001;
private var _data:PathConstraintData; private var _data:PathConstraintData;
private var _bones:Vector<Bone>; private var _bones:Array<Bone>;
public var target:Slot; public var target:Slot;
public var position:Float = 0; public var position:Float = 0;
@ -48,12 +47,12 @@ class PathConstraint implements Updatable {
public var mixX:Float = 0; public var mixX:Float = 0;
public var mixY:Float = 0; public var mixY:Float = 0;
private var _spaces(default, never):Vector<Float> = new Vector<Float>(); private var _spaces(default, never):Array<Float> = new Array<Float>();
private var _positions(default, never):Vector<Float> = new Vector<Float>(); private var _positions(default, never):Array<Float> = new Array<Float>();
private var _world(default, never):Vector<Float> = new Vector<Float>(); private var _world(default, never):Array<Float> = new Array<Float>();
private var _curves(default, never):Vector<Float> = new Vector<Float>(); private var _curves(default, never):Array<Float> = new Array<Float>();
private var _lengths(default, never):Vector<Float> = new Vector<Float>(); private var _lengths(default, never):Array<Float> = new Array<Float>();
private var _segments(default, never):Vector<Float> = new Vector<Float>(10, true); private var _segments(default, never):Array<Float> = new Array<Float>();
public var active:Bool = false; public var active:Bool = false;
@ -63,7 +62,7 @@ class PathConstraint implements Updatable {
if (skeleton == null) if (skeleton == null)
throw new SpineException("skeleton cannot be null."); throw new SpineException("skeleton cannot be null.");
_data = data; _data = data;
_bones = new Vector<Bone>(); _bones = new Array<Bone>();
for (boneData in data.bones) { for (boneData in data.bones) {
_bones.push(skeleton.findBone(boneData.name)); _bones.push(skeleton.findBone(boneData.name));
} }
@ -94,11 +93,11 @@ class PathConstraint implements Updatable {
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:Vector<Bone> = _bones; var bones:Array<Bone> = _bones;
_spaces.length = spacesCount; _spaces.resize(spacesCount);
if (fScale) if (fScale)
_lengths.length = boneCount; _lengths.resize(boneCount);
var i:Int, var i:Int,
n:Int, n:Int,
@ -175,7 +174,7 @@ class PathConstraint implements Updatable {
} }
} }
var positions:Vector<Float> = computeWorldPositions(attachment, spacesCount, fTangents); var positions:Array<Float> = computeWorldPositions(attachment, spacesCount, fTangents);
var boneX:Float = positions[0]; var boneX:Float = positions[0];
var boneY:Float = positions[1]; var boneY:Float = positions[1];
var offsetRotation:Float = data.offsetRotation; var offsetRotation:Float = data.offsetRotation;
@ -253,10 +252,10 @@ class PathConstraint implements Updatable {
} }
} }
private function computeWorldPositions(path:PathAttachment, spacesCount:Int, tangents:Bool):Vector<Float> { private function computeWorldPositions(path:PathAttachment, spacesCount:Int, tangents:Bool):Array<Float> {
var position:Float = this.position; var position:Float = this.position;
_positions.length = spacesCount * 3 + 2; _positions.resize(spacesCount * 3 + 2);
var out:Vector<Float> = _positions, world:Vector<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;
var curveCount:Int = Std.int(verticesLength / 6); var curveCount:Int = Std.int(verticesLength / 6);
@ -264,7 +263,7 @@ class PathConstraint implements Updatable {
var multiplier:Float, i:Int; var multiplier:Float, i:Int;
if (!path.constantSpeed) { if (!path.constantSpeed) {
var lengths:Vector<Float> = path.lengths; var lengths:Array<Float> = path.lengths;
curveCount -= closed ? 1 : 2; curveCount -= closed ? 1 : 2;
var pathLength:Float = lengths[curveCount]; var pathLength:Float = lengths[curveCount];
if (data.positionMode == PositionMode.percent) if (data.positionMode == PositionMode.percent)
@ -278,7 +277,7 @@ class PathConstraint implements Updatable {
multiplier = 1; multiplier = 1;
} }
_world.length = 8; _world.resize(8);
world = _world; world = _world;
var i:Int = 0; var i:Int = 0;
var o:Int = 0; var o:Int = 0;
@ -344,7 +343,7 @@ class PathConstraint implements Updatable {
// World vertices. // World vertices.
if (closed) { if (closed) {
verticesLength += 2; verticesLength += 2;
_world.length = verticesLength; _world.resize(verticesLength);
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);
@ -353,14 +352,14 @@ class PathConstraint implements Updatable {
} else { } else {
curveCount--; curveCount--;
verticesLength -= 4; verticesLength -= 4;
_world.length = verticesLength; _world.resize(verticesLength);
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.length = curveCount; _curves.resize(curveCount);
var curves:Vector<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],
y1:Float = world[1], y1:Float = world[1],
@ -420,7 +419,7 @@ class PathConstraint implements Updatable {
multiplier = 1; multiplier = 1;
} }
var segments:Vector<Float> = _segments; var segments:Array<Float> = _segments;
var curveLength:Float = 0; var curveLength:Float = 0;
var segment:Int; var segment:Int;
i = 0; i = 0;
@ -529,7 +528,7 @@ class PathConstraint implements Updatable {
return out; return out;
} }
private function addBeforePosition(p:Float, temp:Vector<Float>, i:Int, out:Vector<Float>, o:Int):Void { private function addBeforePosition(p:Float, temp:Array<Float>, i:Int, out:Array<Float>, o:Int):Void {
var x1:Float = temp[i]; var x1:Float = temp[i];
var y1:Float = temp[i + 1]; var y1:Float = temp[i + 1];
var dx:Float = temp[i + 2] - x1; var dx:Float = temp[i + 2] - x1;
@ -540,7 +539,7 @@ class PathConstraint implements Updatable {
out[o + 2] = r; out[o + 2] = r;
} }
private function addAfterPosition(p:Float, temp:Vector<Float>, i:Int, out:Vector<Float>, o:Int):Void { private function addAfterPosition(p:Float, temp:Array<Float>, i:Int, out:Array<Float>, o:Int):Void {
var x1:Float = temp[i + 2]; var x1:Float = temp[i + 2];
var y1:Float = temp[i + 3]; var y1:Float = temp[i + 3];
var dx:Float = x1 - temp[i]; var dx:Float = x1 - temp[i];
@ -551,7 +550,7 @@ class PathConstraint implements Updatable {
out[o + 2] = r; out[o + 2] = r;
} }
private function addCurvePosition(p:Float, x1:Float, y1:Float, cx1:Float, cy1:Float, cx2:Float, cy2:Float, x2:Float, y2:Float, out:Vector<Float>, o:Int, private function addCurvePosition(p:Float, x1:Float, y1:Float, cx1:Float, cy1:Float, cx2:Float, cy2:Float, x2:Float, y2:Float, out:Array<Float>, o:Int,
tangents:Bool):Void { tangents:Bool):Void {
if (p == 0 || Math.isNaN(p)) { if (p == 0 || Math.isNaN(p)) {
out[o] = x1; out[o] = x1;
@ -581,9 +580,9 @@ class PathConstraint implements Updatable {
} }
} }
public var bones(get, never):Vector<Bone>; public var bones(get, never):Array<Bone>;
private function get_bones():Vector<Bone> { private function get_bones():Array<Bone> {
return _bones; return _bones;
} }

View File

@ -29,10 +29,8 @@
package spine; package spine;
import openfl.Vector;
class PathConstraintData extends ConstraintData { class PathConstraintData extends ConstraintData {
private var _bones:Vector<BoneData> = new Vector<BoneData>(); private var _bones:Array<BoneData> = new Array<BoneData>();
public var target:SlotData; public var target:SlotData;
public var positionMode:PositionMode = PositionMode.fixed; public var positionMode:PositionMode = PositionMode.fixed;
@ -49,9 +47,9 @@ class PathConstraintData extends ConstraintData {
super(name, 0, false); super(name, 0, false);
} }
public var bones(get, never):Vector<BoneData>; public var bones(get, never):Array<BoneData>;
private function get_bones():Vector<BoneData> { private function get_bones():Array<BoneData> {
return _bones; return _bones;
} }
} }

View File

@ -29,10 +29,8 @@
package spine; package spine;
import openfl.Vector;
class Polygon { class Polygon {
public var vertices:Vector<Float> = new Vector<Float>(); public var vertices:Array<Float> = new Array<Float>();
public function new() {} public function new() {}

View File

@ -29,8 +29,6 @@
package spine; package spine;
import openfl.Vector;
#if flash #if flash
typedef Function = Dynamic; typedef Function = Dynamic;
#else #else
@ -38,11 +36,11 @@ typedef Function = haxe.Constraints.Function;
#end #end
@:generic class Pool<T> { @:generic class Pool<T> {
private var items:Vector<T>; private var items:Array<T>;
private var instantiator:Function; private var instantiator:Function;
public function new(instantiator:Void->T) { public function new(instantiator:Void->T) {
this.items = new Vector<T>(); this.items = new Array<T>();
this.instantiator = instantiator; this.instantiator = instantiator;
} }
@ -56,13 +54,13 @@ typedef Function = haxe.Constraints.Function;
items.push(item); items.push(item);
} }
public function freeAll(items:Vector<T>):Void { public function freeAll(items:Array<T>):Void {
for (item in items) { for (item in items) {
free(item); free(item);
} }
} }
public function clear():Void { public function clear():Void {
items.length = 0; items.resize(0);
} }
} }

View File

@ -29,13 +29,11 @@
package spine; package spine;
import openfl.Vector;
class PositionMode { class PositionMode {
public static var fixed(default, never):PositionMode = new PositionMode("fixed"); public static var fixed(default, never):PositionMode = new PositionMode("fixed");
public static var percent(default, never):PositionMode = new PositionMode("percent"); public static var percent(default, never):PositionMode = new PositionMode("percent");
public static var values(default, never):Vector<PositionMode> = Vector.ofArray([fixed, percent]); public static var values(default, never):Array<PositionMode> = [fixed, percent];
public var name(default, null):String; public var name(default, null):String;

View File

@ -0,0 +1,15 @@
package spine;
class Rectangle {
public var x:Float;
public var y:Float;
public var width:Float;
public var height:Float;
public function new() {
x = 0;
y = 0;
width = 0;
height = 0;
}
}

View File

@ -29,14 +29,12 @@
package spine; package spine;
import openfl.Vector;
class RotateMode { class RotateMode {
public static var tangent(default, never):RotateMode = new RotateMode("tangent"); public static var tangent(default, never):RotateMode = new RotateMode("tangent");
public static var chain(default, never):RotateMode = new RotateMode("chain"); public static var chain(default, never):RotateMode = new RotateMode("chain");
public static var chainScale(default, never):RotateMode = new RotateMode("chainScale"); public static var chainScale(default, never):RotateMode = new RotateMode("chainScale");
public static var values(default, never):Vector<RotateMode> = Vector.ofArray([tangent, chain, chainScale]); public static var values(default, never):Array<RotateMode> = [tangent, chain, chainScale];
public var name(default, null):String; public var name(default, null):String;

View File

@ -29,13 +29,11 @@
package spine; package spine;
import openfl.Vector;
class Sequence { class Sequence {
private static var _nextID = 0; private static var _nextID = 0;
public var id = _nextID++; public var id = _nextID++;
public var regions:Vector<TextureRegion>; public var regions:Array<TextureRegion>;
public var start = 0; public var start = 0;
public var digits = 0; public var digits = 0;
@ -43,7 +41,8 @@ class Sequence {
public var setupIndex = 0; public var setupIndex = 0;
public function new(count:Int) { public function new(count:Int) {
this.regions = new Vector<TextureRegion>(count); this.regions = new Array<TextureRegion>();
this.regions.resize(count);
} }
public function copy():Sequence { public function copy():Sequence {

View File

@ -29,8 +29,6 @@
package spine; package spine;
import openfl.Vector;
class SequenceMode { class SequenceMode {
public static var hold(default, never):SequenceMode = new SequenceMode("hold", 0); public static var hold(default, never):SequenceMode = new SequenceMode("hold", 0);
public static var once(default, never):SequenceMode = new SequenceMode("once", 1); public static var once(default, never):SequenceMode = new SequenceMode("once", 1);
@ -40,7 +38,7 @@ class SequenceMode {
public static var loopReverse(default, never):SequenceMode = new SequenceMode("loopReverse", 5); public static var loopReverse(default, never):SequenceMode = new SequenceMode("loopReverse", 5);
public static var pingpongReverse(default, never):SequenceMode = new SequenceMode("pingpongReverse", 6); public static var pingpongReverse(default, never):SequenceMode = new SequenceMode("pingpongReverse", 6);
public static var values(default, never):Vector<SequenceMode> = Vector.ofArray([hold, once, loop, pingpong, onceReverse, loopReverse, pingpongReverse]); public static var values(default, never):Array<SequenceMode> = [hold, once, loop, pingpong, onceReverse, loopReverse, pingpongReverse];
public var name(default, null):String; public var name(default, null):String;
public var value:Int; public var value:Int;

View File

@ -29,9 +29,8 @@
package spine; package spine;
import openfl.geom.Rectangle; import lime.math.Rectangle;
import openfl.utils.Dictionary; import haxe.ds.StringMap;
import openfl.Vector;
import spine.attachments.Attachment; import spine.attachments.Attachment;
import spine.attachments.MeshAttachment; import spine.attachments.MeshAttachment;
import spine.attachments.PathAttachment; import spine.attachments.PathAttachment;
@ -40,14 +39,14 @@ import spine.attachments.RegionAttachment;
class Skeleton { class Skeleton {
private var _data:SkeletonData; private var _data:SkeletonData;
public var bones:Vector<Bone>; public var bones:Array<Bone>;
public var slots:Vector<Slot>; public var slots:Array<Slot>;
public var drawOrder:Vector<Slot>; public var drawOrder:Array<Slot>;
public var ikConstraints:Vector<IkConstraint>; public var ikConstraints:Array<IkConstraint>;
public var transformConstraints:Vector<TransformConstraint>; public var transformConstraints:Array<TransformConstraint>;
public var pathConstraints:Vector<PathConstraint>; public var pathConstraints:Array<PathConstraint>;
private var _updateCache:Vector<Updatable> = new Vector<Updatable>(); private var _updateCache:Array<Updatable> = new Array<Updatable>();
private var _skin:Skin; private var _skin:Skin;
public var color:Color = new Color(1, 1, 1, 1); public var color:Color = new Color(1, 1, 1, 1);
@ -62,7 +61,7 @@ class Skeleton {
} }
_data = data; _data = data;
bones = new Vector<Bone>(); bones = new Array<Bone>();
for (boneData in data.bones) { for (boneData in data.bones) {
var bone:Bone; var bone:Bone;
if (boneData.parent == null) { if (boneData.parent == null) {
@ -75,8 +74,8 @@ class Skeleton {
bones.push(bone); bones.push(bone);
} }
slots = new Vector<Slot>(); slots = new Array<Slot>();
drawOrder = new Vector<Slot>(); drawOrder = new Array<Slot>();
for (slotData in data.slots) { for (slotData in data.slots) {
var bone = bones[slotData.boneData.index]; var bone = bones[slotData.boneData.index];
var slot:Slot = new Slot(slotData, bone); var slot:Slot = new Slot(slotData, bone);
@ -84,17 +83,17 @@ class Skeleton {
drawOrder.push(slot); drawOrder.push(slot);
} }
ikConstraints = new Vector<IkConstraint>(); ikConstraints = new Array<IkConstraint>();
for (ikConstraintData in data.ikConstraints) { for (ikConstraintData in data.ikConstraints) {
ikConstraints.push(new IkConstraint(ikConstraintData, this)); ikConstraints.push(new IkConstraint(ikConstraintData, this));
} }
transformConstraints = new Vector<TransformConstraint>(); transformConstraints = new Array<TransformConstraint>();
for (transformConstraintData in data.transformConstraints) { for (transformConstraintData in data.transformConstraints) {
transformConstraints.push(new TransformConstraint(transformConstraintData, this)); transformConstraints.push(new TransformConstraint(transformConstraintData, this));
} }
pathConstraints = new Vector<PathConstraint>(); pathConstraints = new Array<PathConstraint>();
for (pathConstraintData in data.pathConstraints) { for (pathConstraintData in data.pathConstraints) {
pathConstraints.push(new PathConstraint(pathConstraintData, this)); pathConstraints.push(new PathConstraint(pathConstraintData, this));
} }
@ -105,7 +104,7 @@ class Skeleton {
/** Caches information about bones and constraints. Must be called if bones, constraints, or weighted path attachments are /** Caches information about bones and constraints. Must be called if bones, constraints, or weighted path attachments are
* added or removed. */ * added or removed. */
public function updateCache():Void { public function updateCache():Void {
_updateCache.length = 0; _updateCache.resize(0);
for (bone in bones) { for (bone in bones) {
bone.sorted = bone.data.skinRequired; bone.sorted = bone.data.skinRequired;
@ -113,7 +112,7 @@ class Skeleton {
} }
if (skin != null) { if (skin != null) {
var skinBones:Vector<BoneData> = skin.bones; var skinBones:Array<BoneData> = skin.bones;
for (i in 0...skin.bones.length) { for (i in 0...skin.bones.length) {
var bone:Bone = bones[skinBones[i].index]; var bone:Bone = bones[skinBones[i].index];
do { do {
@ -164,7 +163,7 @@ class Skeleton {
} }
} }
private static function contains(list:Vector<ConstraintData>, element:ConstraintData):Bool { private static function contains(list:Array<ConstraintData>, element:ConstraintData):Bool {
return list.indexOf(element) != -1; return list.indexOf(element) != -1;
} }
@ -177,7 +176,7 @@ class Skeleton {
var target:Bone = constraint.target; var target:Bone = constraint.target;
sortBone(target); sortBone(target);
var constrained:Vector<Bone> = constraint.bones; var constrained:Array<Bone> = constraint.bones;
var parent:Bone = constrained[0]; var parent:Bone = constrained[0];
sortBone(parent); sortBone(parent);
@ -222,7 +221,7 @@ class Skeleton {
if (Std.isOfType(attachment, PathAttachment)) if (Std.isOfType(attachment, PathAttachment))
sortPathConstraintAttachment2(attachment, slotBone); sortPathConstraintAttachment2(attachment, slotBone);
var constrainedBones:Vector<Bone> = constraint.bones; var constrainedBones:Array<Bone> = constraint.bones;
for (bone in constrainedBones) { for (bone in constrainedBones) {
sortBone(bone); sortBone(bone);
} }
@ -245,7 +244,7 @@ class Skeleton {
sortBone(constraint.target); sortBone(constraint.target);
var constrainedBones:Vector<Bone> = constraint.bones; var constrainedBones:Array<Bone> = constraint.bones;
if (constraint.data.local) { if (constraint.data.local) {
for (bone in constrainedBones) { for (bone in constrainedBones) {
sortBone(bone.parent); sortBone(bone.parent);
@ -267,10 +266,10 @@ class Skeleton {
} }
private function sortPathConstraintAttachment(skin:Skin, slotIndex:Int, slotBone:Bone):Void { private function sortPathConstraintAttachment(skin:Skin, slotIndex:Int, slotBone:Bone):Void {
var dict:Dictionary<String, Attachment> = skin.attachments[slotIndex]; var dict:StringMap<Attachment> = skin.attachments[slotIndex];
if (dict != null) { if (dict != null) {
for (attachment in dict.each()) { for (attachment in dict.keyValueIterator()) {
sortPathConstraintAttachment2(attachment, slotBone); sortPathConstraintAttachment2(attachment.value, slotBone);
} }
} }
} }
@ -279,7 +278,7 @@ class Skeleton {
var pathAttachment:PathAttachment = cast(attachment, PathAttachment); var pathAttachment:PathAttachment = cast(attachment, PathAttachment);
if (pathAttachment == null) if (pathAttachment == null)
return; return;
var pathBones:Vector<Int> = pathAttachment.bones; var pathBones:Array<Int> = pathAttachment.bones;
if (pathBones == null) { if (pathBones == null) {
sortBone(slotBone); sortBone(slotBone);
} else { } else {
@ -305,7 +304,7 @@ class Skeleton {
_updateCache.push(bone); _updateCache.push(bone);
} }
private function sortReset(bones:Vector<Bone>):Void { private function sortReset(bones:Array<Bone>):Void {
for (bone in bones) { for (bone in bones) {
if (!bone.active) if (!bone.active)
continue; continue;
@ -411,9 +410,9 @@ class Skeleton {
return _data; return _data;
} }
public var getUpdateCache(get, never):Vector<Updatable>; public var getUpdateCache(get, never):Array<Updatable>;
private function get_getUpdateCache():Vector<Updatable> { private function get_getUpdateCache():Array<Updatable> {
return _updateCache; return _updateCache;
} }
@ -590,7 +589,7 @@ class Skeleton {
return _data.name != null ? _data.name : "Skeleton?"; return _data.name != null ? _data.name : "Skeleton?";
} }
private var _tempVertices = new Vector<Float>(); private var _tempVertices = new Array<Float>();
private var _bounds = new Rectangle(); private var _bounds = new Rectangle();
public function getBounds():Rectangle { public function getBounds():Rectangle {
@ -600,17 +599,17 @@ class Skeleton {
var maxY:Float = Math.NEGATIVE_INFINITY; var maxY:Float = Math.NEGATIVE_INFINITY;
for (slot in drawOrder) { for (slot in drawOrder) {
var verticesLength:Int = 0; var verticesLength:Int = 0;
var vertices:Vector<Float> = null; var vertices:Array<Float> = null;
var attachment:Attachment = slot.attachment; var attachment:Attachment = slot.attachment;
if (Std.isOfType(attachment, RegionAttachment)) { if (Std.isOfType(attachment, RegionAttachment)) {
verticesLength = 8; verticesLength = 8;
_tempVertices.length = verticesLength; _tempVertices.resize(verticesLength);
vertices = _tempVertices; vertices = _tempVertices;
cast(attachment, RegionAttachment).computeWorldVertices(slot, vertices, 0, 2); cast(attachment, RegionAttachment).computeWorldVertices(slot, vertices, 0, 2);
} else if (Std.isOfType(attachment, MeshAttachment)) { } else if (Std.isOfType(attachment, MeshAttachment)) {
var mesh:MeshAttachment = cast(attachment, MeshAttachment); var mesh:MeshAttachment = cast(attachment, MeshAttachment);
verticesLength = mesh.worldVerticesLength; verticesLength = mesh.worldVerticesLength;
_tempVertices.length = verticesLength; _tempVertices.resize(verticesLength);
vertices = _tempVertices; vertices = _tempVertices;
mesh.computeWorldVertices(slot, 0, verticesLength, vertices, 0, 2); mesh.computeWorldVertices(slot, 0, verticesLength, vertices, 0, 2);
} }

View File

@ -29,10 +29,8 @@
package spine; package spine;
import haxe.io.Bytes;
import StringTools; import StringTools;
import openfl.Vector;
import openfl.utils.ByteArray;
import openfl.utils.Endian;
import spine.animation.AlphaTimeline; import spine.animation.AlphaTimeline;
import spine.animation.Animation; import spine.animation.Animation;
import spine.animation.AttachmentTimeline; import spine.animation.AttachmentTimeline;
@ -78,7 +76,7 @@ class SkeletonBinary {
public var attachmentLoader:AttachmentLoader; public var attachmentLoader:AttachmentLoader;
public var scale:Float = 1; public var scale:Float = 1;
private var linkedMeshes:Vector<LinkedMeshBinary> = new Vector<LinkedMeshBinary>(); private var linkedMeshes:Array<LinkedMeshBinary> = new Array<LinkedMeshBinary>();
private static inline var BONE_ROTATE:Int = 0; private static inline var BONE_ROTATE:Int = 0;
private static inline var BONE_TRANSLATE:Int = 1; private static inline var BONE_TRANSLATE:Int = 1;
@ -113,8 +111,8 @@ class SkeletonBinary {
this.attachmentLoader = attachmentLoader; this.attachmentLoader = attachmentLoader;
} }
public function readSkeletonData(bytes:ByteArray):SkeletonData { public function readSkeletonData(bytes:Bytes):SkeletonData {
bytes.endian = Endian.BIG_ENDIAN; // bytes.getData(). = Endian.BIG_ENDIAN;
var skeletonData:SkeletonData = new SkeletonData(); var skeletonData:SkeletonData = new SkeletonData();
skeletonData.name = null; skeletonData.name = null;
@ -291,7 +289,7 @@ class SkeletonBinary {
if (linkedMesh.mesh.region != null) if (linkedMesh.mesh.region != null)
linkedMesh.mesh.updateRegion(); linkedMesh.mesh.updateRegion();
} }
linkedMeshes.length = 0; linkedMeshes.resize(0);
// Events. // Events.
n = input.readInt(true); n = input.readInt(true);
@ -327,7 +325,7 @@ class SkeletonBinary {
skin = new Skin("default"); skin = new Skin("default");
} else { } else {
skin = new Skin(input.readStringRef()); skin = new Skin(input.readStringRef());
skin.bones.length = input.readInt(true); skin.bones.resize(input.readInt(true));
for (i in 0...skin.bones.length) { for (i in 0...skin.bones.length) {
skin.bones[i] = skeletonData.bones[input.readInt(true)]; skin.bones[i] = skeletonData.bones[input.readInt(true)];
} }
@ -436,12 +434,12 @@ class SkeletonBinary {
path = input.readStringRef(); path = input.readStringRef();
color = input.readInt32(); color = input.readInt32();
vertexCount = input.readInt(true); vertexCount = input.readInt(true);
var uvs:Vector<Float> = readFloatArray(input, vertexCount << 1, 1); var uvs:Array<Float> = readFloatArray(input, vertexCount << 1, 1);
var triangles:Vector<Int> = readShortArray(input); var triangles:Array<Int> = readShortArray(input);
vertices = readVertices(input, vertexCount); vertices = readVertices(input, vertexCount);
var hullLength:Int = input.readInt(true); var hullLength:Int = input.readInt(true);
var sequence = readSequence(input); var sequence = readSequence(input);
var edges:Vector<Int> = null; var edges:Array<Int> = null;
if (nonessential) { if (nonessential) {
edges = readShortArray(input); edges = readShortArray(input);
width = input.readFloat(); width = input.readFloat();
@ -502,8 +500,8 @@ class SkeletonBinary {
var constantSpeed:Bool = input.readBoolean(); var constantSpeed:Bool = input.readBoolean();
vertexCount = input.readInt(true); vertexCount = input.readInt(true);
vertices = readVertices(input, vertexCount); vertices = readVertices(input, vertexCount);
var lengths:Vector<Float> = new Vector<Float>(); var lengths:Array<Float> = new Array<Float>();
lengths.length = Std.int(vertexCount / 3); lengths.resize(Std.int(vertexCount / 3));
for (i in 0...lengths.length) { for (i in 0...lengths.length) {
lengths[i] = input.readFloat() * scale; lengths[i] = input.readFloat() * scale;
} }
@ -567,8 +565,8 @@ class SkeletonBinary {
vertices.vertices = readFloatArray(input, verticesLength, scale); vertices.vertices = readFloatArray(input, verticesLength, scale);
return vertices; return vertices;
} }
var weights:Vector<Float> = new Vector<Float>(); var weights:Array<Float> = new Array<Float>();
var bonesArray:Vector<Int> = new Vector<Int>(); var bonesArray:Array<Int> = new Array<Int>();
for (i in 0...vertexCount) { for (i in 0...vertexCount) {
var boneCount:Int = input.readInt(true); var boneCount:Int = input.readInt(true);
bonesArray.push(boneCount); bonesArray.push(boneCount);
@ -584,8 +582,8 @@ class SkeletonBinary {
return vertices; return vertices;
} }
private function readFloatArray(input:BinaryInput, n:Int, scale:Float):Vector<Float> { private function readFloatArray(input:BinaryInput, n:Int, scale:Float):Array<Float> {
var array:Vector<Float> = new Vector<Float>(); var array:Array<Float> = new Array<Float>();
if (scale == 1) { if (scale == 1) {
for (i in 0...n) { for (i in 0...n) {
array.push(input.readFloat()); array.push(input.readFloat());
@ -598,9 +596,9 @@ class SkeletonBinary {
return array; return array;
} }
private function readShortArray(input:BinaryInput):Vector<Int> { private function readShortArray(input:BinaryInput):Array<Int> {
var n:Int = input.readInt(true); var n:Int = input.readInt(true);
var array:Vector<Int> = new Vector<Int>(); var array:Array<Int> = new Array<Int>();
for (i in 0...n) { for (i in 0...n) {
array.push(input.readShort()); array.push(input.readShort());
} }
@ -609,7 +607,7 @@ class SkeletonBinary {
private function readAnimation(input:BinaryInput, name:String, skeletonData:SkeletonData):Animation { private function readAnimation(input:BinaryInput, name:String, skeletonData:SkeletonData):Animation {
input.readInt(true); // Count of timelines. input.readInt(true); // Count of timelines.
var timelines:Vector<Timeline> = new Vector<Timeline>(); var timelines:Array<Timeline> = new Array<Timeline>();
var i:Int = 0, n:Int = 0, ii:Int = 0, nn:Int = 0; var i:Int = 0, n:Int = 0, ii:Int = 0, nn:Int = 0;
var index:Int, slotIndex:Int, timelineType:Int, timelineScale:Float; var index:Int, slotIndex:Int, timelineType:Int, timelineScale:Float;
@ -1042,7 +1040,7 @@ class SkeletonBinary {
case ATTACHMENT_DEFORM: case ATTACHMENT_DEFORM:
var vertexAttachment = cast(attachment, VertexAttachment); var vertexAttachment = cast(attachment, VertexAttachment);
var weighted:Bool = vertexAttachment.bones != null; var weighted:Bool = vertexAttachment.bones != null;
var vertices:Vector<Float> = vertexAttachment.vertices; var vertices:Array<Float> = vertexAttachment.vertices;
var deformLength:Int = weighted ? Std.int(vertices.length / 3 * 2) : vertices.length; var deformLength:Int = weighted ? Std.int(vertices.length / 3 * 2) : vertices.length;
bezierCount = input.readInt(true); bezierCount = input.readInt(true);
@ -1052,17 +1050,19 @@ class SkeletonBinary {
frame = 0; frame = 0;
bezier = 0; bezier = 0;
while (true) { while (true) {
var deform:Vector<Float>; var deform:Array<Float>;
var end:Int = input.readInt(true); var end:Int = input.readInt(true);
if (end == 0) { if (end == 0) {
if (weighted) { if (weighted) {
deform = new Vector<Float>(deformLength, true); deform = new Array<Float>();
deform.resize(deformLength);
} else { } else {
deform = vertices; deform = vertices;
} }
} else { } else {
var v:Int, vn:Int; var v:Int, vn:Int;
deform = new Vector<Float>(deformLength, true); deform = new Array<Float>();
deform.resize(deformLength);
var start:Int = input.readInt(true); var start:Int = input.readInt(true);
end += start; end += start;
if (scale == 1) { if (scale == 1) {
@ -1118,12 +1118,14 @@ class SkeletonBinary {
for (i in 0...drawOrderCount) { for (i in 0...drawOrderCount) {
time = input.readFloat(); time = input.readFloat();
var offsetCount:Int = input.readInt(true); var offsetCount:Int = input.readInt(true);
var drawOrder:Vector<Int> = new Vector<Int>(slotCount, true); var drawOrder:Array<Int> = new Array<Int>();
drawOrder.resize(slotCount);
var ii:Int = slotCount - 1; var ii:Int = slotCount - 1;
while (ii >= 0) { while (ii >= 0) {
drawOrder[ii--] = -1; drawOrder[ii--] = -1;
} }
var unchanged:Vector<Int> = new Vector<Int>(slotCount - offsetCount, true); var unchanged:Array<Int> = new Array<Int>();
unchanged.resize(slotCount - offsetCount);
var originalIndex:Int = 0, unchangedIndex:Int = 0; var originalIndex:Int = 0, unchangedIndex:Int = 0;
for (ii in 0...offsetCount) { for (ii in 0...offsetCount) {
slotIndex = input.readInt(true); slotIndex = input.readInt(true);
@ -1245,8 +1247,8 @@ class SkeletonBinary {
} }
class Vertices { class Vertices {
public var vertices:Vector<Float> = new Vector<Float>(); public var vertices:Array<Float> = new Array<Float>();
public var bones:Vector<Int> = new Vector<Int>(); public var bones:Array<Int> = new Array<Int>();
public function new() {} public function new() {}
} }

View File

@ -29,22 +29,21 @@
package spine; package spine;
import openfl.Vector;
import spine.attachments.ClippingAttachment; import spine.attachments.ClippingAttachment;
class SkeletonClipping { class SkeletonClipping {
private var triangulator:Triangulator = new Triangulator(); private var triangulator:Triangulator = new Triangulator();
private var clippingPolygon:Vector<Float> = new Vector<Float>(); private var clippingPolygon:Array<Float> = new Array<Float>();
private var clipOutput:Vector<Float> = new Vector<Float>(); private var clipOutput:Array<Float> = new Array<Float>();
public var clippedVertices:Vector<Float> = new Vector<Float>(); public var clippedVertices:Array<Float> = new Array<Float>();
public var clippedUvs:Vector<Float> = new Vector<Float>(); public var clippedUvs:Array<Float> = new Array<Float>();
public var clippedTriangles:Vector<Int> = new Vector<Int>(); public var clippedTriangles:Array<Int> = new Array<Int>();
private var scratch:Vector<Float> = new Vector<Float>(); private var scratch:Array<Float> = new Array<Float>();
private var clipAttachment:ClippingAttachment; private var clipAttachment:ClippingAttachment;
private var clippingPolygons:Vector<Vector<Float>>; private var clippingPolygons:Array<Array<Float>>;
public function new() {} public function new() {}
@ -52,7 +51,7 @@ class SkeletonClipping {
if (clipAttachment != null) if (clipAttachment != null)
return 0; return 0;
clipAttachment = clip; clipAttachment = clip;
clippingPolygon.length = clip.worldVerticesLength; clippingPolygon.resize(clip.worldVerticesLength);
clip.computeWorldVertices(slot, 0, clippingPolygon.length, clippingPolygon, 0, 2); clip.computeWorldVertices(slot, 0, clippingPolygon.length, clippingPolygon, 0, 2);
SkeletonClipping.makeClockwise(clippingPolygon); SkeletonClipping.makeClockwise(clippingPolygon);
clippingPolygons = triangulator.decompose(clippingPolygon, triangulator.triangulate(clippingPolygon)); clippingPolygons = triangulator.decompose(clippingPolygon, triangulator.triangulate(clippingPolygon));
@ -74,23 +73,23 @@ class SkeletonClipping {
return; return;
clipAttachment = null; clipAttachment = null;
clippingPolygons = null; clippingPolygons = null;
clippedVertices.length = 0; clippedVertices.resize(0);
clippedUvs.length = 0; clippedUvs.resize(0);
clippedTriangles.length = 0; clippedTriangles.resize(0);
clippingPolygon.length = 0; clippingPolygon.resize(0);
clipOutput.length = 0; clipOutput.resize(0);
} }
public function isClipping():Bool { public function isClipping():Bool {
return clipAttachment != null; return clipAttachment != null;
} }
public function clipTriangles(vertices:Vector<Float>, triangles:Vector<Int>, trianglesLength:Float, uvs:Vector<Float>):Void { public function clipTriangles(vertices:Array<Float>, triangles:Array<Int>, trianglesLength:Float, uvs:Array<Float>):Void {
var polygonsCount:Int = clippingPolygons.length; var polygonsCount:Int = clippingPolygons.length;
var index:Int = 0; var index:Int = 0;
clippedVertices.length = 0; clippedVertices.resize(0);
clippedUvs.length = 0; clippedUvs.resize(0);
clippedTriangles.length = 0; clippedTriangles.resize(0);
var i:Int = 0; var i:Int = 0;
while (i < trianglesLength) { while (i < trianglesLength) {
var vertexOffset:Int = triangles[i] << 1; var vertexOffset:Int = triangles[i] << 1;
@ -110,9 +109,9 @@ class SkeletonClipping {
for (p in 0...polygonsCount) { for (p in 0...polygonsCount) {
var s:Int = clippedVertices.length; var s:Int = clippedVertices.length;
var clippedVerticesItems:Vector<Float>; var clippedVerticesItems:Array<Float>;
var clippedUvsItems:Vector<Float>; var clippedUvsItems:Array<Float>;
var clippedTrianglesItems:Vector<Int>; var clippedTrianglesItems:Array<Int>;
if (this.clip(x1, y1, x2, y2, x3, y3, clippingPolygons[p], clipOutput)) { if (this.clip(x1, y1, x2, y2, x3, y3, clippingPolygons[p], clipOutput)) {
var clipOutputLength:Int = clipOutput.length; var clipOutputLength:Int = clipOutput.length;
if (clipOutputLength == 0) if (clipOutputLength == 0)
@ -124,11 +123,11 @@ class SkeletonClipping {
var d:Float = 1 / (d0 * d2 + d1 * (y1 - y3)); var d:Float = 1 / (d0 * d2 + d1 * (y1 - y3));
var clipOutputCount:Int = clipOutputLength >> 1; var clipOutputCount:Int = clipOutputLength >> 1;
var clipOutputItems:Vector<Float> = clipOutput; var clipOutputItems:Array<Float> = clipOutput;
clippedVerticesItems = clippedVertices; clippedVerticesItems = clippedVertices;
clippedVerticesItems.length = s + clipOutputLength; clippedVerticesItems.resize(s + clipOutputLength);
clippedUvsItems = clippedUvs; clippedUvsItems = clippedUvs;
clippedUvsItems.length = s + clipOutputLength; clippedUvsItems.resize(s + clipOutputLength);
var ii:Int = 0; var ii:Int = 0;
while (ii < clipOutputLength) { while (ii < clipOutputLength) {
@ -149,7 +148,7 @@ class SkeletonClipping {
s = clippedTriangles.length; s = clippedTriangles.length;
clippedTrianglesItems = clippedTriangles; clippedTrianglesItems = clippedTriangles;
clippedTrianglesItems.length = s + 3 * (clipOutputCount - 2); clippedTrianglesItems.resize(s + 3 * (clipOutputCount - 2));
clipOutputCount--; clipOutputCount--;
for (ii in 1...clipOutputCount) { for (ii in 1...clipOutputCount) {
clippedTrianglesItems[s] = index; clippedTrianglesItems[s] = index;
@ -160,7 +159,7 @@ class SkeletonClipping {
index += clipOutputCount + 1; index += clipOutputCount + 1;
} else { } else {
clippedVerticesItems = clippedVertices; clippedVerticesItems = clippedVertices;
clippedVerticesItems.length = s + 3 * 2; clippedVerticesItems.resize(s + 3 * 2);
clippedVerticesItems[s] = x1; clippedVerticesItems[s] = x1;
clippedVerticesItems[s + 1] = y1; clippedVerticesItems[s + 1] = y1;
clippedVerticesItems[s + 2] = x2; clippedVerticesItems[s + 2] = x2;
@ -169,7 +168,7 @@ class SkeletonClipping {
clippedVerticesItems[s + 5] = y3; clippedVerticesItems[s + 5] = y3;
clippedUvsItems = clippedUvs; clippedUvsItems = clippedUvs;
clippedUvsItems.length = s + 3 * 2; clippedUvsItems.resize(s + 3 * 2);
clippedUvsItems[s] = u1; clippedUvsItems[s] = u1;
clippedUvsItems[s + 1] = v1; clippedUvsItems[s + 1] = v1;
clippedUvsItems[s + 2] = u2; clippedUvsItems[s + 2] = u2;
@ -179,7 +178,7 @@ class SkeletonClipping {
s = clippedTriangles.length; s = clippedTriangles.length;
clippedTrianglesItems = clippedTriangles; clippedTrianglesItems = clippedTriangles;
clippedTrianglesItems.length = s + 3; clippedTrianglesItems.resize(s + 3);
clippedTrianglesItems[s] = index; clippedTrianglesItems[s] = index;
clippedTrianglesItems[s + 1] = (index + 1); clippedTrianglesItems[s + 1] = (index + 1);
clippedTrianglesItems[s + 2] = (index + 2); clippedTrianglesItems[s + 2] = (index + 2);
@ -194,12 +193,12 @@ class SkeletonClipping {
/** Clips the input triangle against the convex, clockwise clipping area. If the triangle lies entirely within the clipping /** Clips the input triangle against the convex, clockwise clipping area. If the triangle lies entirely within the clipping
* area, false is returned. The clipping area must duplicate the first vertex at the end of the vertices list. */ * area, false is returned. The clipping area must duplicate the first vertex at the end of the vertices list. */
public function clip(x1:Float, y1:Float, x2:Float, y2:Float, x3:Float, y3:Float, clippingArea:Vector<Float>, output:Vector<Float>):Bool { public function clip(x1:Float, y1:Float, x2:Float, y2:Float, x3:Float, y3:Float, clippingArea:Array<Float>, output:Array<Float>):Bool {
var originalOutput:Vector<Float> = output; var originalOutput:Array<Float> = output;
var clipped:Bool = false; var clipped:Bool = false;
// Avoid copy at the end. // Avoid copy at the end.
var input:Vector<Float> = null; var input:Array<Float> = null;
if (clippingArea.length % 4 >= 2) { if (clippingArea.length % 4 >= 2) {
input = output; input = output;
output = scratch; output = scratch;
@ -207,7 +206,7 @@ class SkeletonClipping {
input = scratch; input = scratch;
} }
input.length = 0; input.resize(0);
input.push(x1); input.push(x1);
input.push(y1); input.push(y1);
input.push(x2); input.push(x2);
@ -216,9 +215,9 @@ class SkeletonClipping {
input.push(y3); input.push(y3);
input.push(x1); input.push(x1);
input.push(y1); input.push(y1);
output.length = 0; output.resize(0);
var clippingVertices:Vector<Float> = clippingArea; var clippingVertices:Array<Float> = clippingArea;
var clippingVerticesLast:Int = clippingArea.length - 4; var clippingVerticesLast:Int = clippingArea.length - 4;
var c0:Float, c2:Float, s:Float, ua:Float; var c0:Float, c2:Float, s:Float, ua:Float;
var i:Int = 0; var i:Int = 0;
@ -230,7 +229,7 @@ class SkeletonClipping {
edgeY2:Float = clippingVertices[i + 3]; edgeY2:Float = clippingVertices[i + 3];
var deltaX:Float = edgeX - edgeX2, deltaY:Float = edgeY - edgeY2; var deltaX:Float = edgeX - edgeX2, deltaY:Float = edgeY - edgeY2;
var inputVertices:Vector<Float> = input; var inputVertices:Array<Float> = input;
var inputVerticesLength:Int = input.length - 2, var inputVerticesLength:Int = input.length - 2,
outputStart:Int = output.length; outputStart:Int = output.length;
var ii:Int = 0; var ii:Int = 0;
@ -283,7 +282,7 @@ class SkeletonClipping {
if (outputStart == output.length) { if (outputStart == output.length) {
// All edges outside. // All edges outside.
originalOutput.length = 0; originalOutput.resize(0);
return true; return true;
} }
@ -292,29 +291,29 @@ class SkeletonClipping {
if (i == clippingVerticesLast) if (i == clippingVerticesLast)
break; break;
var temp:Vector<Float> = output; var temp:Array<Float> = output;
output = input; output = input;
output.length = 0; output.resize(0);
input = temp; input = temp;
i += 2; i += 2;
} }
if (originalOutput != output) { if (originalOutput != output) {
originalOutput.length = 0; originalOutput.resize(0);
n = output.length - 2; n = output.length - 2;
for (i in 0...n) { for (i in 0...n) {
originalOutput[i] = output[i]; originalOutput[i] = output[i];
} }
} else { } else {
originalOutput.length = originalOutput.length - 2; originalOutput.resize(originalOutput.length - 2);
} }
return clipped; return clipped;
} }
public static function makeClockwise(polygon:Vector<Float>):Void { public static function makeClockwise(polygon:Array<Float>):Void {
var vertices:Vector<Float> = polygon; var vertices:Array<Float> = polygon;
var verticeslength:Int = polygon.length; var verticeslength:Int = polygon.length;
var area:Float = vertices[verticeslength - 2] * vertices[1] - vertices[0] * vertices[verticeslength - 1]; var area:Float = vertices[verticeslength - 2] * vertices[1] - vertices[0] * vertices[verticeslength - 1];

View File

@ -29,7 +29,6 @@
package spine; package spine;
import openfl.Vector;
import openfl.utils.Assets; import openfl.utils.Assets;
import spine.animation.Animation; import spine.animation.Animation;
import spine.atlas.TextureAtlas; import spine.atlas.TextureAtlas;
@ -39,15 +38,15 @@ class SkeletonData {
/** May be null. */ /** May be null. */
public var name:String; public var name:String;
public var bones:Vector<BoneData> = new Vector<BoneData>(); // Ordered parents first. public var bones:Array<BoneData> = new Array<BoneData>(); // Ordered parents first.
public var slots:Vector<SlotData> = new Vector<SlotData>(); // Setup pose draw order. public var slots:Array<SlotData> = new Array<SlotData>(); // Setup pose draw order.
public var skins:Vector<Skin> = new Vector<Skin>(); public var skins:Array<Skin> = new Array<Skin>();
public var defaultSkin:Skin; public var defaultSkin:Skin;
public var events:Vector<EventData> = new Vector<EventData>(); public var events:Array<EventData> = new Array<EventData>();
public var animations:Vector<Animation> = new Vector<Animation>(); public var animations:Array<Animation> = new Array<Animation>();
public var ikConstraints:Vector<IkConstraintData> = new Vector<IkConstraintData>(); public var ikConstraints:Array<IkConstraintData> = new Array<IkConstraintData>();
public var transformConstraints:Vector<TransformConstraintData> = new Vector<TransformConstraintData>(); public var transformConstraints:Array<TransformConstraintData> = new Array<TransformConstraintData>();
public var pathConstraints:Vector<PathConstraintData> = new Vector<PathConstraintData>(); public var pathConstraints:Array<PathConstraintData> = new Array<PathConstraintData>();
public var x:Float = 0; public var x:Float = 0;
public var y:Float = 0; public var y:Float = 0;
public var width:Float = 0; public var width:Float = 0;

View File

@ -31,8 +31,6 @@ package spine;
import Reflect; import Reflect;
import haxe.Json; import haxe.Json;
import openfl.Vector;
import openfl.utils.Object;
import spine.animation.AlphaTimeline; import spine.animation.AlphaTimeline;
import spine.animation.Animation; import spine.animation.Animation;
import spine.animation.AttachmentTimeline; import spine.animation.AttachmentTimeline;
@ -78,7 +76,7 @@ class SkeletonJson {
public var attachmentLoader:AttachmentLoader; public var attachmentLoader:AttachmentLoader;
public var scale:Float = 1; public var scale:Float = 1;
private var linkedMeshes:Vector<LinkedMesh> = new Vector<LinkedMesh>(); private var linkedMeshes:Array<LinkedMesh> = new Array<LinkedMesh>();
public function new(attachmentLoader:AttachmentLoader) { public function new(attachmentLoader:AttachmentLoader) {
this.attachmentLoader = attachmentLoader; this.attachmentLoader = attachmentLoader;
@ -93,7 +91,7 @@ class SkeletonJson {
var skeletonData:SkeletonData = new SkeletonData(); var skeletonData:SkeletonData = new SkeletonData();
// Skeleton. // Skeleton.
var skeletonMap:Object = getString(root, "skeleton", ""); var skeletonMap = getString(root, "skeleton", "");
if (skeletonMap != null) { if (skeletonMap != null) {
skeletonData.hash = getString(skeletonMap, "hash", ""); skeletonData.hash = getString(skeletonMap, "hash", "");
skeletonData.version = getString(skeletonMap, "spine", ""); skeletonData.version = getString(skeletonMap, "spine", "");
@ -318,11 +316,11 @@ class SkeletonJson {
} }
if (Reflect.hasField(skinMap, "attachments")) { if (Reflect.hasField(skinMap, "attachments")) {
var attachments:Object = Reflect.getProperty(skinMap, "attachments"); var attachments:Dynamic = Reflect.getProperty(skinMap, "attachments");
for (slotName in attachments) { for (slotName in Reflect.fields(attachments)) {
var slot:SlotData = skeletonData.findSlot(slotName); var slot:SlotData = skeletonData.findSlot(slotName);
var slotEntry:Object = Reflect.getProperty(attachments, slotName); var slotEntry:Dynamic = Reflect.getProperty(attachments, slotName);
for (attachmentName in slotEntry) { for (attachmentName in Reflect.fields(slotEntry)) {
var attachment:Attachment = readAttachment(Reflect.getProperty(slotEntry, attachmentName), skin, slot.index, attachmentName, var attachment:Attachment = readAttachment(Reflect.getProperty(slotEntry, attachmentName), skin, slot.index, attachmentName,
skeletonData); skeletonData);
if (attachment != null) { if (attachment != null) {
@ -352,12 +350,12 @@ class SkeletonJson {
if (linkedMesh.mesh.region != null) if (linkedMesh.mesh.region != null)
linkedMesh.mesh.updateRegion(); linkedMesh.mesh.updateRegion();
} }
linkedMeshes.length = 0; linkedMeshes.resize(0);
// Events. // Events.
var events:Object = Reflect.getProperty(root, "events"); var events:Dynamic = Reflect.getProperty(root, "events");
for (eventName in events) { for (eventName in Reflect.fields(events)) {
var eventMap:Map<String, Dynamic> = events[eventName]; var eventMap:Map<String, Dynamic> = Reflect.field(events, eventName);
var eventData:EventData = new EventData(eventName); var eventData:EventData = new EventData(eventName);
eventData.intValue = getInt(eventMap, "int"); eventData.intValue = getInt(eventMap, "int");
eventData.floatValue = getFloat(eventMap, "float"); eventData.floatValue = getFloat(eventMap, "float");
@ -371,14 +369,14 @@ class SkeletonJson {
} }
// Animations. // Animations.
var animations:Object = Reflect.getProperty(root, "animations"); var animations:Dynamic = Reflect.getProperty(root, "animations");
for (animationName in animations) { for (animationName in Reflect.fields(animations)) {
readAnimation(animations[animationName], animationName, skeletonData); readAnimation(Reflect.field(animations, animationName), animationName, skeletonData);
} }
return skeletonData; return skeletonData;
} }
private function readSequence(map:Object) { private function readSequence(map:Dynamic) {
if (map == null) if (map == null)
return null; return null;
var sequence = new Sequence(getInt(map, "count", 0)); var sequence = new Sequence(getInt(map, "count", 0));
@ -388,15 +386,15 @@ class SkeletonJson {
return sequence; return sequence;
} }
private function readAttachment(map:Object, skin:Skin, slotIndex:Int, name:String, skeletonData:SkeletonData):Attachment { private function readAttachment(map:Dynamic, skin:Skin, slotIndex:Int, name:String, skeletonData:SkeletonData):Attachment {
if (map["name"] != null) if (Reflect.field(map, "name") != null)
name = map["name"]; name = Reflect.field(map, "name");
var color:String; var color:String;
switch (AttachmentType.fromName(Reflect.hasField(map, "type") ? Reflect.getProperty(map, "type") : "region")) { switch (AttachmentType.fromName(Reflect.hasField(map, "type") ? Reflect.getProperty(map, "type") : "region")) {
case AttachmentType.region: case AttachmentType.region:
var path = getString(map, "path", name); var path = getString(map, "path", name);
var sequence = readSequence(map["sequence"]); var sequence = readSequence(Reflect.field(map, "sequence"));
var region:RegionAttachment = attachmentLoader.newRegionAttachment(skin, name, path, sequence); var region:RegionAttachment = attachmentLoader.newRegionAttachment(skin, name, path, sequence);
if (region == null) if (region == null)
return null; return null;
@ -419,7 +417,7 @@ class SkeletonJson {
return region; return region;
case AttachmentType.mesh, AttachmentType.linkedmesh: case AttachmentType.mesh, AttachmentType.linkedmesh:
var path = getString(map, "path", name); var path = getString(map, "path", name);
var sequence = readSequence(map["sequence"]); var sequence = readSequence(Reflect.field(map, "sequence"));
var mesh:MeshAttachment = attachmentLoader.newMeshAttachment(skin, name, path, sequence); var mesh:MeshAttachment = attachmentLoader.newMeshAttachment(skin, name, path, sequence);
if (mesh == null) if (mesh == null)
return null; return null;
@ -434,20 +432,20 @@ class SkeletonJson {
mesh.height = getFloat(map, "height") * scale; mesh.height = getFloat(map, "height") * scale;
mesh.sequence = sequence; mesh.sequence = sequence;
if (map["parent"] != null) { if (Reflect.field(map, "parent") != null) {
var inheritTimelines:Bool = map.hasOwnProperty("timelines") ? cast(map["timelines"], Bool) : true; var inheritTimelines:Bool = map.hasOwnProperty("timelines") ? cast(Reflect.field(map, "timelines"), Bool) : true;
linkedMeshes.push(new LinkedMesh(mesh, map["skin"], slotIndex, map["parent"], inheritTimelines)); linkedMeshes.push(new LinkedMesh(mesh, Reflect.field(map, "skin"), slotIndex, Reflect.field(map, "parent"), inheritTimelines));
return mesh; return mesh;
} }
var uvs:Vector<Float> = getFloatArray(map, "uvs"); var uvs:Array<Float> = getFloatArray(map, "uvs");
readVertices(map, mesh, uvs.length); readVertices(map, mesh, uvs.length);
mesh.triangles = getIntArray(map, "triangles"); mesh.triangles = getIntArray(map, "triangles");
mesh.regionUVs = uvs; mesh.regionUVs = uvs;
if (mesh.region != null) if (mesh.region != null)
mesh.updateRegion(); mesh.updateRegion();
if (map["edges"] != null) if (Reflect.field(map, "edges") != null)
mesh.edges = getIntArray(map, "edges"); mesh.edges = getIntArray(map, "edges");
mesh.hullLength = getInt(map, "hull") * 2; mesh.hullLength = getInt(map, "hull") * 2;
return mesh; return mesh;
@ -455,18 +453,18 @@ class SkeletonJson {
var box:BoundingBoxAttachment = attachmentLoader.newBoundingBoxAttachment(skin, name); var box:BoundingBoxAttachment = attachmentLoader.newBoundingBoxAttachment(skin, name);
if (box == null) if (box == null)
return null; return null;
readVertices(map, box, Std.parseInt(map["vertexCount"]) << 1); readVertices(map, box, Std.parseInt(Reflect.field(map, "vertexCount")) << 1);
return box; return box;
case AttachmentType.path: case AttachmentType.path:
var path:PathAttachment = attachmentLoader.newPathAttachment(skin, name); var path:PathAttachment = attachmentLoader.newPathAttachment(skin, name);
if (path == null) if (path == null)
return null; return null;
path.closed = map.hasOwnProperty("closed") ? cast(map["closed"], Bool) : false; path.closed = map.hasOwnProperty("closed") ? cast(Reflect.field(map, "closed"), Bool) : false;
path.constantSpeed = map.hasOwnProperty("constantSpeed") ? cast(map["constantSpeed"], Bool) : true; path.constantSpeed = map.hasOwnProperty("constantSpeed") ? cast(Reflect.field(map, "constantSpeed"), Bool) : true;
var vertexCount:Int = Std.parseInt(map["vertexCount"]); var vertexCount:Int = Std.parseInt(Reflect.field(map, "vertexCount"));
readVertices(map, path, vertexCount << 1); readVertices(map, path, vertexCount << 1);
var lengths:Vector<Float> = new Vector<Float>(); var lengths:Array<Float> = new Array<Float>();
for (curves in cast(map["lengths"], Array<Dynamic>)) { for (curves in cast(Reflect.field(map, "lengths"), Array<Dynamic>)) {
lengths.push(Std.parseFloat(curves) * scale); lengths.push(Std.parseFloat(curves) * scale);
} }
path.lengths = lengths; path.lengths = lengths;
@ -475,9 +473,9 @@ class SkeletonJson {
var point:PointAttachment = attachmentLoader.newPointAttachment(skin, name); var point:PointAttachment = attachmentLoader.newPointAttachment(skin, name);
if (point == null) if (point == null)
return null; return null;
point.x = map.hasOwnProperty("x") ? Std.parseFloat(map["x"]) * scale : 0; point.x = getFloat(map, "x", 0) * scale;
point.y = map.hasOwnProperty("y") ? Std.parseFloat(map["y"]) * scale : 0; point.y = getFloat(map, "y", 0) * scale;
point.rotation = map.hasOwnProperty("rotation") ? Std.parseFloat(map["rotation"]) : 0; point.rotation = getFloat(map, "rotation", 0);
color = Reflect.getProperty(map, "color"); color = Reflect.getProperty(map, "color");
if (color != null) { if (color != null) {
point.color.setFromString(color); point.color.setFromString(color);
@ -487,14 +485,14 @@ class SkeletonJson {
var clip:ClippingAttachment = attachmentLoader.newClippingAttachment(skin, name); var clip:ClippingAttachment = attachmentLoader.newClippingAttachment(skin, name);
if (clip == null) if (clip == null)
return null; return null;
var end:String = map["end"]; var end:String = getString(map, "end", null);
if (end != null) { if (end != null) {
var slot:SlotData = skeletonData.findSlot(end); var slot:SlotData = skeletonData.findSlot(end);
if (slot == null) if (slot == null)
throw new SpineException("Clipping end slot not found: " + end); throw new SpineException("Clipping end slot not found: " + end);
clip.endSlot = slot; clip.endSlot = slot;
} }
var vertexCount:Int = Std.parseInt(map["vertexCount"]); var vertexCount:Int = getInt(map, "vertexCount", 0);
readVertices(map, clip, vertexCount << 1); readVertices(map, clip, vertexCount << 1);
color = Reflect.getProperty(map, "color"); color = Reflect.getProperty(map, "color");
if (color != null) { if (color != null) {
@ -505,9 +503,9 @@ class SkeletonJson {
return null; return null;
} }
private function readVertices(map:Object, attachment:VertexAttachment, verticesLength:Int):Void { private function readVertices(map:Dynamic, attachment:VertexAttachment, verticesLength:Int):Void {
attachment.worldVerticesLength = verticesLength; attachment.worldVerticesLength = verticesLength;
var vertices:Vector<Float> = getFloatArray(map, "vertices"); var vertices:Array<Float> = getFloatArray(map, "vertices");
if (verticesLength == vertices.length) { if (verticesLength == vertices.length) {
if (scale != 1) { if (scale != 1) {
for (i in 0...vertices.length) { for (i in 0...vertices.length) {
@ -518,8 +516,8 @@ class SkeletonJson {
return; return;
} }
var weights:Vector<Float> = new Vector<Float>(); var weights:Array<Float> = new Array<Float>();
var bones:Vector<Int> = new Vector<Int>(); var bones:Array<Int> = new Array<Int>();
var i:Int = 0; var i:Int = 0;
var n:Int = vertices.length; var n:Int = vertices.length;
while (i < n) { while (i < n) {
@ -539,28 +537,28 @@ class SkeletonJson {
attachment.vertices = weights; attachment.vertices = weights;
} }
private function readAnimation(map:Object, name:String, skeletonData:SkeletonData):Void { private function readAnimation(map:Dynamic, name:String, skeletonData:SkeletonData):Void {
var timelines:Vector<Timeline> = new Vector<Timeline>(); var timelines:Array<Timeline> = new Array<Timeline>();
var slotMap:Object; var slotMap:Dynamic;
var slotIndex:Int; var slotIndex:Int;
var slotName:String; var slotName:String;
var timelineMap:Array<Object>; var timelineMap:Array<Dynamic>;
var keyMap:Object; var keyMap:Dynamic;
var nextMap:Object; var nextMap:Dynamic;
var frame:Int, bezier:Int; var frame:Int, bezier:Int;
var time:Float, time2:Float; var time:Float, time2:Float;
var curve:Object; var curve:Dynamic;
var timelineName:String; var timelineName:String;
// Slot timelines. // Slot timelines.
var slots:Object = Reflect.getProperty(map, "slots"); var slots:Dynamic = Reflect.getProperty(map, "slots");
for (slotName in slots) { for (slotName in Reflect.fields(slots)) {
slotMap = slots[slotName]; slotMap = Reflect.field(slots, slotName);
slotIndex = skeletonData.findSlot(slotName).index; slotIndex = skeletonData.findSlot(slotName).index;
for (timelineName in slotMap) { for (timelineName in Reflect.fields(slotMap)) {
timelineMap = slotMap[timelineName]; timelineMap = Reflect.field(slotMap, timelineName);
if (timelineMap == null) if (timelineMap == null)
continue; continue;
if (timelineName == "attachment") { if (timelineName == "attachment") {
@ -721,14 +719,14 @@ class SkeletonJson {
} }
// Bone timelines. // Bone timelines.
var bones:Object = Reflect.getProperty(map, "bones"); var bones:Dynamic = Reflect.getProperty(map, "bones");
for (boneName in bones) { for (boneName in Reflect.fields(bones)) {
var boneIndex:Int = skeletonData.findBoneIndex(boneName); var boneIndex:Int = skeletonData.findBoneIndex(boneName);
if (boneIndex == -1) if (boneIndex == -1)
throw new SpineException("Bone not found: " + boneName); throw new SpineException("Bone not found: " + boneName);
var boneMap:Object = bones[boneName]; var boneMap:Dynamic = Reflect.field(bones, boneName);
for (timelineName in boneMap) { for (timelineName in Reflect.fields(boneMap)) {
timelineMap = boneMap[timelineName]; timelineMap = Reflect.field(boneMap, timelineName);
if (timelineMap.length == 0) if (timelineMap.length == 0)
continue; continue;
@ -768,9 +766,9 @@ class SkeletonJson {
} }
// IK constraint timelines. // IK constraint timelines.
var iks:Object = Reflect.getProperty(map, "ik"); var iks:Dynamic = Reflect.getProperty(map, "ik");
for (ikConstraintName in iks) { for (ikConstraintName in Reflect.fields(iks)) {
timelineMap = iks[ikConstraintName]; timelineMap = Reflect.field(iks, ikConstraintName);
keyMap = timelineMap[0]; keyMap = timelineMap[0];
if (keyMap == null) if (keyMap == null)
continue; continue;
@ -819,9 +817,9 @@ class SkeletonJson {
var mixRotate:Float, mixRotate2:Float; var mixRotate:Float, mixRotate2:Float;
var mixX:Float, mixX2:Float; var mixX:Float, mixX2:Float;
var mixY:Float, mixY2:Float; var mixY:Float, mixY2:Float;
var transforms:Object = Reflect.getProperty(map, "transform"); var transforms:Dynamic = Reflect.getProperty(map, "transform");
for (transformName in transforms) { for (transformName in Reflect.fields(transforms)) {
timelineMap = transforms[transformName]; timelineMap = Reflect.field(transforms, transformName);
keyMap = timelineMap[0]; keyMap = timelineMap[0];
if (keyMap == null) if (keyMap == null)
continue; continue;
@ -879,16 +877,16 @@ class SkeletonJson {
} }
// Path constraint timelines. // Path constraint timelines.
var paths:Object = Reflect.getProperty(map, "path"); var paths:Dynamic = Reflect.getProperty(map, "path");
for (pathName in paths) { for (pathName in Reflect.fields(paths)) {
var index:Int = skeletonData.findPathConstraintIndex(pathName); var index:Int = skeletonData.findPathConstraintIndex(pathName);
if (index == -1) if (index == -1)
throw new SpineException("Path constraint not found: " + pathName); throw new SpineException("Path constraint not found: " + pathName);
var pathData:PathConstraintData = skeletonData.pathConstraints[index]; var pathData:PathConstraintData = skeletonData.pathConstraints[index];
var pathMap:Object = paths[pathName]; var pathMap:Dynamic = Reflect.field(paths, pathName);
for (timelineName in pathMap) { for (timelineName in Reflect.fields(pathMap)) {
timelineMap = pathMap[timelineName]; timelineMap = Reflect.field(pathMap, timelineName);
keyMap = timelineMap[0]; keyMap = timelineMap[0];
if (keyMap == null) if (keyMap == null)
continue; continue;
@ -941,26 +939,26 @@ class SkeletonJson {
} }
// Attachment timelines. // Attachment timelines.
var attachments:Object = Reflect.getProperty(map, "attachments"); var attachments:Dynamic = Reflect.getProperty(map, "attachments");
for (attachmentsName in attachments) { for (attachmentsName in Reflect.fields(attachments)) {
var attachmentsMap:Object = attachments[attachmentsName]; var attachmentsMap:Dynamic = Reflect.field(attachments, attachmentsName);
var skin:Skin = skeletonData.findSkin(attachmentsName); var skin:Skin = skeletonData.findSkin(attachmentsName);
if (skin == null) if (skin == null)
throw new SpineException("Skin not found: " + attachmentsName); throw new SpineException("Skin not found: " + attachmentsName);
for (slotMapName in attachmentsMap) { for (slotMapName in Reflect.fields(attachmentsMap)) {
slotMap = attachmentsMap[slotMapName]; slotMap = Reflect.field(attachmentsMap, slotMapName);
slotIndex = skeletonData.findSlot(slotMapName).index; slotIndex = skeletonData.findSlot(slotMapName).index;
if (slotIndex == -1) if (slotIndex == -1)
throw new SpineException("Slot not found: " + slotMapName); throw new SpineException("Slot not found: " + slotMapName);
for (attachmentMapName in slotMap) { for (attachmentMapName in Reflect.fields(slotMap)) {
var attachmentMap = slotMap[attachmentMapName]; var attachmentMap = Reflect.field(slotMap, attachmentMapName);
var attachment:Attachment = skin.getAttachment(slotIndex, attachmentMapName); var attachment:Attachment = skin.getAttachment(slotIndex, attachmentMapName);
if (attachment == null) if (attachment == null)
throw new SpineException("Timeline attachment not found: " + attachmentMapName); throw new SpineException("Timeline attachment not found: " + attachmentMapName);
for (timelineMapName in attachmentMap) { for (timelineMapName in Reflect.fields(attachmentMap)) {
var timelineMap = attachmentMap[timelineMapName]; var timelineMap = Reflect.field(attachmentMap, timelineMapName);
var keyMap = timelineMap[0]; var keyMap = timelineMap[0];
if (keyMap == null) if (keyMap == null)
continue; continue;
@ -968,7 +966,7 @@ class SkeletonJson {
if (timelineMapName == "deform") { if (timelineMapName == "deform") {
var vertexAttachment = cast(attachment, VertexAttachment); var vertexAttachment = cast(attachment, VertexAttachment);
var weighted:Bool = vertexAttachment.bones != null; var weighted:Bool = vertexAttachment.bones != null;
var vertices:Vector<Float> = vertexAttachment.vertices; var vertices:Array<Float> = vertexAttachment.vertices;
var deformLength:Int = weighted ? Std.int(vertices.length / 3 * 2) : vertices.length; var deformLength:Int = weighted ? Std.int(vertices.length / 3 * 2) : vertices.length;
var deformTimeline:DeformTimeline = new DeformTimeline(timelineMap.length, timelineMap.length, slotIndex, vertexAttachment); var deformTimeline:DeformTimeline = new DeformTimeline(timelineMap.length, timelineMap.length, slotIndex, vertexAttachment);
@ -976,14 +974,20 @@ class SkeletonJson {
frame = 0; frame = 0;
bezier = 0; bezier = 0;
while (true) { while (true) {
var deform:Vector<Float>; var deform:Array<Float>;
var verticesValue:Vector<Float> = Reflect.getProperty(keyMap, "vertices"); var verticesValue:Array<Float> = Reflect.getProperty(keyMap, "vertices");
if (verticesValue == null) { if (verticesValue == null) {
deform = weighted ? new Vector<Float>(deformLength, true) : vertices; if (weighted) {
deform = new Array<Float>();
deform.resize(deformLength);
} else {
deform = vertices;
}
} else { } else {
deform = new Vector<Float>(deformLength, true); deform = new Array<Float>();
deform.resize(deformLength);
var start:Int = getInt(keyMap, "offset"); var start:Int = getInt(keyMap, "offset");
var temp:Vector<Float> = getFloatArray(keyMap, "vertices"); var temp:Array<Float> = getFloatArray(keyMap, "vertices");
for (i in 0...temp.length) { for (i in 0...temp.length) {
deform[start + i] = temp[i]; deform[start + i] = temp[i];
} }
@ -1040,21 +1044,23 @@ class SkeletonJson {
// Draw order timelines. // Draw order timelines.
if (Reflect.hasField(map, "drawOrder")) { if (Reflect.hasField(map, "drawOrder")) {
var drawOrders:Array<Dynamic> = cast(map["drawOrder"], Array<Dynamic>); var drawOrders:Array<Dynamic> = cast(Reflect.field(map, "drawOrder"), Array<Dynamic>);
if (drawOrders != null) { if (drawOrders != null) {
var drawOrderTimeline:DrawOrderTimeline = new DrawOrderTimeline(drawOrders.length); var drawOrderTimeline:DrawOrderTimeline = new DrawOrderTimeline(drawOrders.length);
var slotCount:Int = skeletonData.slots.length; var slotCount:Int = skeletonData.slots.length;
frame = 0; frame = 0;
for (drawOrderMap in drawOrders) { for (drawOrderMap in drawOrders) {
var drawOrder:Vector<Int> = null; var drawOrder:Array<Int> = null;
var offsets:Array<Dynamic> = Reflect.getProperty(drawOrderMap, "offsets"); var offsets:Array<Dynamic> = Reflect.getProperty(drawOrderMap, "offsets");
if (offsets != null) { if (offsets != null) {
drawOrder = new Vector<Int>(slotCount, true); drawOrder = new Array<Int>();
drawOrder.resize(slotCount);
var i = slotCount - 1; var i = slotCount - 1;
while (i >= 0) { while (i >= 0) {
drawOrder[i--] = -1; drawOrder[i--] = -1;
} }
var unchanged:Vector<Int> = new Vector<Int>(slotCount - offsets.length, true); var unchanged:Array<Int> = new Array<Int>();
unchanged.resize(slotCount - offsets.length);
var originalIndex:Int = 0, unchangedIndex:Int = 0; var originalIndex:Int = 0, unchangedIndex:Int = 0;
for (offsetMap in offsets) { for (offsetMap in offsets) {
slotIndex = skeletonData.findSlot(Reflect.getProperty(offsetMap, "slot")).index; slotIndex = skeletonData.findSlot(Reflect.getProperty(offsetMap, "slot")).index;
@ -1087,7 +1093,7 @@ class SkeletonJson {
// Event timelines. // Event timelines.
if (Reflect.hasField(map, "events")) { if (Reflect.hasField(map, "events")) {
var eventsMap:Array<Dynamic> = cast(map["events"], Array<Dynamic>); var eventsMap:Array<Dynamic> = cast(Reflect.field(map, "events"), Array<Dynamic>);
if (eventsMap != null) { if (eventsMap != null) {
var eventTimeline:EventTimeline = new EventTimeline(eventsMap.length); var eventTimeline:EventTimeline = new EventTimeline(eventsMap.length);
frame = 0; frame = 0;
@ -1120,21 +1126,21 @@ class SkeletonJson {
} }
static private function readTimeline(keys:Array<Dynamic>, timeline:CurveTimeline1, defaultValue:Float, scale:Float):CurveTimeline1 { static private function readTimeline(keys:Array<Dynamic>, timeline:CurveTimeline1, defaultValue:Float, scale:Float):CurveTimeline1 {
var keyMap:Object = keys[0]; var keyMap:Dynamic = keys[0];
var time:Float = getFloat(keyMap, "time"); var time:Float = getFloat(keyMap, "time");
var value:Float = getFloat(keyMap, "value", defaultValue) * scale; var value:Float = getFloat(keyMap, "value", defaultValue) * scale;
var bezier:Int = 0; var bezier:Int = 0;
var frame:Int = 0; var frame:Int = 0;
while (true) { while (true) {
timeline.setFrame(frame, time, value); timeline.setFrame(frame, time, value);
var nextMap:Object = keys[frame + 1]; var nextMap:Dynamic = keys[frame + 1];
if (nextMap == null) { if (nextMap == null) {
timeline.shrink(bezier); timeline.shrink(bezier);
break; break;
} }
var time2:Float = getFloat(nextMap, "time"); var time2:Float = getFloat(nextMap, "time");
var value2:Float = getFloat(nextMap, "value", defaultValue) * scale; var value2:Float = getFloat(nextMap, "value", defaultValue) * scale;
var curve:Object = keyMap.curve; var curve:Dynamic = keyMap.curve;
if (curve != null) { if (curve != null) {
bezier = readCurve(curve, timeline, bezier, frame, 0, time, time2, value, value2, scale); bezier = readCurve(curve, timeline, bezier, frame, 0, time, time2, value, value2, scale);
} }
@ -1149,7 +1155,7 @@ class SkeletonJson {
static private function readTimeline2(keys:Array<Dynamic>, timeline:CurveTimeline2, name1:String, name2:String, defaultValue:Float, static private function readTimeline2(keys:Array<Dynamic>, timeline:CurveTimeline2, name1:String, name2:String, defaultValue:Float,
scale:Float):CurveTimeline2 { scale:Float):CurveTimeline2 {
var keyMap:Object = keys[0]; var keyMap:Dynamic = keys[0];
var time:Float = getFloat(keyMap, "time"); var time:Float = getFloat(keyMap, "time");
var value1:Float = getFloat(keyMap, name1, defaultValue) * scale; var value1:Float = getFloat(keyMap, name1, defaultValue) * scale;
var value2:Float = getFloat(keyMap, name2, defaultValue) * scale; var value2:Float = getFloat(keyMap, name2, defaultValue) * scale;
@ -1157,7 +1163,7 @@ class SkeletonJson {
var frame:Int = 0; var frame:Int = 0;
while (true) { while (true) {
timeline.setFrame(frame, time, value1, value2); timeline.setFrame(frame, time, value1, value2);
var nextMap:Object = keys[frame + 1]; var nextMap:Dynamic = keys[frame + 1];
if (nextMap == null) { if (nextMap == null) {
timeline.shrink(bezier); timeline.shrink(bezier);
break; break;
@ -1165,7 +1171,7 @@ class SkeletonJson {
var time2:Float = getFloat(nextMap, "time"); var time2:Float = getFloat(nextMap, "time");
var nvalue1:Float = getFloat(nextMap, name1, defaultValue) * scale; var nvalue1:Float = getFloat(nextMap, name1, defaultValue) * scale;
var nvalue2:Float = getFloat(nextMap, name2, defaultValue) * scale; var nvalue2:Float = getFloat(nextMap, name2, defaultValue) * scale;
var curve:Object = keyMap.curve; var curve:Dynamic = keyMap.curve;
if (curve != null) { if (curve != null) {
bezier = readCurve(curve, timeline, bezier, frame, 0, time, time2, value1, nvalue1, scale); bezier = readCurve(curve, timeline, bezier, frame, 0, time, time2, value1, nvalue1, scale);
bezier = readCurve(curve, timeline, bezier, frame, 1, time, time2, value2, nvalue2, scale); bezier = readCurve(curve, timeline, bezier, frame, 1, time, time2, value2, nvalue2, scale);
@ -1180,7 +1186,7 @@ class SkeletonJson {
return timeline; return timeline;
} }
static private function readCurve(curve:Object, timeline:CurveTimeline, bezier:Int, frame:Int, value:Int, time1:Float, time2:Float, value1:Float, static private function readCurve(curve:Dynamic, timeline:CurveTimeline, bezier:Int, frame:Int, value:Int, time1:Float, time2:Float, value1:Float,
value2:Float, scale:Float):Int { value2:Float, scale:Float):Int {
if (curve == "stepped") { if (curve == "stepped") {
timeline.setStepped(frame); timeline.setStepped(frame);
@ -1196,42 +1202,44 @@ class SkeletonJson {
return bezier + 1; return bezier + 1;
} }
static private function getValue(map:Object, name:String, defaultValue:Dynamic):Dynamic { static private function getValue(map:Dynamic, name:String, defaultValue:Dynamic):Dynamic {
if (map.hasOwnProperty(name)) if (map.hasOwnProperty(name))
return map[name]; return Reflect.field(map, name);
return defaultValue; return defaultValue;
} }
static private function getString(value:Object, name:String, defaultValue:String):String { static private function getString(value:Dynamic, name:String, defaultValue:String):String {
if (Std.isOfType(value[name], String)) if (Std.isOfType(Reflect.field(value, name), String))
return cast(value[name], String); return cast(Reflect.field(value, name), String);
return defaultValue; return defaultValue;
} }
static private function getFloat(value:Object, name:String, defaultValue:Float = 0):Float { static private function getFloat(value:Dynamic, name:String, defaultValue:Float = 0):Float {
if (Std.isOfType(value[name], Float)) if (Std.isOfType(Reflect.field(value, name), Float))
return cast(value[name], Float); return cast(Reflect.field(value, name), Float);
return defaultValue; return defaultValue;
} }
static private function getFloatArray(map:Object, name:String):Vector<Float> { static private function getFloatArray(map:Dynamic, name:String):Array<Float> {
var list:Array<Dynamic> = cast(map[name], Array<Dynamic>); var list:Array<Dynamic> = cast(Reflect.field(map, name), Array<Dynamic>);
var values:Vector<Float> = new Vector<Float>(list.length, true); var values:Array<Float> = new Array<Float>();
values.resize(list.length);
for (i in 0...list.length) { for (i in 0...list.length) {
values[i] = cast(list[i], Float); values[i] = cast(list[i], Float);
} }
return values; return values;
} }
static private function getInt(value:Object, name:String, defaultValue:Int = 0):Int { static private function getInt(value:Dynamic, name:String, defaultValue:Int = 0):Int {
if (Std.isOfType(value[name], Int)) if (Std.isOfType(Reflect.field(value, name), Int))
return cast(value[name], Int); return cast(Reflect.field(value, name), Int);
return defaultValue; return defaultValue;
} }
static private function getIntArray(map:Object, name:String):Vector<Int> { static private function getIntArray(map:Dynamic, name:String):Array<Int> {
var list:Array<Dynamic> = cast(map[name], Array<Dynamic>); var list:Array<Dynamic> = cast(Reflect.field(map, name), Array<Dynamic>);
var values:Vector<Int> = new Vector<Int>(list.length, true); var values:Array<Int> = new Array<Int>();
values.resize(list.length);
for (i in 0...list.length) { for (i in 0...list.length) {
values[i] = Std.int(list[i]); values[i] = Std.int(list[i]);
} }

View File

@ -29,17 +29,16 @@
package spine; package spine;
import openfl.utils.Dictionary; import haxe.ds.StringMap;
import openfl.Vector;
import spine.attachments.Attachment; import spine.attachments.Attachment;
import spine.attachments.MeshAttachment; import spine.attachments.MeshAttachment;
/** Stores attachments by slot index and attachment name. */ /** Stores attachments by slot index and attachment name. */
class Skin { class Skin {
private var _name:String; private var _name:String;
private var _attachments:Vector<Dictionary<String, Attachment>> = new Vector<Dictionary<String, Attachment>>(); private var _attachments:Array<StringMap<Attachment>> = new Array<StringMap<Attachment>>();
private var _bones:Vector<BoneData> = new Vector<BoneData>(); private var _bones:Array<BoneData> = new Array<BoneData>();
private var _constraints:Vector<ConstraintData> = new Vector<ConstraintData>(); private var _constraints:Array<ConstraintData> = new Array<ConstraintData>();
public function new(name:String) { public function new(name:String) {
if (name == null) if (name == null)
@ -51,10 +50,10 @@ class Skin {
if (attachment == null) if (attachment == null)
throw new SpineException("attachment cannot be null."); throw new SpineException("attachment cannot be null.");
if (slotIndex >= _attachments.length) if (slotIndex >= _attachments.length)
_attachments.length = slotIndex + 1; _attachments.resize(slotIndex + 1);
if (_attachments[slotIndex] == null) if (_attachments[slotIndex] == null)
_attachments[slotIndex] = new Dictionary<String, Attachment>(); _attachments[slotIndex] = new StringMap<Attachment>();
_attachments[slotIndex][name] = attachment; _attachments[slotIndex].set(name, attachment);
} }
public function addSkin(skin:Skin):Void { public function addSkin(skin:Skin):Void {
@ -85,7 +84,7 @@ class Skin {
_constraints.push(constraint); _constraints.push(constraint);
} }
var attachments:Vector<SkinEntry> = skin.getAttachments(); var attachments:Array<SkinEntry> = skin.getAttachments();
for (i in 0...attachments.length) { for (i in 0...attachments.length) {
var attachment:SkinEntry = attachments[i]; var attachment:SkinEntry = attachments[i];
setAttachment(attachment.slotIndex, attachment.name, attachment.attachment); setAttachment(attachment.slotIndex, attachment.name, attachment.attachment);
@ -122,7 +121,7 @@ class Skin {
_constraints.push(constraint); _constraints.push(constraint);
} }
var attachments:Vector<SkinEntry> = skin.getAttachments(); var attachments:Array<SkinEntry> = skin.getAttachments();
for (i in 0...attachments.length) { for (i in 0...attachments.length) {
attachment = attachments[i]; attachment = attachments[i];
if (attachment.attachment == null) if (attachment.attachment == null)
@ -141,23 +140,23 @@ class Skin {
public function getAttachment(slotIndex:Int, name:String):Attachment { public function getAttachment(slotIndex:Int, name:String):Attachment {
if (slotIndex >= _attachments.length) if (slotIndex >= _attachments.length)
return null; return null;
var dictionary:Dictionary<String, Attachment> = _attachments[slotIndex]; var dictionary:StringMap<Attachment> = _attachments[slotIndex];
return dictionary != null ? dictionary[name] : null; return dictionary != null ? dictionary.get(name) : null;
} }
public function removeAttachment(slotIndex:Int, name:String):Void { public function removeAttachment(slotIndex:Int, name:String):Void {
var dictionary:Dictionary<String, Attachment> = _attachments[slotIndex]; var dictionary:StringMap<Attachment> = _attachments[slotIndex];
if (dictionary != null) if (dictionary != null)
dictionary.remove(name); dictionary.remove(name);
} }
public function getAttachments():Vector<SkinEntry> { public function getAttachments():Array<SkinEntry> {
var entries:Vector<SkinEntry> = new Vector<SkinEntry>(); var entries:Array<SkinEntry> = new Array<SkinEntry>();
for (slotIndex in 0..._attachments.length) { for (slotIndex in 0..._attachments.length) {
var attachments:Dictionary<String, Attachment> = _attachments[slotIndex]; var attachments:StringMap<Attachment> = _attachments[slotIndex];
if (attachments != null) { if (attachments != null) {
for (name in attachments.iterator()) { for (name in attachments.keys()) {
var attachment:Attachment = attachments[name]; var attachment:Attachment = attachments.get(name);
if (attachment != null) if (attachment != null)
entries.push(new SkinEntry(slotIndex, name, attachment)); entries.push(new SkinEntry(slotIndex, name, attachment));
} }
@ -166,12 +165,12 @@ class Skin {
return entries; return entries;
} }
public function getAttachmentsForSlot(slotIndex:Int):Vector<SkinEntry> { public function getAttachmentsForSlot(slotIndex:Int):Array<SkinEntry> {
var entries:Vector<SkinEntry> = new Vector<SkinEntry>(); var entries:Array<SkinEntry> = new Array<SkinEntry>();
var attachments:Dictionary<String, Attachment> = _attachments[slotIndex]; var attachments:StringMap<Attachment> = _attachments[slotIndex];
if (attachments != null) { if (attachments != null) {
for (name in attachments.iterator()) { for (name in attachments.keys()) {
var attachment:Attachment = attachments[name]; var attachment:Attachment = attachments.get(name);
if (attachment != null) if (attachment != null)
entries.push(new SkinEntry(slotIndex, name, attachment)); entries.push(new SkinEntry(slotIndex, name, attachment));
} }
@ -180,26 +179,26 @@ class Skin {
} }
public function clear():Void { public function clear():Void {
_attachments.length = 0; _attachments.resize(0);
_bones.length = 0; _bones.resize(0);
_constraints.length = 0; _constraints.resize(0);
} }
public var attachments(get, never):Vector<Dictionary<String, Attachment>>; public var attachments(get, never):Array<StringMap<Attachment>>;
private function get_attachments():Vector<Dictionary<String, Attachment>> { private function get_attachments():Array<StringMap<Attachment>> {
return _attachments; return _attachments;
} }
public var bones(get, never):Vector<BoneData>; public var bones(get, never):Array<BoneData>;
private function get_bones():Vector<BoneData> { private function get_bones():Array<BoneData> {
return _bones; return _bones;
} }
public var constraints(get, never):Vector<ConstraintData>; public var constraints(get, never):Array<ConstraintData>;
private function get_constraints():Vector<ConstraintData> { private function get_constraints():Array<ConstraintData> {
return _constraints; return _constraints;
} }
@ -221,9 +220,9 @@ class Skin {
for (slot in skeleton.slots) { for (slot in skeleton.slots) {
var slotAttachment:Attachment = slot.attachment; var slotAttachment:Attachment = slot.attachment;
if (slotAttachment != null && slotIndex < oldSkin.attachments.length) { if (slotAttachment != null && slotIndex < oldSkin.attachments.length) {
var dictionary:Dictionary<String, Attachment> = oldSkin.attachments[slotIndex]; var dictionary:StringMap<Attachment> = oldSkin.attachments[slotIndex];
for (name in dictionary) { for (name in dictionary.keys()) {
var skinAttachment:Attachment = dictionary[name]; var skinAttachment:Attachment = dictionary.get(name);
if (slotAttachment == skinAttachment) { if (slotAttachment == skinAttachment) {
var attachment:Attachment = getAttachment(slotIndex, name); var attachment:Attachment = getAttachment(slotIndex, name);
if (attachment != null) if (attachment != null)

View File

@ -29,7 +29,6 @@
package spine; package spine;
import openfl.Vector;
import spine.attachments.Attachment; import spine.attachments.Attachment;
import spine.attachments.VertexAttachment; import spine.attachments.VertexAttachment;
@ -45,7 +44,7 @@ class Slot {
public var sequenceIndex = -1; public var sequenceIndex = -1;
public var attachmentState:Int = 0; public var attachmentState:Int = 0;
public var deform:Vector<Float> = new Vector<Float>(); public var deform:Array<Float> = new Array<Float>();
public function new(data:SlotData, bone:Bone) { public function new(data:SlotData, bone:Bone) {
if (data == null) if (data == null)
@ -93,7 +92,7 @@ class Slot {
if (!Std.isOfType(attachmentNew, VertexAttachment) if (!Std.isOfType(attachmentNew, VertexAttachment)
|| !Std.isOfType(attachment, VertexAttachment) || !Std.isOfType(attachment, VertexAttachment)
|| cast(attachmentNew, VertexAttachment).timelineAttachment != cast(attachment, VertexAttachment).timelineAttachment) { || cast(attachmentNew, VertexAttachment).timelineAttachment != cast(attachment, VertexAttachment).timelineAttachment) {
deform = new Vector<Float>(); deform = new Array<Float>();
} }
_attachment = attachmentNew; _attachment = attachmentNew;
sequenceIndex = -1; sequenceIndex = -1;

View File

@ -29,15 +29,13 @@
package spine; package spine;
import openfl.Vector;
class SpacingMode { class SpacingMode {
public static var length(default, never):SpacingMode = new SpacingMode("length"); public static var length(default, never):SpacingMode = new SpacingMode("length");
public static var fixed(default, never):SpacingMode = new SpacingMode("fixed"); public static var fixed(default, never):SpacingMode = new SpacingMode("fixed");
public static var percent(default, never):SpacingMode = new SpacingMode("percent"); public static var percent(default, never):SpacingMode = new SpacingMode("percent");
public static var proportional(default, never):SpacingMode = new SpacingMode("proportional"); public static var proportional(default, never):SpacingMode = new SpacingMode("proportional");
public static var values(default, never):Vector<SpacingMode> = Vector.ofArray([length, fixed, percent, proportional]); public static var values(default, never):Array<SpacingMode> = [length, fixed, percent, proportional];
public var name(default, null):String; public var name(default, null):String;

View File

@ -29,11 +29,9 @@
package spine; package spine;
import openfl.Vector;
class TransformConstraint implements Updatable { class TransformConstraint implements Updatable {
private var _data:TransformConstraintData; private var _data:TransformConstraintData;
private var _bones:Vector<Bone>; private var _bones:Array<Bone>;
public var target:Bone; public var target:Bone;
public var mixRotate:Float = 0; public var mixRotate:Float = 0;
@ -43,7 +41,7 @@ class TransformConstraint implements Updatable {
public var mixScaleY:Float = 0; public var mixScaleY:Float = 0;
public var mixShearY:Float = 0; public var mixShearY:Float = 0;
private var _temp:Vector<Float> = new Vector<Float>(2, true); private var _temp:Array<Float> = new Array<Float>();
public var active:Bool = false; public var active:Bool = false;
@ -59,7 +57,7 @@ class TransformConstraint implements Updatable {
mixScaleX = data.mixScaleX; mixScaleX = data.mixScaleX;
mixScaleY = data.mixScaleY; mixScaleY = data.mixScaleY;
mixShearY = data.mixShearY; mixShearY = data.mixShearY;
_bones = new Vector<Bone>(); _bones = new Array<Bone>();
for (boneData in data.bones) { for (boneData in data.bones) {
_bones.push(skeleton.findBone(boneData.name)); _bones.push(skeleton.findBone(boneData.name));
} }
@ -187,7 +185,7 @@ class TransformConstraint implements Updatable {
} }
if (translate) { if (translate) {
var temp:Vector<Float> = _temp; var temp:Array<Float> = _temp;
temp[0] = _data.offsetX; temp[0] = _data.offsetX;
temp[1] = _data.offsetY; temp[1] = _data.offsetY;
target.localToWorld(temp); target.localToWorld(temp);
@ -275,9 +273,9 @@ class TransformConstraint implements Updatable {
return _data; return _data;
} }
public var bones(get, never):Vector<Bone>; public var bones(get, never):Array<Bone>;
private function get_bones():Vector<Bone> { private function get_bones():Array<Bone> {
return _bones; return _bones;
} }

View File

@ -29,10 +29,8 @@
package spine; package spine;
import openfl.Vector;
class TransformConstraintData extends ConstraintData { class TransformConstraintData extends ConstraintData {
private var _bones:Vector<BoneData> = new Vector<BoneData>(); private var _bones:Array<BoneData> = new Array<BoneData>();
public var target:BoneData; public var target:BoneData;
public var mixRotate:Float = 0; public var mixRotate:Float = 0;
@ -54,9 +52,9 @@ class TransformConstraintData extends ConstraintData {
super(name, 0, false); super(name, 0, false);
} }
public var bones(get, never):Vector<BoneData>; public var bones(get, never):Array<BoneData>;
private function get_bones():Vector<BoneData> { private function get_bones():Array<BoneData> {
return _bones; return _bones;
} }
} }

View File

@ -29,8 +29,6 @@
package spine; package spine;
import openfl.Vector;
class TransformMode { class TransformMode {
public static var normal(default, never):TransformMode = new TransformMode("normal"); public static var normal(default, never):TransformMode = new TransformMode("normal");
public static var onlyTranslation(default, never):TransformMode = new TransformMode("onlyTranslation"); public static var onlyTranslation(default, never):TransformMode = new TransformMode("onlyTranslation");
@ -38,7 +36,7 @@ class TransformMode {
public static var noScale(default, never):TransformMode = new TransformMode("noScale"); public static var noScale(default, never):TransformMode = new TransformMode("noScale");
public static var noScaleOrReflection(default, never):TransformMode = new TransformMode("noScaleOrReflection"); public static var noScaleOrReflection(default, never):TransformMode = new TransformMode("noScaleOrReflection");
public static var values:Vector<TransformMode> = Vector.ofArray([normal, onlyTranslation, noRotationOrReflection, noScale, noScaleOrReflection]); public static var values:Array<TransformMode> = [normal, onlyTranslation, noRotationOrReflection, noScale, noScaleOrReflection];
public var name(default, null):String; public var name(default, null):String;

View File

@ -29,37 +29,35 @@
package spine; package spine;
import openfl.Vector;
class Triangulator { class Triangulator {
private var convexPolygons:Vector<Vector<Float>> = new Vector<Vector<Float>>(); private var convexPolygons:Array<Array<Float>> = new Array<Array<Float>>();
private var convexPolygonsIndices:Vector<Vector<Int>> = new Vector<Vector<Int>>(); private var convexPolygonsIndices:Array<Array<Int>> = new Array<Array<Int>>();
private var indicesArray:Vector<Int> = new Vector<Int>(); private var indicesArray:Array<Int> = new Array<Int>();
private var isConcaveArray:Vector<Bool> = new Vector<Bool>(); private var isConcaveArray:Array<Bool> = new Array<Bool>();
private var triangles:Vector<Int> = new Vector<Int>(); private var triangles:Array<Int> = new Array<Int>();
private var polygonPool:Pool<Vector<Float>> = new Pool(function():Dynamic { private var polygonPool:Pool<Array<Float>> = new Pool(function():Dynamic {
return new Vector<Float>(); return new Array<Float>();
}); });
private var polygonIndicesPool:Pool<Vector<Int>> = new Pool(function():Dynamic { private var polygonIndicesPool:Pool<Array<Int>> = new Pool(function():Dynamic {
return new Vector<Int>(); return new Array<Int>();
}); });
public function new() {} public function new() {}
public function triangulate(vertices:Vector<Float>):Vector<Int> { public function triangulate(vertices:Array<Float>):Array<Int> {
var vertexCount:Int = vertices.length >> 1; var vertexCount:Int = vertices.length >> 1;
indicesArray.length = 0; indicesArray.resize(0);
for (i in 0...vertexCount) { for (i in 0...vertexCount) {
indicesArray.push(i); indicesArray.push(i);
} }
isConcaveArray.length = 0; isConcaveArray.resize(0);
for (i in 0...vertexCount) { for (i in 0...vertexCount) {
isConcaveArray.push(isConcave(i, vertexCount, vertices, indicesArray)); isConcaveArray.push(isConcave(i, vertexCount, vertices, indicesArray));
} }
triangles.length = 0; triangles.resize(0);
while (vertexCount > 3) { while (vertexCount > 3) {
// Find ear tip. // Find ear tip.
@ -131,22 +129,22 @@ class Triangulator {
return triangles; return triangles;
} }
public function decompose(vertices:Vector<Float>, triangles:Vector<Int>):Vector<Vector<Float>> { public function decompose(vertices:Array<Float>, triangles:Array<Int>):Array<Array<Float>> {
for (i in 0...convexPolygons.length) { for (i in 0...convexPolygons.length) {
this.polygonPool.free(convexPolygons[i]); this.polygonPool.free(convexPolygons[i]);
} }
convexPolygons.length = 0; convexPolygons.resize(0);
for (i in 0...convexPolygonsIndices.length) { for (i in 0...convexPolygonsIndices.length) {
this.polygonIndicesPool.free(convexPolygonsIndices[i]); this.polygonIndicesPool.free(convexPolygonsIndices[i]);
} }
convexPolygonsIndices.length = 0; convexPolygonsIndices.resize(0);
var polygonIndices:Vector<Int> = polygonIndicesPool.obtain(); var polygonIndices:Array<Int> = polygonIndicesPool.obtain();
polygonIndices.length = 0; polygonIndices.resize(0);
var polygon:Vector<Float> = polygonPool.obtain(); var polygon:Array<Float> = polygonPool.obtain();
polygon.length = 0; polygon.resize(0);
// Merge subsequent triangles if they form a triangle fan. // Merge subsequent triangles if they form a triangle fan.
var fanBaseIndex:Int = -1, lastWinding:Int = 0; var fanBaseIndex:Int = -1, lastWinding:Int = 0;
@ -188,7 +186,7 @@ class Triangulator {
polygonIndicesPool.free(polygonIndices); polygonIndicesPool.free(polygonIndices);
} }
polygon = polygonPool.obtain(); polygon = polygonPool.obtain();
polygon.length = 0; polygon.resize(0);
polygon.push(x1); polygon.push(x1);
polygon.push(y1); polygon.push(y1);
polygon.push(x2); polygon.push(x2);
@ -196,7 +194,7 @@ class Triangulator {
polygon.push(x3); polygon.push(x3);
polygon.push(y3); polygon.push(y3);
polygonIndices = polygonIndicesPool.obtain(); polygonIndices = polygonIndicesPool.obtain();
polygonIndices.length = 0; polygonIndices.resize(0);
polygonIndices.push(t1); polygonIndices.push(t1);
polygonIndices.push(t2); polygonIndices.push(t2);
polygonIndices.push(t3); polygonIndices.push(t3);
@ -238,7 +236,7 @@ class Triangulator {
ii++; ii++;
continue; continue;
} }
var otherIndices:Vector<Int> = convexPolygonsIndices[ii]; var otherIndices:Array<Int> = convexPolygonsIndices[ii];
if (otherIndices.length != 3) { if (otherIndices.length != 3) {
ii++; ii++;
continue; continue;
@ -247,7 +245,7 @@ class Triangulator {
var otherSecondIndex:Int = otherIndices[1]; var otherSecondIndex:Int = otherIndices[1];
var otherLastIndex:Int = otherIndices[2]; var otherLastIndex:Int = otherIndices[2];
var otherPoly:Vector<Float> = convexPolygons[ii]; var otherPoly:Array<Float> = convexPolygons[ii];
x3 = otherPoly[otherPoly.length - 2]; x3 = otherPoly[otherPoly.length - 2];
y3 = otherPoly[otherPoly.length - 1]; y3 = otherPoly[otherPoly.length - 1];
@ -258,8 +256,8 @@ class Triangulator {
winding1 = Triangulator.winding(prevPrevX, prevPrevY, prevX, prevY, x3, y3); winding1 = Triangulator.winding(prevPrevX, prevPrevY, prevX, prevY, x3, y3);
winding2 = Triangulator.winding(x3, y3, firstX, firstY, secondX, secondY); winding2 = Triangulator.winding(x3, y3, firstX, firstY, secondX, secondY);
if (winding1 == currWinding && winding2 == currWinding) { if (winding1 == currWinding && winding2 == currWinding) {
otherPoly.length = 0; otherPoly.resize(0);
otherIndices.length = 0; otherIndices.resize(0);
polygon.push(x3); polygon.push(x3);
polygon.push(y3); polygon.push(y3);
polygonIndices.push(otherLastIndex); polygonIndices.push(otherLastIndex);
@ -294,7 +292,7 @@ class Triangulator {
return convexPolygons; return convexPolygons;
} }
private static function isConcave(index:Int, vertexCount:Int, vertices:Vector<Float>, indices:Vector<Int>):Bool { private static function isConcave(index:Int, vertexCount:Int, vertices:Array<Float>, indices:Array<Int>):Bool {
var previous:Int = indices[(vertexCount + index - 1) % vertexCount] << 1; var previous:Int = indices[(vertexCount + index - 1) % vertexCount] << 1;
var current:Int = indices[index] << 1; var current:Int = indices[index] << 1;
var next:Int = indices[(index + 1) % vertexCount] << 1; var next:Int = indices[(index + 1) % vertexCount] << 1;

View File

@ -29,7 +29,6 @@
package spine.animation; package spine.animation;
import openfl.Vector;
import spine.Event; import spine.Event;
import spine.Skeleton; import spine.Skeleton;
import spine.Slot; import spine.Slot;
@ -43,7 +42,7 @@ class AlphaTimeline extends CurveTimeline1 implements SlotTimeline {
private var slotIndex:Int = 0; private var slotIndex:Int = 0;
public function new(frameCount:Int, bezierCount:Int, slotIndex:Int) { public function new(frameCount:Int, bezierCount:Int, slotIndex:Int) {
super(frameCount, bezierCount, Vector.ofArray([Property.alpha + "|" + slotIndex])); super(frameCount, bezierCount, [Property.alpha + "|" + slotIndex]);
this.slotIndex = slotIndex; this.slotIndex = slotIndex;
} }
@ -55,7 +54,7 @@ class AlphaTimeline extends CurveTimeline1 implements SlotTimeline {
return slotIndex; return slotIndex;
} }
public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector<Event>, alpha:Float, blend:MixBlend, public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array<Event>, alpha:Float, blend:MixBlend,
direction:MixDirection):Void { direction:MixDirection):Void {
var slot:Slot = skeleton.slots[slotIndex]; var slot:Slot = skeleton.slots[slotIndex];
if (!slot.bone.active) if (!slot.bone.active)

View File

@ -29,19 +29,18 @@
package spine.animation; package spine.animation;
import openfl.utils.Dictionary; import haxe.ds.StringMap;
import openfl.Vector;
import spine.Event; import spine.Event;
import spine.Skeleton; import spine.Skeleton;
class Animation { class Animation {
private var _name:String; private var _name:String;
private var _timelines:Vector<Timeline>; private var _timelines:Array<Timeline>;
private var _timelineIds:Dictionary<String, Bool> = new Dictionary<String, Bool>(); private var _timelineIds:StringMap<Bool> = new StringMap<Bool>();
public var duration:Float = 0; public var duration:Float = 0;
public function new(name:String, timelines:Vector<Timeline>, duration:Float) { public function new(name:String, timelines:Array<Timeline>, duration:Float) {
if (name == null) if (name == null)
throw new SpineException("name cannot be null."); throw new SpineException("name cannot be null.");
_name = name; _name = name;
@ -49,29 +48,29 @@ class Animation {
this.duration = duration; this.duration = duration;
} }
public function setTimelines(timelines:Vector<Timeline>) { public function setTimelines(timelines:Array<Timeline>) {
if (timelines == null) if (timelines == null)
throw new SpineException("timelines cannot be null."); throw new SpineException("timelines cannot be null.");
_timelines = timelines; _timelines = timelines;
_timelineIds = new Dictionary<String, Bool>(); _timelineIds = new StringMap<Bool>();
for (timeline in timelines) { for (timeline in timelines) {
var ids:Vector<String> = timeline.propertyIds; var ids:Array<String> = timeline.propertyIds;
for (id in ids) { for (id in ids) {
_timelineIds[id] = true; _timelineIds.set(id, true);
} }
} }
} }
public function hasTimeline(ids:Vector<String>):Bool { public function hasTimeline(ids:Array<String>):Bool {
for (id in ids) { for (id in ids) {
if (_timelineIds[id]) if (_timelineIds.exists(id))
return true; return true;
} }
return false; return false;
} }
/** Poses the skeleton at the specified time for this animation. */ /** Poses the skeleton at the specified time for this animation. */
public function apply(skeleton:Skeleton, lastTime:Float, time:Float, loop:Bool, events:Vector<Event>, alpha:Float, blend:MixBlend, public function apply(skeleton:Skeleton, lastTime:Float, time:Float, loop:Bool, events:Array<Event>, alpha:Float, blend:MixBlend,
direction:MixDirection):Void { direction:MixDirection):Void {
if (skeleton == null) if (skeleton == null)
throw new SpineException("skeleton cannot be null."); throw new SpineException("skeleton cannot be null.");
@ -97,9 +96,9 @@ class Animation {
return _name; return _name;
} }
public var timelines(get, never):Vector<Timeline>; public var timelines(get, never):Array<Timeline>;
private function get_timelines():Vector<Timeline> { private function get_timelines():Array<Timeline> {
return _timelines; return _timelines;
} }
} }

View File

@ -29,8 +29,7 @@
package spine.animation; package spine.animation;
import openfl.utils.Dictionary; import haxe.ds.StringMap;
import openfl.Vector;
import spine.animation.Listeners.EventListeners; import spine.animation.Listeners.EventListeners;
import spine.Event; import spine.Event;
import spine.Pool; import spine.Pool;
@ -45,12 +44,12 @@ class AnimationState {
public static inline var SETUP:Int = 1; public static inline var SETUP:Int = 1;
public static inline var CURRENT:Int = 2; public static inline var CURRENT:Int = 2;
private static var emptyAnimation:Animation = new Animation("<empty>", new Vector<Timeline>(), 0); private static var emptyAnimation:Animation = new Animation("<empty>", new Array<Timeline>(), 0);
public var data:AnimationStateData; public var data:AnimationStateData;
public var tracks:Vector<TrackEntry> = new Vector<TrackEntry>(); public var tracks:Array<TrackEntry> = new Array<TrackEntry>();
private var events:Vector<Event> = new Vector<Event>(); private var events:Array<Event> = new Array<Event>();
public var onStart:Listeners = new Listeners(); public var onStart:Listeners = new Listeners();
public var onInterrupt:Listeners = new Listeners(); public var onInterrupt:Listeners = new Listeners();
@ -193,12 +192,12 @@ class AnimationState {
var animationLast:Float = current.animationLast, var animationLast:Float = current.animationLast,
animationTime:Float = current.getAnimationTime(), animationTime:Float = current.getAnimationTime(),
applyTime:Float = animationTime; applyTime:Float = animationTime;
var applyEvents:Vector<Event> = events; var applyEvents:Array<Event> = events;
if (current.reverse) { if (current.reverse) {
applyTime = current.animation.duration - applyTime; applyTime = current.animation.duration - applyTime;
applyEvents = null; applyEvents = null;
} }
var timelines:Vector<Timeline> = current.animation.timelines; var timelines:Array<Timeline> = current.animation.timelines;
var timelineCount:Int = timelines.length; var timelineCount:Int = timelines.length;
var timeline:Timeline; var timeline:Timeline;
if ((i == 0 && mix == 1) || blend == MixBlend.add) { if ((i == 0 && mix == 1) || blend == MixBlend.add) {
@ -206,12 +205,12 @@ class AnimationState {
timeline.apply(skeleton, animationLast, applyTime, applyEvents, mix, blend, MixDirection.mixIn); timeline.apply(skeleton, animationLast, applyTime, applyEvents, mix, blend, MixDirection.mixIn);
} }
} else { } else {
var timelineMode:Vector<Int> = current.timelineMode; var timelineMode:Array<Int> = current.timelineMode;
var shortestRotation = current.shortestRotation; var shortestRotation = current.shortestRotation;
var firstFrame:Bool = !shortestRotation && current.timelinesRotation.length != timelineCount << 1; var firstFrame:Bool = !shortestRotation && current.timelinesRotation.length != timelineCount << 1;
if (firstFrame) if (firstFrame)
current.timelinesRotation.length = timelineCount << 1; current.timelinesRotation.resize(timelineCount << 1);
for (ii in 0...timelineCount) { for (ii in 0...timelineCount) {
var timeline:Timeline = timelines[ii]; var timeline:Timeline = timelines[ii];
@ -227,7 +226,7 @@ class AnimationState {
} }
} }
queueEvents(current, animationTime); queueEvents(current, animationTime);
events.length = 0; events.resize(0);
current.nextAnimationLast = animationTime; current.nextAnimationLast = animationTime;
current.nextTrackLast = current.trackTime; current.nextTrackLast = current.trackTime;
} }
@ -270,13 +269,13 @@ class AnimationState {
var attachments:Bool = mix < from.attachmentThreshold, var attachments:Bool = mix < from.attachmentThreshold,
drawOrder:Bool = mix < from.drawOrderThreshold; drawOrder:Bool = mix < from.drawOrderThreshold;
var timelineCount:Int = from.animation.timelines.length; var timelineCount:Int = from.animation.timelines.length;
var timelines:Vector<Timeline> = from.animation.timelines; var timelines:Array<Timeline> = from.animation.timelines;
var alphaHold:Float = from.alpha * to.interruptAlpha, var alphaHold:Float = from.alpha * to.interruptAlpha,
alphaMix:Float = alphaHold * (1 - mix); alphaMix:Float = alphaHold * (1 - mix);
var animationLast:Float = from.animationLast, var animationLast:Float = from.animationLast,
animationTime:Float = from.getAnimationTime(), animationTime:Float = from.getAnimationTime(),
applyTime:Float = animationTime; applyTime:Float = animationTime;
var applyEvents:Vector<Event> = null; var applyEvents:Array<Event> = null;
if (from.reverse) { if (from.reverse) {
applyTime = from.animation.duration - applyTime; applyTime = from.animation.duration - applyTime;
} else if (mix < from.eventThreshold) { } else if (mix < from.eventThreshold) {
@ -288,14 +287,14 @@ class AnimationState {
timeline.apply(skeleton, animationLast, applyTime, applyEvents, alphaMix, blend, MixDirection.mixOut); timeline.apply(skeleton, animationLast, applyTime, applyEvents, alphaMix, blend, MixDirection.mixOut);
} }
} else { } else {
var timelineMode:Vector<Int> = from.timelineMode; var timelineMode:Array<Int> = from.timelineMode;
var timelineHoldMix:Vector<TrackEntry> = from.timelineHoldMix; var timelineHoldMix:Array<TrackEntry> = from.timelineHoldMix;
var shortestRotation = from.shortestRotation; var shortestRotation = from.shortestRotation;
var firstFrame:Bool = !shortestRotation && from.timelinesRotation.length != timelineCount << 1; var firstFrame:Bool = !shortestRotation && from.timelinesRotation.length != timelineCount << 1;
if (firstFrame) if (firstFrame)
from.timelinesRotation.length = timelineCount << 1; from.timelinesRotation.resize(timelineCount << 1);
var timelinesRotation:Vector<Float> = from.timelinesRotation; var timelinesRotation:Array<Float> = from.timelinesRotation;
from.totalAlpha = 0; from.totalAlpha = 0;
for (i in 0...timelineCount) { for (i in 0...timelineCount) {
@ -340,7 +339,7 @@ class AnimationState {
if (to.mixDuration > 0) if (to.mixDuration > 0)
queueEvents(from, animationTime); queueEvents(from, animationTime);
events.length = 0; events.resize(0);
from.nextAnimationLast = animationTime; from.nextAnimationLast = animationTime;
from.nextTrackLast = from.trackTime; from.nextTrackLast = from.trackTime;
@ -363,7 +362,7 @@ class AnimationState {
slot.attachmentState = this.unkeyedState + SETUP; slot.attachmentState = this.unkeyedState + SETUP;
} }
public function applyRotateTimeline(timeline:RotateTimeline, skeleton:Skeleton, time:Float, alpha:Float, blend:MixBlend, timelinesRotation:Vector<Float>, public function applyRotateTimeline(timeline:RotateTimeline, skeleton:Skeleton, time:Float, alpha:Float, blend:MixBlend, timelinesRotation:Array<Float>,
i:Int, firstFrame:Bool) { i:Int, firstFrame:Bool) {
if (firstFrame) if (firstFrame)
timelinesRotation[i] = 0; timelinesRotation[i] = 0;
@ -478,7 +477,7 @@ class AnimationState {
for (i in 0...tracks.length) { for (i in 0...tracks.length) {
clearTrack(i); clearTrack(i);
} }
tracks.length = 0; tracks.resize(0);
queue.drainDisabled = oldTrainDisabled; queue.drainDisabled = oldTrainDisabled;
queue.drain(); queue.drain();
} }
@ -525,7 +524,7 @@ class AnimationState {
current.interruptAlpha *= Math.min(1, from.mixTime / from.mixDuration); current.interruptAlpha *= Math.min(1, from.mixTime / from.mixDuration);
} }
from.timelinesRotation.length = 0; // Reset rotation for mixing out, in case entry was mixed in. from.timelinesRotation.resize(0); // Reset rotation for mixing out, in case entry was mixed in.
} }
queue.start(current); queue.start(current);
@ -627,7 +626,7 @@ class AnimationState {
private function expandToIndex(index:Int):TrackEntry { private function expandToIndex(index:Int):TrackEntry {
if (index < tracks.length) if (index < tracks.length)
return tracks[index]; return tracks[index];
tracks.length = index + 1; tracks.resize(index + 1);
return null; return null;
} }
@ -698,13 +697,13 @@ class AnimationState {
private function computeHold(entry:TrackEntry):Void { private function computeHold(entry:TrackEntry):Void {
var to:TrackEntry = entry.mixingTo; var to:TrackEntry = entry.mixingTo;
var timelines:Vector<Timeline> = entry.animation.timelines; var timelines:Array<Timeline> = entry.animation.timelines;
var timelinesCount:Int = entry.animation.timelines.length; var timelinesCount:Int = entry.animation.timelines.length;
var timelineMode:Vector<Int> = entry.timelineMode; var timelineMode:Array<Int> = entry.timelineMode;
timelineMode.length = timelinesCount; timelineMode.resize(timelinesCount);
entry.timelineHoldMix.length = 0; entry.timelineHoldMix.resize(0);
var timelineHoldMix:Vector<TrackEntry> = entry.timelineHoldMix; var timelineHoldMix:Array<TrackEntry> = entry.timelineHoldMix;
timelineHoldMix.length = timelinesCount; timelineHoldMix.resize(timelinesCount);
if (to != null && to.holdPrevious) { if (to != null && to.holdPrevious) {
for (i in 0...timelinesCount) { for (i in 0...timelinesCount) {
@ -717,7 +716,7 @@ class AnimationState {
for (i in 0...timelinesCount) { for (i in 0...timelinesCount) {
continueOuter = false; continueOuter = false;
var timeline:Timeline = timelines[i]; var timeline:Timeline = timelines[i];
var ids:Vector<String> = timeline.propertyIds; var ids:Array<String> = timeline.propertyIds;
if (!propertyIDs.addAll(ids)) { if (!propertyIDs.addAll(ids)) {
timelineMode[i] = SUBSEQUENT; timelineMode[i] = SUBSEQUENT;
} else if (to == null } else if (to == null
@ -761,12 +760,12 @@ class AnimationState {
} }
public function clearListeners():Void { public function clearListeners():Void {
onStart.listeners.length = 0; onStart.listeners.resize(0);
onInterrupt.listeners.length = 0; onInterrupt.listeners.resize(0);
onEnd.listeners.length = 0; onEnd.listeners.resize(0);
onDispose.listeners.length = 0; onDispose.listeners.resize(0);
onComplete.listeners.length = 0; onComplete.listeners.resize(0);
onEvent.listeners.length = 0; onEvent.listeners.resize(0);
} }
public function clearListenerNotifications():Void { public function clearListenerNotifications():Void {
@ -775,14 +774,14 @@ class AnimationState {
} }
class StringSet { class StringSet {
private var entries:Dictionary<String, Bool> = new Dictionary<String, Bool>(); private var entries:StringMap<Bool> = new StringMap<Bool>();
private var size:Int = 0; private var size:Int = 0;
public function new() {} public function new() {}
public function add(value:String):Bool { public function add(value:String):Bool {
var contains:Bool = entries[value]; var contains:Bool = entries.exists(value);
entries[value] = true; entries.set(value, true);
if (!contains) { if (!contains) {
size++; size++;
return true; return true;
@ -790,7 +789,7 @@ class StringSet {
return false; return false;
} }
public function addAll(values:Vector<String>):Bool { public function addAll(values:Array<String>):Bool {
var oldSize:Int = size; var oldSize:Int = size;
for (i in 0...values.length) { for (i in 0...values.length) {
add(values[i]); add(values[i]);
@ -799,11 +798,11 @@ class StringSet {
} }
public function contains(value:String):Bool { public function contains(value:String):Bool {
return entries[value]; return entries.exists(value);
} }
public function clear():Void { public function clear():Void {
entries = new Dictionary<String, Bool>(); entries = new StringMap<Bool>();
size = 0; size = 0;
} }
} }

View File

@ -29,12 +29,12 @@
package spine.animation; package spine.animation;
import openfl.utils.Object; import haxe.ds.StringMap;
import spine.SkeletonData; import spine.SkeletonData;
class AnimationStateData { class AnimationStateData {
private var _skeletonData:SkeletonData; private var _skeletonData:SkeletonData;
private var animationToMixTime:Object = new Object(); private var animationToMixTime:StringMap<Float> = new StringMap<Float>();
public var defaultMix:Float = 0; public var defaultMix:Float = 0;
@ -63,13 +63,13 @@ class AnimationStateData {
throw new SpineException("from cannot be null."); throw new SpineException("from cannot be null.");
if (to == null) if (to == null)
throw new SpineException("to cannot be null."); throw new SpineException("to cannot be null.");
animationToMixTime[from.name + ":" + to.name] = duration; animationToMixTime.set(from.name + ":" + to.name, duration);
} }
public function getMix(from:Animation, to:Animation):Float { public function getMix(from:Animation, to:Animation):Float {
var time:Object = animationToMixTime[from.name + ":" + to.name]; if (animationToMixTime.exists(from.name + ":" + to.name))
if (time == null) return animationToMixTime.get(from.name + ":" + to.name);
else
return defaultMix; return defaultMix;
return cast(time, Float);
} }
} }

View File

@ -29,7 +29,6 @@
package spine.animation; package spine.animation;
import openfl.Vector;
import spine.Event; import spine.Event;
import spine.Skeleton; import spine.Skeleton;
import spine.Slot; import spine.Slot;
@ -38,12 +37,13 @@ class AttachmentTimeline extends Timeline implements SlotTimeline {
public var slotIndex:Int = 0; public var slotIndex:Int = 0;
/** The attachment name for each key frame. May contain null values to clear the attachment. */ /** The attachment name for each key frame. May contain null values to clear the attachment. */
public var attachmentNames:Vector<String>; public var attachmentNames:Array<String>;
public function new(frameCount:Int, slotIndex:Int) { public function new(frameCount:Int, slotIndex:Int) {
super(frameCount, Vector.ofArray([Property.attachment + "|" + slotIndex])); super(frameCount, [Property.attachment + "|" + slotIndex]);
this.slotIndex = slotIndex; this.slotIndex = slotIndex;
attachmentNames = new Vector<String>(frameCount, true); attachmentNames = new Array<String>();
attachmentNames.resize(frameCount);
} }
public override function getFrameCount():Int { public override function getFrameCount():Int {
@ -60,7 +60,7 @@ class AttachmentTimeline extends Timeline implements SlotTimeline {
attachmentNames[frame] = attachmentName; attachmentNames[frame] = attachmentName;
} }
public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector<Event>, alpha:Float, blend:MixBlend, public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array<Event>, alpha:Float, blend:MixBlend,
direction:MixDirection):Void { direction:MixDirection):Void {
var slot:Slot = skeleton.slots[slotIndex]; var slot:Slot = skeleton.slots[slotIndex];
if (!slot.bone.active) if (!slot.bone.active)

View File

@ -29,8 +29,6 @@
package spine.animation; package spine.animation;
import openfl.Vector;
/** Base class for frames that use an interpolation bezier curve. */ /** Base class for frames that use an interpolation bezier curve. */
class CurveTimeline extends Timeline { class CurveTimeline extends Timeline {
private static inline var LINEAR:Int = 0; private static inline var LINEAR:Int = 0;
@ -38,11 +36,12 @@ class CurveTimeline extends Timeline {
private static inline var BEZIER:Int = 2; private static inline var BEZIER:Int = 2;
private static inline var BEZIER_SIZE:Int = 18; private static inline var BEZIER_SIZE:Int = 18;
private var curves:Vector<Float>; // type, x, y, ... private var curves:Array<Float>; // type, x, y, ...
public function new(frameCount:Int, bezierCount:Int, propertyIds:Vector<String>) { public function new(frameCount:Int, bezierCount:Int, propertyIds:Array<String>) {
super(frameCount, propertyIds); super(frameCount, propertyIds);
curves = new Vector<Float>(frameCount + bezierCount * BEZIER_SIZE, true); curves = new Array<Float>();
curves.resize(frameCount + bezierCount * BEZIER_SIZE);
curves[frameCount - 1] = STEPPED; curves[frameCount - 1] = STEPPED;
} }
@ -58,7 +57,7 @@ class CurveTimeline extends Timeline {
* than the actual number of Bezier curves. */ * than the actual number of Bezier curves. */
public function shrink(bezierCount:Int):Void { public function shrink(bezierCount:Int):Void {
var size:Int = getFrameCount() + bezierCount * BEZIER_SIZE; var size:Int = getFrameCount() + bezierCount * BEZIER_SIZE;
curves.length = size; curves.resize(size);
} }
/** Stores the segments for the specified Bezier curve. For timelines that modify multiple values, there may be more than /** Stores the segments for the specified Bezier curve. For timelines that modify multiple values, there may be more than

View File

@ -30,15 +30,13 @@
package spine.animation; package spine.animation;
/** The base class for a {@link CurveTimeline} that sets one property. */ /** The base class for a {@link CurveTimeline} that sets one property. */
import openfl.Vector;
class CurveTimeline1 extends CurveTimeline { class CurveTimeline1 extends CurveTimeline {
private static inline var ENTRIES:Int = 2; private static inline var ENTRIES:Int = 2;
private static inline var VALUE:Int = 1; private static inline var VALUE:Int = 1;
/** @param bezierCount The maximum number of Bezier curves. See {@link #shrink(Int)}. /** @param bezierCount The maximum number of Bezier curves. See {@link #shrink(Int)}.
* @param propertyIds Unique identifiers for the properties the timeline modifies. */ * @param propertyIds Unique identifiers for the properties the timeline modifies. */
public function new(frameCount:Int, bezierCount:Int, propertyIds:Vector<String>) { public function new(frameCount:Int, bezierCount:Int, propertyIds:Array<String>) {
super(frameCount, bezierCount, propertyIds); super(frameCount, bezierCount, propertyIds);
} }

View File

@ -30,8 +30,6 @@
package spine.animation; package spine.animation;
/** The base class for a {@link CurveTimeline} which sets two properties. */ /** The base class for a {@link CurveTimeline} which sets two properties. */
import openfl.Vector;
class CurveTimeline2 extends CurveTimeline { class CurveTimeline2 extends CurveTimeline {
private static inline var ENTRIES:Int = 3; private static inline var ENTRIES:Int = 3;
private static inline var VALUE1:Int = 1; private static inline var VALUE1:Int = 1;
@ -39,7 +37,7 @@ class CurveTimeline2 extends CurveTimeline {
/** @param bezierCount The maximum number of Bezier curves. See {@link #shrink(Int)}. /** @param bezierCount The maximum number of Bezier curves. See {@link #shrink(Int)}.
* @param propertyIds Unique identifiers for the properties the timeline modifies. */ * @param propertyIds Unique identifiers for the properties the timeline modifies. */
public function new(frameCount:Int, bezierCount:Int, propertyIds:Vector<String>) { public function new(frameCount:Int, bezierCount:Int, propertyIds:Array<String>) {
super(frameCount, bezierCount, propertyIds); super(frameCount, bezierCount, propertyIds);
} }

View File

@ -29,7 +29,6 @@
package spine.animation; package spine.animation;
import openfl.Vector;
import spine.animation.Timeline; import spine.animation.Timeline;
import spine.attachments.Attachment; import spine.attachments.Attachment;
import spine.attachments.VertexAttachment; import spine.attachments.VertexAttachment;
@ -44,13 +43,14 @@ class DeformTimeline extends CurveTimeline implements SlotTimeline {
public var attachment:VertexAttachment; public var attachment:VertexAttachment;
/** The vertices for each key frame. */ /** The vertices for each key frame. */
public var vertices:Vector<Vector<Float>>; public var vertices:Array<Array<Float>>;
public function new(frameCount:Int, bezierCount:Int, slotIndex:Int, attachment:VertexAttachment) { public function new(frameCount:Int, bezierCount:Int, slotIndex:Int, attachment:VertexAttachment) {
super(frameCount, bezierCount, Vector.ofArray([Property.deform + "|" + slotIndex + "|" + attachment.id])); super(frameCount, bezierCount, [Property.deform + "|" + slotIndex + "|" + attachment.id]);
this.slotIndex = slotIndex; this.slotIndex = slotIndex;
this.attachment = attachment; this.attachment = attachment;
vertices = new Vector<Vector<Float>>(frameCount, true); vertices = new Array<Array<Float>>();
vertices.resize(frameCount);
} }
public override function getFrameCount():Int { public override function getFrameCount():Int {
@ -63,7 +63,7 @@ class DeformTimeline extends CurveTimeline implements SlotTimeline {
/** Sets the time in seconds and the vertices for the specified key frame. /** Sets the time in seconds and the vertices for the specified key frame.
* @param vertices Vertex positions for an unweighted VertexAttachment, or deform offsets if it has weights. */ * @param vertices Vertex positions for an unweighted VertexAttachment, or deform offsets if it has weights. */
public function setFrame(frame:Int, time:Float, verticesOrDeform:Vector<Float>):Void { public function setFrame(frame:Int, time:Float, verticesOrDeform:Array<Float>):Void {
frames[frame] = time; frames[frame] = time;
vertices[frame] = verticesOrDeform; vertices[frame] = verticesOrDeform;
} }
@ -129,7 +129,7 @@ class DeformTimeline extends CurveTimeline implements SlotTimeline {
return y + (1 - y) * (time - x) / (frames[frame + getFrameEntries()] - x); return y + (1 - y) * (time - x) / (frames[frame + getFrameEntries()] - x);
} }
public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector<Event>, alpha:Float, blend:MixBlend, public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array<Event>, alpha:Float, blend:MixBlend,
direction:MixDirection):Void { direction:MixDirection):Void {
var slot:Slot = skeleton.slots[slotIndex]; var slot:Slot = skeleton.slots[slotIndex];
if (!slot.bone.active) if (!slot.bone.active)
@ -140,23 +140,23 @@ class DeformTimeline extends CurveTimeline implements SlotTimeline {
if (!Std.isOfType(slotAttachment, VertexAttachment) || cast(slotAttachment, VertexAttachment).timelineAttachment != attachment) if (!Std.isOfType(slotAttachment, VertexAttachment) || cast(slotAttachment, VertexAttachment).timelineAttachment != attachment)
return; return;
var deform:Vector<Float> = slot.deform; var deform:Array<Float> = slot.deform;
if (deform.length == 0) if (deform.length == 0)
blend = MixBlend.setup; blend = MixBlend.setup;
var vertexCount:Int = vertices[0].length; var vertexCount:Int = vertices[0].length;
var i:Int, setupVertices:Vector<Float>; var i:Int, setupVertices:Array<Float>;
if (time < frames[0]) { if (time < frames[0]) {
switch (blend) { switch (blend) {
case MixBlend.setup: case MixBlend.setup:
deform.length = 0; deform.resize(0);
case MixBlend.first: case MixBlend.first:
if (alpha == 1) { if (alpha == 1) {
deform.length = 0; deform.resize(0);
return; return;
} }
deform.length = vertexCount; deform.resize(vertexCount);
var vertexAttachment:VertexAttachment = cast(slotAttachment, VertexAttachment); var vertexAttachment:VertexAttachment = cast(slotAttachment, VertexAttachment);
if (vertexAttachment.bones == null) { if (vertexAttachment.bones == null) {
// Unweighted vertex positions. // Unweighted vertex positions.
@ -175,11 +175,11 @@ class DeformTimeline extends CurveTimeline implements SlotTimeline {
return; return;
} }
deform.length = vertexCount; deform.resize(vertexCount);
var setup:Float; var setup:Float;
if (time >= frames[frames.length - 1]) // Time is after last frame. if (time >= frames[frames.length - 1]) // Time is after last frame.
{ {
var lastVertices:Vector<Float> = vertices[frames.length - 1]; var lastVertices:Array<Float> = vertices[frames.length - 1];
if (alpha == 1) { if (alpha == 1) {
if (blend == MixBlend.add) { if (blend == MixBlend.add) {
var vertexAttachment:VertexAttachment = cast(slotAttachment, VertexAttachment); var vertexAttachment:VertexAttachment = cast(slotAttachment, VertexAttachment);
@ -243,8 +243,8 @@ class DeformTimeline extends CurveTimeline implements SlotTimeline {
// Interpolate between the previous frame and the current frame. // Interpolate between the previous frame and the current frame.
var frame:Int = Timeline.search1(frames, time); var frame:Int = Timeline.search1(frames, time);
var percent:Float = getCurvePercent(time, frame); var percent:Float = getCurvePercent(time, frame);
var prevVertices:Vector<Float> = vertices[frame], prev:Float; var prevVertices:Array<Float> = vertices[frame], prev:Float;
var nextVertices:Vector<Float> = vertices[frame + 1]; var nextVertices:Array<Float> = vertices[frame + 1];
if (alpha == 1) { if (alpha == 1) {
if (blend == MixBlend.add) { if (blend == MixBlend.add) {

View File

@ -29,17 +29,17 @@
package spine.animation; package spine.animation;
import openfl.Vector;
import spine.Event; import spine.Event;
import spine.Skeleton; import spine.Skeleton;
import spine.Slot; import spine.Slot;
class DrawOrderTimeline extends Timeline { class DrawOrderTimeline extends Timeline {
public var drawOrders:Vector<Vector<Int>>; public var drawOrders:Array<Array<Int>>;
public function new(frameCount:Int) { public function new(frameCount:Int) {
super(frameCount, Vector.ofArray([Std.string(Property.drawOrder)])); super(frameCount, [Std.string(Property.drawOrder)]);
drawOrders = new Vector<Vector<Int>>(frameCount, true); drawOrders = new Array<Array<Int>>();
drawOrders.resize(frameCount);
} }
public var frameCount(get, never):Int; public var frameCount(get, never):Int;
@ -49,15 +49,15 @@ class DrawOrderTimeline extends Timeline {
} }
/** Sets the time and value of the specified keyframe. */ /** Sets the time and value of the specified keyframe. */
public function setFrame(frame:Int, time:Float, drawOrder:Vector<Int>):Void { public function setFrame(frame:Int, time:Float, drawOrder:Array<Int>):Void {
frames[frame] = time; frames[frame] = time;
drawOrders[frame] = drawOrder; drawOrders[frame] = drawOrder;
} }
override public function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector<Event>, alpha:Float, blend:MixBlend, override public function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array<Event>, alpha:Float, blend:MixBlend,
direction:MixDirection):Void { direction:MixDirection):Void {
var drawOrder:Vector<Slot> = skeleton.drawOrder; var drawOrder:Array<Slot> = skeleton.drawOrder;
var slots:Vector<Slot> = skeleton.slots; var slots:Array<Slot> = skeleton.slots;
var i:Int = 0, n:Int = slots.length; var i:Int = 0, n:Int = slots.length;
if (direction == MixDirection.mixOut) { if (direction == MixDirection.mixOut) {
@ -78,7 +78,7 @@ class DrawOrderTimeline extends Timeline {
return; return;
} }
var drawOrderToSetupIndex:Vector<Int> = drawOrders[Timeline.search1(frames, time)]; var drawOrderToSetupIndex:Array<Int> = drawOrders[Timeline.search1(frames, time)];
if (drawOrderToSetupIndex == null) { if (drawOrderToSetupIndex == null) {
for (i in 0...n) { for (i in 0...n) {
drawOrder[i] = slots[i]; drawOrder[i] = slots[i];

View File

@ -29,17 +29,17 @@
package spine.animation; package spine.animation;
import openfl.Vector;
import spine.animation.Timeline; import spine.animation.Timeline;
import spine.Event; import spine.Event;
import spine.Skeleton; import spine.Skeleton;
class EventTimeline extends Timeline { class EventTimeline extends Timeline {
public var events:Vector<Event>; public var events:Array<Event>;
public function new(frameCount:Int) { public function new(frameCount:Int) {
super(frameCount, Vector.ofArray([Std.string(Property.event)])); super(frameCount, [Std.string(Property.event)]);
events = new Vector<Event>(frameCount, true); events = new Array<Event>();
events.resize(frameCount);
} }
public override function getFrameCount():Int { public override function getFrameCount():Int {
@ -53,7 +53,7 @@ class EventTimeline extends Timeline {
} }
/** Fires events for frames > `lastTime` and <= `time`. */ /** Fires events for frames > `lastTime` and <= `time`. */
public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector<Event>, alpha:Float, blend:MixBlend, public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array<Event>, alpha:Float, blend:MixBlend,
direction:MixDirection):Void { direction:MixDirection):Void {
if (events == null) if (events == null)
return; return;

View File

@ -29,7 +29,6 @@
package spine.animation; package spine.animation;
import openfl.Vector;
import spine.Event; import spine.Event;
import spine.IkConstraint; import spine.IkConstraint;
import spine.Skeleton; import spine.Skeleton;
@ -46,7 +45,7 @@ class IkConstraintTimeline extends CurveTimeline {
public var ikConstraintIndex:Int = 0; public var ikConstraintIndex:Int = 0;
public function new(frameCount:Int, bezierCount:Int, ikConstraintIndex:Int) { public function new(frameCount:Int, bezierCount:Int, ikConstraintIndex:Int) {
super(frameCount, bezierCount, Vector.ofArray([Property.ikConstraint + "|" + ikConstraintIndex])); super(frameCount, bezierCount, [Property.ikConstraint + "|" + ikConstraintIndex]);
this.ikConstraintIndex = ikConstraintIndex; this.ikConstraintIndex = ikConstraintIndex;
} }
@ -65,7 +64,7 @@ class IkConstraintTimeline extends CurveTimeline {
frames[frame + STRETCH] = stretch ? 1 : 0; frames[frame + STRETCH] = stretch ? 1 : 0;
} }
public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector<Event>, alpha:Float, blend:MixBlend, public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array<Event>, alpha:Float, blend:MixBlend,
direction:MixDirection):Void { direction:MixDirection):Void {
var constraint:IkConstraint = skeleton.ikConstraints[ikConstraintIndex]; var constraint:IkConstraint = skeleton.ikConstraints[ikConstraintIndex];
if (!constraint.active) if (!constraint.active)

View File

@ -29,19 +29,17 @@
package spine.animation; package spine.animation;
import openfl.Vector;
class Listeners { class Listeners {
private var _listeners:Vector<TrackEntry->Void>; private var _listeners:Array<TrackEntry->Void>;
public var listeners(get, never):Vector<TrackEntry->Void>; public var listeners(get, never):Array<TrackEntry->Void>;
private function get_listeners():Vector<TrackEntry->Void> { private function get_listeners():Array<TrackEntry->Void> {
return _listeners; return _listeners;
} }
public function new() { public function new() {
_listeners = new Vector<TrackEntry->Void>(); _listeners = new Array<TrackEntry->Void>();
} }
public function invoke(entry:TrackEntry) { public function invoke(entry:TrackEntry) {
@ -68,16 +66,16 @@ class Listeners {
} }
class EventListeners { class EventListeners {
private var _listeners:Vector<TrackEntry->Event->Void>; private var _listeners:Array<TrackEntry->Event->Void>;
public var listeners(get, never):Vector<TrackEntry->Event->Void>; public var listeners(get, never):Array<TrackEntry->Event->Void>;
private function get_listeners():Vector<TrackEntry->Event->Void> { private function get_listeners():Array<TrackEntry->Event->Void> {
return _listeners; return _listeners;
} }
public function new() { public function new() {
_listeners = new Vector<TrackEntry->Event->Void>(); _listeners = new Array<TrackEntry->Event->Void>();
} }
public function invoke(entry:TrackEntry, event:Event) { public function invoke(entry:TrackEntry, event:Event) {

View File

@ -29,7 +29,6 @@
package spine.animation; package spine.animation;
import openfl.Vector;
import spine.Event; import spine.Event;
import spine.PathConstraint; import spine.PathConstraint;
import spine.Skeleton; import spine.Skeleton;
@ -44,7 +43,7 @@ class PathConstraintMixTimeline extends CurveTimeline {
public var pathConstraintIndex:Int = 0; public var pathConstraintIndex:Int = 0;
public function new(frameCount:Int, bezierCount:Int, pathConstraintIndex:Int) { public function new(frameCount:Int, bezierCount:Int, pathConstraintIndex:Int) {
super(frameCount, bezierCount, Vector.ofArray([Property.pathConstraintMix + "|" + pathConstraintIndex])); super(frameCount, bezierCount, [Property.pathConstraintMix + "|" + pathConstraintIndex]);
this.pathConstraintIndex = pathConstraintIndex; this.pathConstraintIndex = pathConstraintIndex;
} }
@ -60,7 +59,7 @@ class PathConstraintMixTimeline extends CurveTimeline {
frames[frame + Y] = mixY; frames[frame + Y] = mixY;
} }
public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector<Event>, alpha:Float, blend:MixBlend, public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array<Event>, alpha:Float, blend:MixBlend,
direction:MixDirection):Void { direction:MixDirection):Void {
var constraint:PathConstraint = skeleton.pathConstraints[pathConstraintIndex]; var constraint:PathConstraint = skeleton.pathConstraints[pathConstraintIndex];
if (!constraint.active) if (!constraint.active)

View File

@ -29,7 +29,6 @@
package spine.animation; package spine.animation;
import openfl.Vector;
import spine.Event; import spine.Event;
import spine.PathConstraint; import spine.PathConstraint;
import spine.Skeleton; import spine.Skeleton;
@ -39,11 +38,11 @@ class PathConstraintPositionTimeline extends CurveTimeline1 {
public var pathConstraintIndex:Int = 0; public var pathConstraintIndex:Int = 0;
public function new(frameCount:Int, bezierCount:Int, pathConstraintIndex:Int) { public function new(frameCount:Int, bezierCount:Int, pathConstraintIndex:Int) {
super(frameCount, bezierCount, Vector.ofArray([Property.pathConstraintPosition + "|" + pathConstraintIndex])); super(frameCount, bezierCount, [Property.pathConstraintPosition + "|" + pathConstraintIndex]);
this.pathConstraintIndex = pathConstraintIndex; this.pathConstraintIndex = pathConstraintIndex;
} }
public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector<Event>, alpha:Float, blend:MixBlend, public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array<Event>, alpha:Float, blend:MixBlend,
direction:MixDirection):Void { direction:MixDirection):Void {
var constraint:PathConstraint = skeleton.pathConstraints[pathConstraintIndex]; var constraint:PathConstraint = skeleton.pathConstraints[pathConstraintIndex];
if (!constraint.active) if (!constraint.active)

View File

@ -29,7 +29,6 @@
package spine.animation; package spine.animation;
import openfl.Vector;
import spine.Event; import spine.Event;
import spine.PathConstraint; import spine.PathConstraint;
import spine.Skeleton; import spine.Skeleton;
@ -39,11 +38,11 @@ class PathConstraintSpacingTimeline extends CurveTimeline1 {
public var pathConstraintIndex:Int = 0; public var pathConstraintIndex:Int = 0;
public function new(frameCount:Int, bezierCount:Int, pathConstraintIndex:Int) { public function new(frameCount:Int, bezierCount:Int, pathConstraintIndex:Int) {
super(frameCount, bezierCount, Vector.ofArray([Property.pathConstraintSpacing + "|" + pathConstraintIndex])); super(frameCount, bezierCount, [Property.pathConstraintSpacing + "|" + pathConstraintIndex]);
this.pathConstraintIndex = pathConstraintIndex; this.pathConstraintIndex = pathConstraintIndex;
} }
public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector<Event>, alpha:Float, blend:MixBlend, public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array<Event>, alpha:Float, blend:MixBlend,
direction:MixDirection):Void { direction:MixDirection):Void {
var constraint:PathConstraint = skeleton.pathConstraints[pathConstraintIndex]; var constraint:PathConstraint = skeleton.pathConstraints[pathConstraintIndex];
if (!constraint.active) if (!constraint.active)

View File

@ -29,8 +29,6 @@
package spine.animation; package spine.animation;
import openfl.Vector;
class RGB2Timeline extends CurveTimeline implements SlotTimeline { class RGB2Timeline extends CurveTimeline implements SlotTimeline {
private static inline var ENTRIES:Int = 7; private static inline var ENTRIES:Int = 7;
private static inline var R:Int = 1; private static inline var R:Int = 1;
@ -43,7 +41,7 @@ class RGB2Timeline extends CurveTimeline implements SlotTimeline {
private var slotIndex:Int = 0; private var slotIndex:Int = 0;
public function new(frameCount:Int, bezierCount:Int, slotIndex:Int) { public function new(frameCount:Int, bezierCount:Int, slotIndex:Int) {
super(frameCount, bezierCount, Vector.ofArray([Property.rgb + "|" + slotIndex, Property.rgb2 + "|" + slotIndex])); super(frameCount, bezierCount, [Property.rgb + "|" + slotIndex, Property.rgb2 + "|" + slotIndex]);
this.slotIndex = slotIndex; this.slotIndex = slotIndex;
} }
@ -67,7 +65,7 @@ class RGB2Timeline extends CurveTimeline implements SlotTimeline {
frames[frame + B2] = b2; frames[frame + B2] = b2;
} }
public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector<Event>, alpha:Float, blend:MixBlend, public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array<Event>, alpha:Float, blend:MixBlend,
direction:MixDirection):Void { direction:MixDirection):Void {
var slot:Slot = skeleton.slots[slotIndex]; var slot:Slot = skeleton.slots[slotIndex];
if (!slot.bone.active) if (!slot.bone.active)

View File

@ -29,8 +29,6 @@
package spine.animation; package spine.animation;
import openfl.Vector;
class RGBA2Timeline extends CurveTimeline implements SlotTimeline { class RGBA2Timeline extends CurveTimeline implements SlotTimeline {
private static inline var ENTRIES:Int = 8; private static inline var ENTRIES:Int = 8;
private static inline var R:Int = 1; private static inline var R:Int = 1;
@ -44,11 +42,11 @@ class RGBA2Timeline extends CurveTimeline implements SlotTimeline {
private var slotIndex:Int = 0; private var slotIndex:Int = 0;
public function new(frameCount:Int, bezierCount:Int, slotIndex:Int) { public function new(frameCount:Int, bezierCount:Int, slotIndex:Int) {
super(frameCount, bezierCount, Vector.ofArray([ super(frameCount, bezierCount, [
Property.rgb + "|" + slotIndex, Property.rgb + "|" + slotIndex,
Property.alpha + "|" + slotIndex, Property.alpha + "|" + slotIndex,
Property.rgb2 + "|" + slotIndex Property.rgb2 + "|" + slotIndex
])); ]);
this.slotIndex = slotIndex; this.slotIndex = slotIndex;
} }
@ -73,7 +71,7 @@ class RGBA2Timeline extends CurveTimeline implements SlotTimeline {
frames[frame + B2] = b2; frames[frame + B2] = b2;
} }
public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector<Event>, alpha:Float, blend:MixBlend, public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array<Event>, alpha:Float, blend:MixBlend,
direction:MixDirection):Void { direction:MixDirection):Void {
var slot:Slot = skeleton.slots[slotIndex]; var slot:Slot = skeleton.slots[slotIndex];
if (!slot.bone.active) if (!slot.bone.active)

View File

@ -29,8 +29,6 @@
package spine.animation; package spine.animation;
import openfl.Vector;
class RGBATimeline extends CurveTimeline implements SlotTimeline { class RGBATimeline extends CurveTimeline implements SlotTimeline {
private static inline var ENTRIES:Int = 5; private static inline var ENTRIES:Int = 5;
private static inline var R:Int = 1; private static inline var R:Int = 1;
@ -41,7 +39,7 @@ class RGBATimeline extends CurveTimeline implements SlotTimeline {
private var slotIndex:Int = 0; private var slotIndex:Int = 0;
public function new(frameCount:Int, bezierCount:Int, slotIndex:Int) { public function new(frameCount:Int, bezierCount:Int, slotIndex:Int) {
super(frameCount, bezierCount, Vector.ofArray([Property.rgb + "|" + slotIndex, Property.alpha + "|" + slotIndex])); super(frameCount, bezierCount, [Property.rgb + "|" + slotIndex, Property.alpha + "|" + slotIndex]);
this.slotIndex = slotIndex; this.slotIndex = slotIndex;
} }
@ -63,7 +61,7 @@ class RGBATimeline extends CurveTimeline implements SlotTimeline {
frames[frame + A] = a; frames[frame + A] = a;
} }
public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector<Event>, alpha:Float, blend:MixBlend, public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array<Event>, alpha:Float, blend:MixBlend,
direction:MixDirection):Void { direction:MixDirection):Void {
var slot:Slot = skeleton.slots[slotIndex]; var slot:Slot = skeleton.slots[slotIndex];
if (!slot.bone.active) if (!slot.bone.active)

View File

@ -29,8 +29,6 @@
package spine.animation; package spine.animation;
import openfl.Vector;
class RGBTimeline extends CurveTimeline implements SlotTimeline { class RGBTimeline extends CurveTimeline implements SlotTimeline {
private static inline var ENTRIES:Int = 4; private static inline var ENTRIES:Int = 4;
private static inline var R:Int = 1; private static inline var R:Int = 1;
@ -40,7 +38,7 @@ class RGBTimeline extends CurveTimeline implements SlotTimeline {
private var slotIndex:Int = 0; private var slotIndex:Int = 0;
public function new(frameCount:Int, bezierCount:Int, slotIndex:Int) { public function new(frameCount:Int, bezierCount:Int, slotIndex:Int) {
super(frameCount, bezierCount, Vector.ofArray([Property.rgb + "|" + slotIndex])); super(frameCount, bezierCount, [Property.rgb + "|" + slotIndex]);
this.slotIndex = slotIndex; this.slotIndex = slotIndex;
} }
@ -61,7 +59,7 @@ class RGBTimeline extends CurveTimeline implements SlotTimeline {
frames[frame + B] = b; frames[frame + B] = b;
} }
public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector<Event>, alpha:Float, blend:MixBlend, public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array<Event>, alpha:Float, blend:MixBlend,
direction:MixDirection):Void { direction:MixDirection):Void {
var slot:Slot = skeleton.slots[slotIndex]; var slot:Slot = skeleton.slots[slotIndex];
if (!slot.bone.active) if (!slot.bone.active)

View File

@ -29,7 +29,6 @@
package spine.animation; package spine.animation;
import openfl.Vector;
import spine.Bone; import spine.Bone;
import spine.Event; import spine.Event;
import spine.Skeleton; import spine.Skeleton;
@ -38,7 +37,7 @@ class RotateTimeline extends CurveTimeline1 implements BoneTimeline {
public var boneIndex:Int = 0; public var boneIndex:Int = 0;
public function new(frameCount:Int, bezierCount:Int, boneIndex:Int) { public function new(frameCount:Int, bezierCount:Int, boneIndex:Int) {
super(frameCount, bezierCount, Vector.ofArray([Property.rotate + "|" + boneIndex])); super(frameCount, bezierCount, [Property.rotate + "|" + boneIndex]);
this.boneIndex = boneIndex; this.boneIndex = boneIndex;
} }
@ -46,7 +45,7 @@ class RotateTimeline extends CurveTimeline1 implements BoneTimeline {
return boneIndex; return boneIndex;
} }
override public function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector<Event>, alpha:Float, blend:MixBlend, override public function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array<Event>, alpha:Float, blend:MixBlend,
direction:MixDirection):Void { direction:MixDirection):Void {
var bone:Bone = skeleton.bones[boneIndex]; var bone:Bone = skeleton.bones[boneIndex];
if (!bone.active) if (!bone.active)

View File

@ -29,7 +29,6 @@
package spine.animation; package spine.animation;
import openfl.Vector;
import spine.Bone; import spine.Bone;
import spine.Event; import spine.Event;
import spine.MathUtils; import spine.MathUtils;
@ -39,7 +38,7 @@ class ScaleTimeline extends CurveTimeline2 implements BoneTimeline {
private var boneIndex:Int = 0; private var boneIndex:Int = 0;
public function new(frameCount:Int, bezierCount:Int, boneIndex:Int) { public function new(frameCount:Int, bezierCount:Int, boneIndex:Int) {
super(frameCount, bezierCount, Vector.ofArray([Property.scaleX + "|" + boneIndex, Property.scaleY + "|" + boneIndex])); super(frameCount, bezierCount, [Property.scaleX + "|" + boneIndex, Property.scaleY + "|" + boneIndex]);
this.boneIndex = boneIndex; this.boneIndex = boneIndex;
} }
@ -47,7 +46,7 @@ class ScaleTimeline extends CurveTimeline2 implements BoneTimeline {
return boneIndex; return boneIndex;
} }
override public function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector<Event>, alpha:Float, blend:MixBlend, override public function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array<Event>, alpha:Float, blend:MixBlend,
direction:MixDirection):Void { direction:MixDirection):Void {
var bone:Bone = skeleton.bones[boneIndex]; var bone:Bone = skeleton.bones[boneIndex];
if (!bone.active) if (!bone.active)

View File

@ -29,7 +29,6 @@
package spine.animation; package spine.animation;
import openfl.Vector;
import spine.Bone; import spine.Bone;
import spine.Event; import spine.Event;
import spine.MathUtils; import spine.MathUtils;
@ -39,7 +38,7 @@ class ScaleXTimeline extends CurveTimeline1 implements BoneTimeline {
private var boneIndex:Int = 0; private var boneIndex:Int = 0;
public function new(frameCount:Int, bezierCount:Int, boneIndex:Int) { public function new(frameCount:Int, bezierCount:Int, boneIndex:Int) {
super(frameCount, bezierCount, Vector.ofArray([Property.scaleX + "|" + boneIndex])); super(frameCount, bezierCount, [Property.scaleX + "|" + boneIndex]);
this.boneIndex = boneIndex; this.boneIndex = boneIndex;
} }
@ -47,7 +46,7 @@ class ScaleXTimeline extends CurveTimeline1 implements BoneTimeline {
return boneIndex; return boneIndex;
} }
override public function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector<Event>, alpha:Float, blend:MixBlend, override public function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array<Event>, alpha:Float, blend:MixBlend,
direction:MixDirection):Void { direction:MixDirection):Void {
var bone:Bone = skeleton.bones[boneIndex]; var bone:Bone = skeleton.bones[boneIndex];
if (!bone.active) if (!bone.active)

View File

@ -29,7 +29,6 @@
package spine.animation; package spine.animation;
import openfl.Vector;
import spine.Bone; import spine.Bone;
import spine.Event; import spine.Event;
import spine.MathUtils; import spine.MathUtils;
@ -39,7 +38,7 @@ class ScaleYTimeline extends CurveTimeline1 implements BoneTimeline {
private var boneIndex:Int = 0; private var boneIndex:Int = 0;
public function new(frameCount:Int, bezierCount:Int, boneIndex:Int) { public function new(frameCount:Int, bezierCount:Int, boneIndex:Int) {
super(frameCount, bezierCount, Vector.ofArray([Property.scaleY + "|" + boneIndex])); super(frameCount, bezierCount, [Property.scaleY + "|" + boneIndex]);
this.boneIndex = boneIndex; this.boneIndex = boneIndex;
} }
@ -47,7 +46,7 @@ class ScaleYTimeline extends CurveTimeline1 implements BoneTimeline {
return boneIndex; return boneIndex;
} }
override public function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector<Event>, alpha:Float, blend:MixBlend, override public function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array<Event>, alpha:Float, blend:MixBlend,
direction:MixDirection):Void { direction:MixDirection):Void {
var bone:Bone = skeleton.bones[boneIndex]; var bone:Bone = skeleton.bones[boneIndex];
if (!bone.active) if (!bone.active)

View File

@ -29,7 +29,6 @@
package spine.animation; package spine.animation;
import openfl.Vector;
import spine.attachments.VertexAttachment; import spine.attachments.VertexAttachment;
import spine.attachments.Attachment; import spine.attachments.Attachment;
@ -42,9 +41,9 @@ class SequenceTimeline extends Timeline implements SlotTimeline {
var attachment:HasTextureRegion; var attachment:HasTextureRegion;
public function new(frameCount:Int, slotIndex:Int, attachment:HasTextureRegion) { public function new(frameCount:Int, slotIndex:Int, attachment:HasTextureRegion) {
super(frameCount, Vector.ofArray([ super(frameCount, [
Std.string(Property.sequence) + "|" + Std.string(slotIndex) + "|" + Std.string(attachment.sequence.id) Std.string(Property.sequence) + "|" + Std.string(slotIndex) + "|" + Std.string(attachment.sequence.id)
])); ]);
this.slotIndex = slotIndex; this.slotIndex = slotIndex;
this.attachment = attachment; this.attachment = attachment;
} }
@ -71,7 +70,7 @@ class SequenceTimeline extends Timeline implements SlotTimeline {
frames[frame + SequenceTimeline.DELAY] = delay; frames[frame + SequenceTimeline.DELAY] = delay;
} }
public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector<Event>, alpha:Float, blend:MixBlend, public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array<Event>, alpha:Float, blend:MixBlend,
direction:MixDirection):Void { direction:MixDirection):Void {
var slot = skeleton.slots[this.slotIndex]; var slot = skeleton.slots[this.slotIndex];
if (!slot.bone.active) if (!slot.bone.active)

View File

@ -29,7 +29,6 @@
package spine.animation; package spine.animation;
import openfl.Vector;
import spine.Bone; import spine.Bone;
import spine.Event; import spine.Event;
import spine.Skeleton; import spine.Skeleton;
@ -38,7 +37,7 @@ class ShearTimeline extends CurveTimeline2 implements BoneTimeline {
private var boneIndex:Int = 0; private var boneIndex:Int = 0;
public function new(frameCount:Int, bezierCount:Int, boneIndex:Int) { public function new(frameCount:Int, bezierCount:Int, boneIndex:Int) {
super(frameCount, bezierCount, Vector.ofArray([Property.shearX + "|" + boneIndex, Property.shearY + "|" + boneIndex])); super(frameCount, bezierCount, [Property.shearX + "|" + boneIndex, Property.shearY + "|" + boneIndex]);
this.boneIndex = boneIndex; this.boneIndex = boneIndex;
} }
@ -46,7 +45,7 @@ class ShearTimeline extends CurveTimeline2 implements BoneTimeline {
return boneIndex; return boneIndex;
} }
override public function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector<Event>, alpha:Float, blend:MixBlend, override public function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array<Event>, alpha:Float, blend:MixBlend,
direction:MixDirection):Void { direction:MixDirection):Void {
var bone:Bone = skeleton.bones[boneIndex]; var bone:Bone = skeleton.bones[boneIndex];
if (!bone.active) if (!bone.active)

View File

@ -29,7 +29,6 @@
package spine.animation; package spine.animation;
import openfl.Vector;
import spine.Bone; import spine.Bone;
import spine.Event; import spine.Event;
import spine.Skeleton; import spine.Skeleton;
@ -38,7 +37,7 @@ class ShearXTimeline extends CurveTimeline1 implements BoneTimeline {
private var boneIndex:Int = 0; private var boneIndex:Int = 0;
public function new(frameCount:Int, bezierCount:Int, boneIndex:Int) { public function new(frameCount:Int, bezierCount:Int, boneIndex:Int) {
super(frameCount, bezierCount, Vector.ofArray([Property.shearX + "|" + boneIndex])); super(frameCount, bezierCount, [Property.shearX + "|" + boneIndex]);
this.boneIndex = boneIndex; this.boneIndex = boneIndex;
} }
@ -46,7 +45,7 @@ class ShearXTimeline extends CurveTimeline1 implements BoneTimeline {
return boneIndex; return boneIndex;
} }
override public function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector<Event>, alpha:Float, blend:MixBlend, override public function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array<Event>, alpha:Float, blend:MixBlend,
direction:MixDirection):Void { direction:MixDirection):Void {
var bone:Bone = skeleton.bones[boneIndex]; var bone:Bone = skeleton.bones[boneIndex];
if (!bone.active) if (!bone.active)

View File

@ -29,7 +29,6 @@
package spine.animation; package spine.animation;
import openfl.Vector;
import spine.Bone; import spine.Bone;
import spine.Event; import spine.Event;
import spine.Skeleton; import spine.Skeleton;
@ -38,7 +37,7 @@ class ShearYTimeline extends CurveTimeline1 implements BoneTimeline {
private var boneIndex:Int = 0; private var boneIndex:Int = 0;
public function new(frameCount:Int, bezierCount:Int, boneIndex:Int) { public function new(frameCount:Int, bezierCount:Int, boneIndex:Int) {
super(frameCount, bezierCount, Vector.ofArray([Property.shearY + "|" + boneIndex])); super(frameCount, bezierCount, [Property.shearY + "|" + boneIndex]);
this.boneIndex = boneIndex; this.boneIndex = boneIndex;
} }
@ -46,7 +45,7 @@ class ShearYTimeline extends CurveTimeline1 implements BoneTimeline {
return boneIndex; return boneIndex;
} }
override public function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector<Event>, alpha:Float, blend:MixBlend, override public function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array<Event>, alpha:Float, blend:MixBlend,
direction:MixDirection):Void { direction:MixDirection):Void {
var bone:Bone = skeleton.bones[boneIndex]; var bone:Bone = skeleton.bones[boneIndex];
if (!bone.active) if (!bone.active)

View File

@ -31,15 +31,15 @@ package spine.animation;
import spine.Event; import spine.Event;
import spine.Skeleton; import spine.Skeleton;
import openfl.Vector;
class Timeline { class Timeline {
public var propertyIds:Vector<String>; public var propertyIds:Array<String>;
public var frames:Vector<Float>; public var frames:Array<Float>;
public function new(frameCount:Int, propertyIds:Vector<String>) { public function new(frameCount:Int, propertyIds:Array<String>) {
this.propertyIds = propertyIds; this.propertyIds = propertyIds;
frames = new Vector<Float>(frameCount * getFrameEntries(), true); frames = new Array<Float>();
frames.resize(frameCount * getFrameEntries());
} }
public function getFrameEntries():Int { public function getFrameEntries():Int {
@ -54,11 +54,11 @@ class Timeline {
return frames[frames.length - getFrameEntries()]; return frames[frames.length - getFrameEntries()];
} }
public function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector<Event>, alpha:Float, blend:MixBlend, direction:MixDirection):Void { public function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array<Event>, alpha:Float, blend:MixBlend, direction:MixDirection):Void {
throw new SpineException("Timeline implementations must override apply()"); throw new SpineException("Timeline implementations must override apply()");
} }
public static function search1(frames:Vector<Float>, time:Float):Int { public static function search1(frames:Array<Float>, time:Float):Int {
var n:Int = frames.length; var n:Int = frames.length;
for (i in 1...n) { for (i in 1...n) {
if (frames[i] > time) if (frames[i] > time)
@ -67,7 +67,7 @@ class Timeline {
return n - 1; return n - 1;
} }
public static function search(values:Vector<Float>, time:Float, step:Int):Int { public static function search(values:Array<Float>, time:Float, step:Int):Int {
var n:Int = values.length; var n:Int = values.length;
var i:Int = step; var i:Int = step;
while (i < n) { while (i < n) {

View File

@ -29,7 +29,6 @@
package spine.animation; package spine.animation;
import openfl.Vector;
import spine.animation.Listeners.EventListeners; import spine.animation.Listeners.EventListeners;
import spine.Poolable; import spine.Poolable;
@ -68,9 +67,9 @@ class TrackEntry implements Poolable {
public var interruptAlpha:Float = 0; public var interruptAlpha:Float = 0;
public var totalAlpha:Float = 0; public var totalAlpha:Float = 0;
public var mixBlend:MixBlend = MixBlend.replace; public var mixBlend:MixBlend = MixBlend.replace;
public var timelineMode:Vector<Int> = new Vector<Int>(); public var timelineMode:Array<Int> = new Array<Int>();
public var timelineHoldMix:Vector<TrackEntry> = new Vector<TrackEntry>(); public var timelineHoldMix:Array<TrackEntry> = new Array<TrackEntry>();
public var timelinesRotation:Vector<Float> = new Vector<Float>(); public var timelinesRotation:Array<Float> = new Array<Float>();
public var shortestRotation = false; public var shortestRotation = false;
public function new() {} public function new() {}
@ -105,18 +104,18 @@ class TrackEntry implements Poolable {
mixingFrom = null; mixingFrom = null;
mixingTo = null; mixingTo = null;
animation = null; animation = null;
onStart.listeners.length = 0; onStart.listeners.resize(0);
onInterrupt.listeners.length = 0; onInterrupt.listeners.resize(0);
onEnd.listeners.length = 0; onEnd.listeners.resize(0);
onDispose.listeners.length = 0; onDispose.listeners.resize(0);
onComplete.listeners.length = 0; onComplete.listeners.resize(0);
onEvent.listeners.length = 0; onEvent.listeners.resize(0);
timelineMode.length = 0; timelineMode.resize(0);
timelineHoldMix.length = 0; timelineHoldMix.resize(0);
timelinesRotation.length = 0; timelinesRotation.resize(0);
} }
public function resetRotationDirection():Void { public function resetRotationDirection():Void {
timelinesRotation.length = 0; timelinesRotation.resize(0);
} }
} }

View File

@ -29,7 +29,6 @@
package spine.animation; package spine.animation;
import openfl.Vector;
import spine.Event; import spine.Event;
import spine.Skeleton; import spine.Skeleton;
import spine.TransformConstraint; import spine.TransformConstraint;
@ -48,7 +47,7 @@ class TransformConstraintTimeline extends CurveTimeline {
public var transformConstraintIndex:Int = 0; public var transformConstraintIndex:Int = 0;
public function new(frameCount:Int, bezierCount:Int, transformConstraintIndex:Int) { public function new(frameCount:Int, bezierCount:Int, transformConstraintIndex:Int) {
super(frameCount, bezierCount, Vector.ofArray([Property.transformConstraint + "|" + transformConstraintIndex])); super(frameCount, bezierCount, [Property.transformConstraint + "|" + transformConstraintIndex]);
this.transformConstraintIndex = transformConstraintIndex; this.transformConstraintIndex = transformConstraintIndex;
} }
@ -68,7 +67,7 @@ class TransformConstraintTimeline extends CurveTimeline {
frames[frame + SHEARY] = mixShearY; frames[frame + SHEARY] = mixShearY;
} }
override public function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector<Event>, alpha:Float, blend:MixBlend, override public function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array<Event>, alpha:Float, blend:MixBlend,
direction:MixDirection):Void { direction:MixDirection):Void {
var constraint:TransformConstraint = skeleton.transformConstraints[transformConstraintIndex]; var constraint:TransformConstraint = skeleton.transformConstraints[transformConstraintIndex];
if (!constraint.active) if (!constraint.active)

View File

@ -29,7 +29,6 @@
package spine.animation; package spine.animation;
import openfl.Vector;
import spine.Bone; import spine.Bone;
import spine.Event; import spine.Event;
import spine.Skeleton; import spine.Skeleton;
@ -38,7 +37,7 @@ class TranslateTimeline extends CurveTimeline2 implements BoneTimeline {
public var boneIndex:Int = 0; public var boneIndex:Int = 0;
public function new(frameCount:Int, bezierCount:Int, boneIndex:Int) { public function new(frameCount:Int, bezierCount:Int, boneIndex:Int) {
super(frameCount, bezierCount, Vector.ofArray([Property.x + "|" + boneIndex, Property.y + "|" + boneIndex])); super(frameCount, bezierCount, [Property.x + "|" + boneIndex, Property.y + "|" + boneIndex]);
this.boneIndex = boneIndex; this.boneIndex = boneIndex;
} }
@ -46,7 +45,7 @@ class TranslateTimeline extends CurveTimeline2 implements BoneTimeline {
return boneIndex; return boneIndex;
} }
override public function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector<Event>, alpha:Float, blend:MixBlend, override public function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array<Event>, alpha:Float, blend:MixBlend,
direction:MixDirection):Void { direction:MixDirection):Void {
var bone:Bone = skeleton.bones[boneIndex]; var bone:Bone = skeleton.bones[boneIndex];
if (!bone.active) if (!bone.active)

View File

@ -29,7 +29,6 @@
package spine.animation; package spine.animation;
import openfl.Vector;
import spine.Bone; import spine.Bone;
import spine.Event; import spine.Event;
import spine.Skeleton; import spine.Skeleton;
@ -38,7 +37,7 @@ class TranslateXTimeline extends CurveTimeline1 implements BoneTimeline {
public var boneIndex:Int = 0; public var boneIndex:Int = 0;
public function new(frameCount:Int, bezierCount:Int, boneIndex:Int) { public function new(frameCount:Int, bezierCount:Int, boneIndex:Int) {
super(frameCount, bezierCount, Vector.ofArray([Property.x + "|" + boneIndex])); super(frameCount, bezierCount, [Property.x + "|" + boneIndex]);
this.boneIndex = boneIndex; this.boneIndex = boneIndex;
} }
@ -46,7 +45,7 @@ class TranslateXTimeline extends CurveTimeline1 implements BoneTimeline {
return boneIndex; return boneIndex;
} }
public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector<Event>, alpha:Float, blend:MixBlend, public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array<Event>, alpha:Float, blend:MixBlend,
direction:MixDirection):Void { direction:MixDirection):Void {
var bone:Bone = skeleton.bones[boneIndex]; var bone:Bone = skeleton.bones[boneIndex];
if (!bone.active) if (!bone.active)

View File

@ -29,7 +29,6 @@
package spine.animation; package spine.animation;
import openfl.Vector;
import spine.Bone; import spine.Bone;
import spine.Event; import spine.Event;
import spine.Skeleton; import spine.Skeleton;
@ -38,7 +37,7 @@ class TranslateYTimeline extends CurveTimeline1 implements BoneTimeline {
public var boneIndex:Int = 0; public var boneIndex:Int = 0;
public function new(frameCount:Int, bezierCount:Int, boneIndex:Int) { public function new(frameCount:Int, bezierCount:Int, boneIndex:Int) {
super(frameCount, bezierCount, Vector.ofArray([Property.y + "|" + boneIndex])); super(frameCount, bezierCount, [Property.y + "|" + boneIndex]);
this.boneIndex = boneIndex; this.boneIndex = boneIndex;
} }
@ -46,7 +45,7 @@ class TranslateYTimeline extends CurveTimeline1 implements BoneTimeline {
return boneIndex; return boneIndex;
} }
public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector<Event>, alpha:Float, blend:MixBlend, public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array<Event>, alpha:Float, blend:MixBlend,
direction:MixDirection):Void { direction:MixDirection):Void {
var bone:Bone = skeleton.bones[boneIndex]; var bone:Bone = skeleton.bones[boneIndex];
if (!bone.active) if (!bone.active)

View File

@ -29,8 +29,6 @@
package spine.atlas; package spine.atlas;
import openfl.Vector;
class Format { class Format {
public static var alpha(default, never):Format = new Format(0, "alpha"); public static var alpha(default, never):Format = new Format(0, "alpha");
public static var intensity(default, never):Format = new Format(1, "intensity"); public static var intensity(default, never):Format = new Format(1, "intensity");
@ -40,7 +38,7 @@ class Format {
public static var rgb888(default, never):Format = new Format(5, "rgb888"); public static var rgb888(default, never):Format = new Format(5, "rgb888");
public static var rgba8888(default, never):Format = new Format(6, "rgba8888"); public static var rgba8888(default, never):Format = new Format(6, "rgba8888");
public static var values(default, never):Vector<Format> = Vector.ofArray([alpha, intensity, luminanceAlpha, rgb565, rgba4444, rgb888, rgba8888]); public static var values(default, never):Array<Format> = [alpha, intensity, luminanceAlpha, rgb565, rgba4444, rgb888, rgba8888];
public var ordinal(default, null):Int; public var ordinal(default, null):Int;
public var name(default, null):String; public var name(default, null):String;

View File

@ -29,14 +29,12 @@
package spine.atlas; package spine.atlas;
import haxe.ds.StringMap;
import openfl.utils.Assets; import openfl.utils.Assets;
import openfl.utils.ByteArray;
import openfl.utils.Dictionary;
import openfl.Vector;
class TextureAtlas { class TextureAtlas {
private var pages = new Vector<TextureAtlasPage>(); private var pages = new Array<TextureAtlasPage>();
private var regions = new Vector<TextureAtlasRegion>(); private var regions = new Array<TextureAtlasRegion>();
private var textureLoader:TextureLoader; private var textureLoader:TextureLoader;
public static function fromAssets(path:String) { public static function fromAssets(path:String) {
@ -51,17 +49,14 @@ class TextureAtlas {
} }
/** @param object A String or ByteArray. */ /** @param object A String or ByteArray. */
public function new(object:Dynamic, textureLoader:TextureLoader) { public function new(atlasText:String, textureLoader:TextureLoader) {
if (object == null) { if (atlasText == null) {
return; throw new SpineException("atlasText must not be null");
} }
if (Std.isOfType(object, String)) { if (textureLoader == null) {
load(cast(object, String), textureLoader); throw new SpineException("textureLoader must not be null");
} else if (Std.isOfType(object, ByteArrayData)) {
load(cast(object, ByteArray).readUTFBytes(cast(object, ByteArray).length), textureLoader);
} else {
throw new SpineException("object must be a string or ByteArrayData.");
} }
load(atlasText, textureLoader);
} }
private function load(atlasText:String, textureLoader:TextureLoader):Void { private function load(atlasText:String, textureLoader:TextureLoader):Void {
@ -71,71 +66,72 @@ class TextureAtlas {
this.textureLoader = textureLoader; this.textureLoader = textureLoader;
var reader:Reader = new Reader(atlasText); var reader:Reader = new Reader(atlasText);
var entry:Vector<String> = new Vector<String>(5, true); var entry:Array<String> = new Array<String>();
entry.resize(5);
var page:TextureAtlasPage = null; var page:TextureAtlasPage = null;
var region:TextureAtlasRegion = null; var region:TextureAtlasRegion = null;
var pageFields:Dictionary<String, Void->Void> = new Dictionary<String, Void->Void>(); var pageFields:StringMap<Void->Void> = new StringMap<Void->Void>();
pageFields["size"] = function():Void { pageFields.set("size", function():Void {
page.width = Std.parseInt(entry[1]); page.width = Std.parseInt(entry[1]);
page.height = Std.parseInt(entry[2]); page.height = Std.parseInt(entry[2]);
}; });
pageFields["format"] = function():Void { pageFields.set("format", function():Void {
page.format = Format.fromName(entry[0]); page.format = Format.fromName(entry[0]);
}; });
pageFields["filter"] = function():Void { pageFields.set("filter", function():Void {
page.minFilter = TextureFilter.fromName(entry[1]); page.minFilter = TextureFilter.fromName(entry[1]);
page.magFilter = TextureFilter.fromName(entry[2]); page.magFilter = TextureFilter.fromName(entry[2]);
}; });
pageFields["repeat"] = function():Void { pageFields.set("repeat", function():Void {
if (entry[1].indexOf('x') != -1) if (entry[1].indexOf('x') != -1)
page.uWrap = TextureWrap.repeat; page.uWrap = TextureWrap.repeat;
if (entry[1].indexOf('y') != -1) if (entry[1].indexOf('y') != -1)
page.vWrap = TextureWrap.repeat; page.vWrap = TextureWrap.repeat;
}; });
pageFields["pma"] = function():Void { pageFields.set("pma", function():Void {
page.pma = entry[1] == "true"; page.pma = entry[1] == "true";
}; });
var regionFields:Dictionary<String, Void->Void> = new Dictionary<String, Void->Void>(); var regionFields:StringMap<Void->Void> = new StringMap<Void->Void>();
regionFields["xy"] = function():Void { regionFields.set("xy", function():Void {
region.x = Std.parseInt(entry[1]); region.x = Std.parseInt(entry[1]);
region.y = Std.parseInt(entry[2]); region.y = Std.parseInt(entry[2]);
}; });
regionFields["size"] = function():Void { regionFields.set("size", function():Void {
region.width = Std.parseInt(entry[1]); region.width = Std.parseInt(entry[1]);
region.height = Std.parseInt(entry[2]); region.height = Std.parseInt(entry[2]);
}; });
regionFields["bounds"] = function():Void { regionFields.set("bounds", function():Void {
region.x = Std.parseInt(entry[1]); region.x = Std.parseInt(entry[1]);
region.y = Std.parseInt(entry[2]); region.y = Std.parseInt(entry[2]);
region.width = Std.parseInt(entry[3]); region.width = Std.parseInt(entry[3]);
region.height = Std.parseInt(entry[4]); region.height = Std.parseInt(entry[4]);
}; });
regionFields["offset"] = function():Void { regionFields.set("offset", function():Void {
region.offsetX = Std.parseInt(entry[1]); region.offsetX = Std.parseInt(entry[1]);
region.offsetY = Std.parseInt(entry[2]); region.offsetY = Std.parseInt(entry[2]);
}; });
regionFields["orig"] = function():Void { regionFields.set("orig", function():Void {
region.originalWidth = Std.parseInt(entry[1]); region.originalWidth = Std.parseInt(entry[1]);
region.originalHeight = Std.parseInt(entry[2]); region.originalHeight = Std.parseInt(entry[2]);
}; });
regionFields["offsets"] = function():Void { regionFields.set("offsets", function():Void {
region.offsetX = Std.parseInt(entry[1]); region.offsetX = Std.parseInt(entry[1]);
region.offsetY = Std.parseInt(entry[2]); region.offsetY = Std.parseInt(entry[2]);
region.originalWidth = Std.parseInt(entry[3]); region.originalWidth = Std.parseInt(entry[3]);
region.originalHeight = Std.parseInt(entry[4]); region.originalHeight = Std.parseInt(entry[4]);
}; });
regionFields["rotate"] = function():Void { regionFields.set("rotate", function():Void {
var value:String = entry[1]; var value:String = entry[1];
if (value == "true") if (value == "true")
region.degrees = 90; region.degrees = 90;
else if (value != "false") else if (value != "false")
region.degrees = Std.parseInt(value); region.degrees = Std.parseInt(value);
}; });
regionFields["index"] = function():Void { regionFields.set("index", function():Void {
region.index = Std.parseInt(entry[1]); region.index = Std.parseInt(entry[1]);
}; });
var line:String = reader.readLine(); var line:String = reader.readLine();
// Ignore empty lines before first entry. // Ignore empty lines before first entry.
@ -153,8 +149,8 @@ class TextureAtlas {
} }
// Page and region entries. // Page and region entries.
var names:Vector<String> = null; var names:Array<String> = null;
var values:Vector<Vector<Float>> = null; var values:Array<Array<Float>> = null;
var field:Void->Void; var field:Void->Void;
while (true) { while (true) {
if (line == null) if (line == null)
@ -167,7 +163,7 @@ class TextureAtlas {
while (true) { while (true) {
if (reader.readEntry(entry, line = reader.readLine()) == 0) if (reader.readEntry(entry, line = reader.readLine()) == 0)
break; break;
field = pageFields[entry[0]]; field = pageFields.get(entry[0]);
if (field != null) { if (field != null) {
field(); field();
} }
@ -180,16 +176,17 @@ class TextureAtlas {
var count:Int = reader.readEntry(entry, line = reader.readLine()); var count:Int = reader.readEntry(entry, line = reader.readLine());
if (count == 0) if (count == 0)
break; break;
field = regionFields[entry[0]]; field = regionFields.get(entry[0]);
if (field != null) { if (field != null) {
field(); field();
} else { } else {
if (names == null) { if (names == null) {
names = new Vector<String>(); names = new Array<String>();
values = new Vector<Vector<Float>>(); values = new Array<Array<Float>>();
} }
names.push(entry[0]); names.push(entry[0]);
var entryValues:Vector<Float> = new Vector<Float>(count, true); var entryValues:Array<Float> = new Array<Float>();
entryValues.resize(count);
for (i in 0...count) { for (i in 0...count) {
entryValues[i] = Std.parseInt(entry[i + 1]); entryValues[i] = Std.parseInt(entry[i + 1]);
} }
@ -262,7 +259,7 @@ class Reader {
return index >= lines.length ? null : lines[index++]; return index >= lines.length ? null : lines[index++];
} }
public function readEntry(entry:Vector<String>, line:String):Int { public function readEntry(entry:Array<String>, line:String):Int {
if (line == null) if (line == null)
return 0; return 0;
if (line.length == 0) if (line.length == 0)

View File

@ -29,18 +29,16 @@
package spine.atlas; package spine.atlas;
import openfl.Vector;
class TextureAtlasRegion extends TextureRegion { class TextureAtlasRegion extends TextureRegion {
public var page:TextureAtlasPage; public var page:TextureAtlasPage;
public var name:String; public var name:String;
public var x:Int = 0; public var x:Int = 0;
public var y:Int = 0; public var y:Int = 0;
public var index:Int = 0; public var index:Int = 0;
public var splits:Vector<Int>; public var splits:Array<Int>;
public var pads:Vector<Int>; public var pads:Array<Int>;
public var names:Vector<String>; public var names:Array<String>;
public var values:Vector<Vector<Float>>; public var values:Array<Array<Float>>;
public function new(page:TextureAtlasPage, name:String) { public function new(page:TextureAtlasPage, name:String) {
super(); super();

View File

@ -29,8 +29,6 @@
package spine.atlas; package spine.atlas;
import openfl.Vector;
class TextureFilter { class TextureFilter {
public static var nearest(default, never):TextureFilter = new TextureFilter(0, "nearest"); public static var nearest(default, never):TextureFilter = new TextureFilter(0, "nearest");
public static var linear(default, never):TextureFilter = new TextureFilter(1, "linear"); public static var linear(default, never):TextureFilter = new TextureFilter(1, "linear");
@ -40,7 +38,7 @@ class TextureFilter {
public static var mipMapNearestLinear(default, never):TextureFilter = new TextureFilter(5, "mipMapNearestLinear"); public static var mipMapNearestLinear(default, never):TextureFilter = new TextureFilter(5, "mipMapNearestLinear");
public static var mipMapLinearLinear(default, never):TextureFilter = new TextureFilter(6, "mipMapLinearLinear"); public static var mipMapLinearLinear(default, never):TextureFilter = new TextureFilter(6, "mipMapLinearLinear");
public static var values(default, never):Vector<TextureFilter> = Vector.ofArray([ public static var values(default, never):Array<TextureFilter> = [
nearest, nearest,
linear, linear,
mipMap, mipMap,
@ -48,7 +46,7 @@ class TextureFilter {
mipMapLinearNearest, mipMapLinearNearest,
mipMapNearestLinear, mipMapNearestLinear,
mipMapLinearLinear mipMapLinearLinear
]); ];
public var ordinal(default, null):Int; public var ordinal(default, null):Int;
public var name(default, null):String; public var name(default, null):String;

View File

@ -29,14 +29,12 @@
package spine.atlas; package spine.atlas;
import openfl.Vector;
class TextureWrap { class TextureWrap {
public static var mirroredRepeat(default, never):TextureWrap = new TextureWrap(0, "mirroredRepeat"); public static var mirroredRepeat(default, never):TextureWrap = new TextureWrap(0, "mirroredRepeat");
public static var clampToEdge(default, never):TextureWrap = new TextureWrap(1, "clampToEdge"); public static var clampToEdge(default, never):TextureWrap = new TextureWrap(1, "clampToEdge");
public static var repeat(default, never):TextureWrap = new TextureWrap(2, "repeat"); public static var repeat(default, never):TextureWrap = new TextureWrap(2, "repeat");
public static var values(default, never):Vector<TextureWrap> = Vector.ofArray([mirroredRepeat, clampToEdge, repeat]); public static var values(default, never):Array<TextureWrap> = [mirroredRepeat, clampToEdge, repeat];
public var ordinal(default, null):Int; public var ordinal(default, null):Int;
public var name(default, null):String; public var name(default, null):String;

View File

@ -29,8 +29,6 @@
package spine.attachments; package spine.attachments;
import openfl.Vector;
class AttachmentType { class AttachmentType {
public static var region(default, never):AttachmentType = new AttachmentType(0, "region"); public static var region(default, never):AttachmentType = new AttachmentType(0, "region");
public static var boundingbox(default, never):AttachmentType = new AttachmentType(1, "boundingbox"); public static var boundingbox(default, never):AttachmentType = new AttachmentType(1, "boundingbox");
@ -40,7 +38,7 @@ class AttachmentType {
public static var point(default, never):AttachmentType = new AttachmentType(5, "point"); public static var point(default, never):AttachmentType = new AttachmentType(5, "point");
public static var clipping(default, never):AttachmentType = new AttachmentType(6, "clipping"); public static var clipping(default, never):AttachmentType = new AttachmentType(6, "clipping");
public static var values(default, never):Vector<AttachmentType> = Vector.ofArray([region, boundingbox, mesh, linkedmesh, path, point, clipping]); public static var values(default, never):Array<AttachmentType> = [region, boundingbox, mesh, linkedmesh, path, point, clipping];
public var ordinal(default, null):Int; public var ordinal(default, null):Int;
public var name(default, null):String; public var name(default, null):String;

View File

@ -29,21 +29,20 @@
package spine.attachments; package spine.attachments;
import openfl.Vector;
import spine.Color; import spine.Color;
import spine.atlas.TextureAtlasRegion; import spine.atlas.TextureAtlasRegion;
class MeshAttachment extends VertexAttachment implements HasTextureRegion { class MeshAttachment extends VertexAttachment implements HasTextureRegion {
public var region:TextureRegion; public var region:TextureRegion;
public var path:String; public var path:String;
public var regionUVs = new Vector<Float>(); public var regionUVs = new Array<Float>();
public var uvs = new Vector<Float>(); public var uvs = new Array<Float>();
public var triangles = new Vector<Int>(); public var triangles = new Array<Int>();
public var color:Color = new Color(1, 1, 1, 1); public var color:Color = new Color(1, 1, 1, 1);
public var width:Float = 0; public var width:Float = 0;
public var height:Float = 0; public var height:Float = 0;
public var hullLength:Int = 0; public var hullLength:Int = 0;
public var edges = new Vector<Int>(); public var edges = new Array<Int>();
public var rendererObject:Dynamic; public var rendererObject:Dynamic;
public var sequence:Sequence; public var sequence:Sequence;
@ -60,8 +59,10 @@ class MeshAttachment extends VertexAttachment implements HasTextureRegion {
return; return;
} }
var regionUVs = this.regionUVs; var regionUVs = this.regionUVs;
if (uvs.length != regionUVs.length) if (uvs.length != regionUVs.length) {
uvs = new Vector<Float>(regionUVs.length, true); uvs = new Array<Float>();
uvs.resize(regionUVs.length);
}
var n = uvs.length; var n = uvs.length;
var u = region.u, v = region.v, width:Float = 0, height:Float = 0; var u = region.u, v = region.v, width:Float = 0, height:Float = 0;
if (Std.isOfType(region, TextureAtlasRegion)) { if (Std.isOfType(region, TextureAtlasRegion)) {
@ -156,15 +157,15 @@ class MeshAttachment extends VertexAttachment implements HasTextureRegion {
copy.rendererObject = rendererObject; copy.rendererObject = rendererObject;
this.copyTo(copy); this.copyTo(copy);
copy.regionUVs = regionUVs.concat(); copy.regionUVs = regionUVs.copy();
copy.uvs = uvs.concat(); copy.uvs = uvs.copy();
copy.triangles = triangles.concat(); copy.triangles = triangles.copy();
copy.hullLength = hullLength; copy.hullLength = hullLength;
copy.sequence = sequence != null ? sequence.copy() : null; copy.sequence = sequence != null ? sequence.copy() : null;
if (edges != null) { if (edges != null) {
copy.edges = edges.concat(); copy.edges = edges.copy();
} }
copy.width = width; copy.width = width;
copy.height = height; copy.height = height;
@ -172,7 +173,7 @@ class MeshAttachment extends VertexAttachment implements HasTextureRegion {
return copy; return copy;
} }
public override function computeWorldVertices(slot:Slot, start:Int, count:Int, worldVertices:Vector<Float>, offset:Int, stride:Int):Void { public override function computeWorldVertices(slot:Slot, start:Int, count:Int, worldVertices:Array<Float>, offset:Int, stride:Int):Void {
if (sequence != null) if (sequence != null)
sequence.apply(slot, this); sequence.apply(slot, this);
super.computeWorldVertices(slot, start, count, worldVertices, offset, stride); super.computeWorldVertices(slot, start, count, worldVertices, offset, stride);

View File

@ -29,11 +29,10 @@
package spine.attachments; package spine.attachments;
import openfl.Vector;
import spine.Color; import spine.Color;
class PathAttachment extends VertexAttachment { class PathAttachment extends VertexAttachment {
public var lengths:Vector<Float>; public var lengths:Array<Float>;
public var closed:Bool = false; public var closed:Bool = false;
public var constantSpeed:Bool = false; public var constantSpeed:Bool = false;
public var color:Color = new Color(0, 0, 0, 0); public var color:Color = new Color(0, 0, 0, 0);
@ -45,7 +44,7 @@ class PathAttachment extends VertexAttachment {
override public function copy():Attachment { override public function copy():Attachment {
var copy:PathAttachment = new PathAttachment(name); var copy:PathAttachment = new PathAttachment(name);
copyTo(copy); copyTo(copy);
copy.lengths = lengths.concat(); copy.lengths = lengths.copy();
copy.closed = closed; copy.closed = closed;
copy.constantSpeed = constantSpeed; copy.constantSpeed = constantSpeed;
return copy; return copy;

View File

@ -29,7 +29,6 @@
package spine.attachments; package spine.attachments;
import openfl.Vector;
import spine.Bone; import spine.Bone;
import spine.Color; import spine.Color;
import spine.MathUtils; import spine.MathUtils;
@ -44,7 +43,7 @@ class PointAttachment extends VertexAttachment {
super(name); super(name);
} }
public function computeWorldPosition(bone:Bone, point:Vector<Float>):Vector<Float> { public function computeWorldPosition(bone:Bone, point:Array<Float>):Array<Float> {
point[0] = x * bone.a + y * bone.b + bone.worldX; point[0] = x * bone.a + y * bone.b + bone.worldX;
point[1] = x * bone.c + y * bone.d + bone.worldY; point[1] = x * bone.c + y * bone.d + bone.worldY;
return point; return point;

View File

@ -29,8 +29,6 @@
package spine.attachments; package spine.attachments;
import openfl.Vector;
import spine.Bone;
import spine.Color; import spine.Color;
class RegionAttachment extends Attachment implements HasTextureRegion { class RegionAttachment extends Attachment implements HasTextureRegion {
@ -56,9 +54,9 @@ class RegionAttachment extends Attachment implements HasTextureRegion {
public var region:TextureRegion; public var region:TextureRegion;
public var sequence:Sequence; public var sequence:Sequence;
private var offsets:Vector<Float> = new Vector<Float>(8, true); private var offsets:Array<Float> = new Array<Float>();
public var uvs:Vector<Float> = new Vector<Float>(8, true); public var uvs:Array<Float> = new Array<Float>();
public function new(name:String, path:String) { public function new(name:String, path:String) {
super(name); super(name);
@ -128,7 +126,7 @@ class RegionAttachment extends Attachment implements HasTextureRegion {
} }
} }
public function computeWorldVertices(slot:Slot, worldVertices:Vector<Float>, offset:Int, stride:Int):Void { public function computeWorldVertices(slot:Slot, worldVertices:Array<Float>, offset:Int, stride:Int):Void {
if (sequence != null) if (sequence != null)
sequence.apply(slot, this); sequence.apply(slot, this);
@ -173,8 +171,8 @@ class RegionAttachment extends Attachment implements HasTextureRegion {
copy.rotation = rotation; copy.rotation = rotation;
copy.width = width; copy.width = width;
copy.height = height; copy.height = height;
copy.uvs = uvs.concat(); copy.uvs = uvs.copy();
copy.offsets = offsets.concat(); copy.offsets = offsets.copy();
copy.color.setFromColor(color); copy.color.setFromColor(color);
copy.sequence = sequence != null ? sequence.copy() : null; copy.sequence = sequence != null ? sequence.copy() : null;
return copy; return copy;

View File

@ -29,7 +29,6 @@
package spine.attachments; package spine.attachments;
import openfl.Vector;
import spine.Bone; import spine.Bone;
import spine.Skeleton; import spine.Skeleton;
import spine.Slot; import spine.Slot;
@ -37,8 +36,8 @@ import spine.Slot;
class VertexAttachment extends Attachment { class VertexAttachment extends Attachment {
private static var nextID:Int = 0; private static var nextID:Int = 0;
public var bones:Vector<Int>; public var bones:Array<Int>;
public var vertices = new Vector<Float>(); public var vertices = new Array<Float>();
public var worldVerticesLength:Int = 0; public var worldVerticesLength:Int = 0;
public var id:Int = nextID++; public var id:Int = nextID++;
public var timelineAttachment:VertexAttachment; public var timelineAttachment:VertexAttachment;
@ -59,10 +58,10 @@ class VertexAttachment extends Attachment {
* `stride` / 2. * `stride` / 2.
* @param offset The `worldVertices` index to begin writing values. * @param offset The `worldVertices` index to begin writing values.
* @param stride The number of `worldVertices` entries between the value pairs written. */ * @param stride The number of `worldVertices` entries between the value pairs written. */
public function computeWorldVertices(slot:Slot, start:Int, count:Int, worldVertices:Vector<Float>, offset:Int, stride:Int):Void { public function computeWorldVertices(slot:Slot, start:Int, count:Int, worldVertices:Array<Float>, offset:Int, stride:Int):Void {
count = offset + (count >> 1) * stride; count = offset + (count >> 1) * stride;
var skeleton:Skeleton = slot.skeleton; var skeleton:Skeleton = slot.skeleton;
var deform:Vector<Float> = slot.deform; var deform:Array<Float> = slot.deform;
var v:Int, w:Int, n:Int, i:Int, skip:Int, b:Int, f:Int; var v:Int, w:Int, n:Int, i:Int, skip:Int, b:Int, f:Int;
var vx:Float, vy:Float; var vx:Float, vy:Float;
@ -100,7 +99,7 @@ class VertexAttachment extends Attachment {
skip += n; skip += n;
i += 2; i += 2;
} }
var skeletonBones:Vector<Bone> = skeleton.bones; var skeletonBones:Array<Bone> = skeleton.bones;
if (deform.length == 0) { if (deform.length == 0) {
w = offset; w = offset;
b = skip * 3; b = skip * 3;
@ -152,13 +151,13 @@ class VertexAttachment extends Attachment {
public function copyTo(attachment:VertexAttachment):Void { public function copyTo(attachment:VertexAttachment):Void {
if (bones != null) { if (bones != null) {
attachment.bones = bones.concat(); attachment.bones = bones.copy();
} else { } else {
attachment.bones = null; attachment.bones = null;
} }
if (this.vertices != null) { if (this.vertices != null) {
attachment.vertices = vertices.concat(); attachment.vertices = vertices.copy();
} }
attachment.worldVerticesLength = worldVerticesLength; attachment.worldVerticesLength = worldVerticesLength;

View File

@ -30,7 +30,6 @@
package spine.starling; package spine.starling;
import starling.animation.IAnimatable; import starling.animation.IAnimatable;
import openfl.Vector;
import openfl.geom.Matrix; import openfl.geom.Matrix;
import openfl.geom.Point; import openfl.geom.Point;
import openfl.geom.Rectangle; import openfl.geom.Rectangle;
@ -58,8 +57,8 @@ import starling.utils.Max;
class SkeletonSprite extends DisplayObject implements IAnimatable { class SkeletonSprite extends DisplayObject implements IAnimatable {
static private var _tempPoint:Point = new Point(); static private var _tempPoint:Point = new Point();
static private var _tempMatrix:Matrix = new Matrix(); static private var _tempMatrix:Matrix = new Matrix();
static private var _tempVertices:Vector<Float> = new Vector<Float>(); static private var _tempVertices:Array<Float> = new Array<Float>();
static private var blendModes:Vector<String> = Vector.ofArray([BlendMode.NORMAL, BlendMode.ADD, BlendMode.MULTIPLY, BlendMode.SCREEN]); static private var blendModes:Array<String> = [BlendMode.NORMAL, BlendMode.ADD, BlendMode.MULTIPLY, BlendMode.SCREEN];
private var _skeleton:Skeleton; private var _skeleton:Skeleton;
@ -68,7 +67,7 @@ class SkeletonSprite extends DisplayObject implements IAnimatable {
private var _smoothing:String = "bilinear"; private var _smoothing:String = "bilinear";
private static var clipper:SkeletonClipping = new SkeletonClipping(); private static var clipper:SkeletonClipping = new SkeletonClipping();
private static var QUAD_INDICES:Vector<Int> = Vector.ofArray([0, 1, 2, 2, 3, 0]); private static var QUAD_INDICES:Array<Int> = [0, 1, 2, 2, 3, 0];
private var tempLight:spine.Color = new spine.Color(0, 0, 0); private var tempLight:spine.Color = new spine.Color(0, 0, 0);
private var tempDark:spine.Color = new spine.Color(0, 0, 0); private var tempDark:spine.Color = new spine.Color(0, 0, 0);
@ -88,7 +87,7 @@ class SkeletonSprite extends DisplayObject implements IAnimatable {
var r:Float = skeleton.color.r * 255; var r:Float = skeleton.color.r * 255;
var g:Float = skeleton.color.g * 255; var g:Float = skeleton.color.g * 255;
var b:Float = skeleton.color.b * 255; var b:Float = skeleton.color.b * 255;
var drawOrder:Vector<Slot> = skeleton.drawOrder; var drawOrder:Array<Slot> = skeleton.drawOrder;
var attachmentColor:spine.Color; var attachmentColor:spine.Color;
var rgb:Int; var rgb:Int;
var a:Float; var a:Float;
@ -98,9 +97,9 @@ class SkeletonSprite extends DisplayObject implements IAnimatable {
var verticesCount:Int; var verticesCount:Int;
var indicesLength:Int; var indicesLength:Int;
var indexData:IndexData; var indexData:IndexData;
var indices:Vector<Int> = null; var indices:Array<Int> = null;
var vertexData:VertexData; var vertexData:VertexData;
var uvs:Vector<Float>; var uvs:Array<Float>;
for (slot in drawOrder) { for (slot in drawOrder) {
if (!slot.bone.active) { if (!slot.bone.active) {
@ -108,13 +107,13 @@ class SkeletonSprite extends DisplayObject implements IAnimatable {
continue; continue;
} }
var worldVertices:Vector<Float> = _tempVertices; var worldVertices:Array<Float> = _tempVertices;
if (Std.isOfType(slot.attachment, RegionAttachment)) { if (Std.isOfType(slot.attachment, RegionAttachment)) {
var region:RegionAttachment = cast(slot.attachment, RegionAttachment); var region:RegionAttachment = cast(slot.attachment, RegionAttachment);
verticesLength = 8; verticesLength = 8;
verticesCount = verticesLength >> 1; verticesCount = verticesLength >> 1;
if (worldVertices.length < verticesLength) if (worldVertices.length < verticesLength)
worldVertices.length = verticesLength; worldVertices.resize(verticesLength);
region.computeWorldVertices(slot, worldVertices, 0, 2); region.computeWorldVertices(slot, worldVertices, 0, 2);
mesh = null; mesh = null;
@ -142,7 +141,7 @@ class SkeletonSprite extends DisplayObject implements IAnimatable {
verticesLength = meshAttachment.worldVerticesLength; verticesLength = meshAttachment.worldVerticesLength;
verticesCount = verticesLength >> 1; verticesCount = verticesLength >> 1;
if (worldVertices.length < verticesLength) if (worldVertices.length < verticesLength)
worldVertices.length = verticesLength; worldVertices.resize(verticesLength);
meshAttachment.computeWorldVertices(slot, 0, meshAttachment.worldVerticesLength, worldVertices, 0, 2); meshAttachment.computeWorldVertices(slot, 0, meshAttachment.worldVerticesLength, worldVertices, 0, 2);
mesh = null; mesh = null;
@ -237,8 +236,8 @@ class SkeletonSprite extends DisplayObject implements IAnimatable {
var minY:Float = Max.MAX_VALUE; var minY:Float = Max.MAX_VALUE;
var maxX:Float = -Max.MAX_VALUE; var maxX:Float = -Max.MAX_VALUE;
var maxY:Float = -Max.MAX_VALUE; var maxY:Float = -Max.MAX_VALUE;
var slots:Vector<Slot> = skeleton.slots; var slots:Array<Slot> = skeleton.slots;
var worldVertices:Vector<Float> = _tempVertices; var worldVertices:Array<Float> = _tempVertices;
var empty:Bool = true; var empty:Bool = true;
for (i in 0...slots.length) { for (i in 0...slots.length) {
var slot:Slot = slots[i]; var slot:Slot = slots[i];
@ -254,7 +253,7 @@ class SkeletonSprite extends DisplayObject implements IAnimatable {
var mesh:MeshAttachment = cast(attachment, MeshAttachment); var mesh:MeshAttachment = cast(attachment, MeshAttachment);
verticesLength = mesh.worldVerticesLength; verticesLength = mesh.worldVerticesLength;
if (worldVertices.length < verticesLength) if (worldVertices.length < verticesLength)
worldVertices.length = verticesLength; worldVertices.resize(verticesLength);
mesh.computeWorldVertices(slot, 0, verticesLength, worldVertices, 0, 2); mesh.computeWorldVertices(slot, 0, verticesLength, worldVertices, 0, 2);
} else { } else {
continue; continue;