diff --git a/spine-haxe/example/src/BasicExample.hx b/spine-haxe/example/src/BasicExample.hx index afed2ec2f..473a061fa 100644 --- a/spine-haxe/example/src/BasicExample.hx +++ b/spine-haxe/example/src/BasicExample.hx @@ -36,7 +36,7 @@ import starling.events.TouchEvent; import starling.events.TouchPhase; class BasicExample extends Scene { - var loadBinary = true; + var loadBinary = false; public function load():Void { var atlas = TextureAtlas.fromAssets("assets/raptor.atlas"); diff --git a/spine-haxe/example/src/SequenceExample.hx b/spine-haxe/example/src/SequenceExample.hx index 0b4ac75f1..507881979 100644 --- a/spine-haxe/example/src/SequenceExample.hx +++ b/spine-haxe/example/src/SequenceExample.hx @@ -36,7 +36,7 @@ import starling.events.TouchEvent; import starling.events.TouchPhase; class SequenceExample extends Scene { - var loadBinary = true; + var loadBinary = false; public function load():Void { var atlas = TextureAtlas.fromAssets("assets/dragon.atlas"); diff --git a/spine-haxe/spine-haxe/spine/BinaryInput.hx b/spine-haxe/spine-haxe/spine/BinaryInput.hx index b1249cdcb..dab9e5552 100644 --- a/spine-haxe/spine-haxe/spine/BinaryInput.hx +++ b/spine-haxe/spine-haxe/spine/BinaryInput.hx @@ -29,32 +29,48 @@ package spine; -import openfl.utils.ByteArray; -import openfl.Vector; +import haxe.io.FPHelper; +import haxe.io.Bytes; class BinaryInput { - private var bytes:ByteArray; + private var bytes:Bytes; + private var index:Int = 0; - public var strings:Vector = new Vector(); + public var strings:Array = new Array(); - public function new(bytes:ByteArray) { + public function new(bytes:Bytes) { this.bytes = bytes; } public function readByte():Int { - return bytes.readByte(); + var result = bytes.get(index++); + if ((result & 0x80) != 0) { + result |= 0xffffff00; + } + return result; } public function readUnsignedByte():Int { - return bytes.readUnsignedByte(); + return bytes.get(index++); } 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 { - 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 { @@ -80,8 +96,8 @@ class BinaryInput { } public function readStringRef():String { - var index:Int = readInt(true); - return index == 0 ? null : strings[index - 1]; + var idx:Int = readInt(true); + return idx == 0 ? null : strings[idx - 1]; } public function readString():String { @@ -113,7 +129,7 @@ class BinaryInput { } public function readFloat():Float { - return bytes.readFloat(); + return FPHelper.i32ToFloat(readInt32()); } public function readBoolean():Bool { diff --git a/spine-haxe/spine-haxe/spine/BlendMode.hx b/spine-haxe/spine-haxe/spine/BlendMode.hx index 7688e894d..9293ae753 100644 --- a/spine-haxe/spine-haxe/spine/BlendMode.hx +++ b/spine-haxe/spine-haxe/spine/BlendMode.hx @@ -29,15 +29,13 @@ package spine; -import openfl.Vector; - class BlendMode { 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 multiply(default, never):BlendMode = new BlendMode(2, "multiply"); public static var screen(default, never):BlendMode = new BlendMode(3, "screen"); - public static var values(default, never):Vector = Vector.ofArray([normal, additive, multiply, screen]); + public static var values(default, never):Array = [normal, additive, multiply, screen]; public var ordinal(default, null):Int; public var name(default, null):String; diff --git a/spine-haxe/spine-haxe/spine/Bone.hx b/spine-haxe/spine-haxe/spine/Bone.hx index bf53da935..b6461e587 100644 --- a/spine-haxe/spine-haxe/spine/Bone.hx +++ b/spine-haxe/spine-haxe/spine/Bone.hx @@ -29,15 +29,13 @@ package spine; -import openfl.Vector; - class Bone implements Updatable { static public var yDown:Bool = false; private var _data:BoneData; private var _skeleton:Skeleton; private var _parent:Bone; - private var _children:Vector = new Vector(); + private var _children:Array = new Array(); public var x:Float = 0; public var y:Float = 0; @@ -230,9 +228,9 @@ class Bone implements Updatable { return _parent; } - public var children(get, never):Vector; + public var children(get, never):Array; - private function get_children():Vector { + private function get_children():Array { return _children; } @@ -308,7 +306,7 @@ class Bone implements Updatable { } } - public function worldToLocal(world:Vector):Void { + public function worldToLocal(world:Array):Void { var a:Float = a, b:Float = b, c:Float = c, d:Float = d; var invDet:Float = 1 / (a * d - b * c); 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); } - public function localToWorld(local:Vector):Void { + public function localToWorld(local:Array):Void { var localX:Float = local[0], localY:Float = local[1]; local[0] = localX * a + localY * b + worldX; local[1] = localX * c + localY * d + worldY; diff --git a/spine-haxe/spine-haxe/spine/IkConstraint.hx b/spine-haxe/spine-haxe/spine/IkConstraint.hx index 7688e0d4a..937d0a416 100644 --- a/spine-haxe/spine-haxe/spine/IkConstraint.hx +++ b/spine-haxe/spine-haxe/spine/IkConstraint.hx @@ -29,12 +29,10 @@ package spine; -import openfl.Vector; - class IkConstraint implements Updatable { private var _data:IkConstraintData; - public var bones:Vector; + public var bones:Array; public var target:Bone; public var bendDirection:Int = 0; public var compress:Bool = false; @@ -55,7 +53,7 @@ class IkConstraint implements Updatable { compress = data.compress; stretch = data.stretch; - bones = new Vector(); + bones = new Array(); for (boneData in data.bones) { bones.push(skeleton.findBone(boneData.name)); } diff --git a/spine-haxe/spine-haxe/spine/IkConstraintData.hx b/spine-haxe/spine-haxe/spine/IkConstraintData.hx index 92ad0c348..aa06812bd 100644 --- a/spine-haxe/spine-haxe/spine/IkConstraintData.hx +++ b/spine-haxe/spine-haxe/spine/IkConstraintData.hx @@ -29,10 +29,8 @@ package spine; -import openfl.Vector; - class IkConstraintData extends ConstraintData { - public var bones:Vector = new Vector(); + public var bones:Array = new Array(); public var target:BoneData; public var mix:Float = 1; public var bendDirection:Int = 1; diff --git a/spine-haxe/spine-haxe/spine/PathConstraint.hx b/spine-haxe/spine-haxe/spine/PathConstraint.hx index 51995b0ab..163fbefd5 100644 --- a/spine-haxe/spine-haxe/spine/PathConstraint.hx +++ b/spine-haxe/spine-haxe/spine/PathConstraint.hx @@ -29,7 +29,6 @@ package spine; -import openfl.Vector; import spine.attachments.PathAttachment; class PathConstraint implements Updatable { @@ -39,7 +38,7 @@ class PathConstraint implements Updatable { private static inline var epsilon:Float = 0.00001; private var _data:PathConstraintData; - private var _bones:Vector; + private var _bones:Array; public var target:Slot; public var position:Float = 0; @@ -48,12 +47,12 @@ class PathConstraint implements Updatable { public var mixX:Float = 0; public var mixY:Float = 0; - private var _spaces(default, never):Vector = new Vector(); - private var _positions(default, never):Vector = new Vector(); - private var _world(default, never):Vector = new Vector(); - private var _curves(default, never):Vector = new Vector(); - private var _lengths(default, never):Vector = new Vector(); - private var _segments(default, never):Vector = new Vector(10, true); + private var _spaces(default, never):Array = new Array(); + private var _positions(default, never):Array = new Array(); + private var _world(default, never):Array = new Array(); + private var _curves(default, never):Array = new Array(); + private var _lengths(default, never):Array = new Array(); + private var _segments(default, never):Array = new Array(); public var active:Bool = false; @@ -63,7 +62,7 @@ class PathConstraint implements Updatable { if (skeleton == null) throw new SpineException("skeleton cannot be null."); _data = data; - _bones = new Vector(); + _bones = new Array(); for (boneData in data.bones) { _bones.push(skeleton.findBone(boneData.name)); } @@ -94,11 +93,11 @@ class PathConstraint implements Updatable { var boneCount:Int = _bones.length; var spacesCount:Int = fTangents ? boneCount : boneCount + 1; - var bones:Vector = _bones; - _spaces.length = spacesCount; + var bones:Array = _bones; + _spaces.resize(spacesCount); if (fScale) - _lengths.length = boneCount; + _lengths.resize(boneCount); var i:Int, n:Int, @@ -175,7 +174,7 @@ class PathConstraint implements Updatable { } } - var positions:Vector = computeWorldPositions(attachment, spacesCount, fTangents); + var positions:Array = computeWorldPositions(attachment, spacesCount, fTangents); var boneX:Float = positions[0]; var boneY:Float = positions[1]; var offsetRotation:Float = data.offsetRotation; @@ -253,10 +252,10 @@ class PathConstraint implements Updatable { } } - private function computeWorldPositions(path:PathAttachment, spacesCount:Int, tangents:Bool):Vector { + private function computeWorldPositions(path:PathAttachment, spacesCount:Int, tangents:Bool):Array { var position:Float = this.position; - _positions.length = spacesCount * 3 + 2; - var out:Vector = _positions, world:Vector; + _positions.resize(spacesCount * 3 + 2); + var out:Array = _positions, world:Array; var closed:Bool = path.closed; var verticesLength:Int = path.worldVerticesLength; var curveCount:Int = Std.int(verticesLength / 6); @@ -264,7 +263,7 @@ class PathConstraint implements Updatable { var multiplier:Float, i:Int; if (!path.constantSpeed) { - var lengths:Vector = path.lengths; + var lengths:Array = path.lengths; curveCount -= closed ? 1 : 2; var pathLength:Float = lengths[curveCount]; if (data.positionMode == PositionMode.percent) @@ -278,7 +277,7 @@ class PathConstraint implements Updatable { multiplier = 1; } - _world.length = 8; + _world.resize(8); world = _world; var i:Int = 0; var o:Int = 0; @@ -344,7 +343,7 @@ class PathConstraint implements Updatable { // World vertices. if (closed) { verticesLength += 2; - _world.length = verticesLength; + _world.resize(verticesLength); world = _world; path.computeWorldVertices(target, 2, verticesLength - 4, world, 0, 2); path.computeWorldVertices(target, 0, 2, world, verticesLength - 4, 2); @@ -353,14 +352,14 @@ class PathConstraint implements Updatable { } else { curveCount--; verticesLength -= 4; - _world.length = verticesLength; + _world.resize(verticesLength); world = _world; path.computeWorldVertices(target, 2, verticesLength, world, 0, 2); } // Curve lengths. - _curves.length = curveCount; - var curves:Vector = _curves; + _curves.resize(curveCount); + var curves:Array = _curves; var pathLength:Float = 0; var x1:Float = world[0], y1:Float = world[1], @@ -420,7 +419,7 @@ class PathConstraint implements Updatable { multiplier = 1; } - var segments:Vector = _segments; + var segments:Array = _segments; var curveLength:Float = 0; var segment:Int; i = 0; @@ -529,7 +528,7 @@ class PathConstraint implements Updatable { return out; } - private function addBeforePosition(p:Float, temp:Vector, i:Int, out:Vector, o:Int):Void { + private function addBeforePosition(p:Float, temp:Array, i:Int, out:Array, o:Int):Void { var x1:Float = temp[i]; var y1:Float = temp[i + 1]; var dx:Float = temp[i + 2] - x1; @@ -540,7 +539,7 @@ class PathConstraint implements Updatable { out[o + 2] = r; } - private function addAfterPosition(p:Float, temp:Vector, i:Int, out:Vector, o:Int):Void { + private function addAfterPosition(p:Float, temp:Array, i:Int, out:Array, o:Int):Void { var x1:Float = temp[i + 2]; var y1:Float = temp[i + 3]; var dx:Float = x1 - temp[i]; @@ -551,7 +550,7 @@ class PathConstraint implements Updatable { 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, 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, o:Int, tangents:Bool):Void { if (p == 0 || Math.isNaN(p)) { out[o] = x1; @@ -581,9 +580,9 @@ class PathConstraint implements Updatable { } } - public var bones(get, never):Vector; + public var bones(get, never):Array; - private function get_bones():Vector { + private function get_bones():Array { return _bones; } diff --git a/spine-haxe/spine-haxe/spine/PathConstraintData.hx b/spine-haxe/spine-haxe/spine/PathConstraintData.hx index 4c18b945c..95e800f38 100644 --- a/spine-haxe/spine-haxe/spine/PathConstraintData.hx +++ b/spine-haxe/spine-haxe/spine/PathConstraintData.hx @@ -29,10 +29,8 @@ package spine; -import openfl.Vector; - class PathConstraintData extends ConstraintData { - private var _bones:Vector = new Vector(); + private var _bones:Array = new Array(); public var target:SlotData; public var positionMode:PositionMode = PositionMode.fixed; @@ -49,9 +47,9 @@ class PathConstraintData extends ConstraintData { super(name, 0, false); } - public var bones(get, never):Vector; + public var bones(get, never):Array; - private function get_bones():Vector { + private function get_bones():Array { return _bones; } } diff --git a/spine-haxe/spine-haxe/spine/Polygon.hx b/spine-haxe/spine-haxe/spine/Polygon.hx index 656efc076..9fc51d08c 100644 --- a/spine-haxe/spine-haxe/spine/Polygon.hx +++ b/spine-haxe/spine-haxe/spine/Polygon.hx @@ -29,10 +29,8 @@ package spine; -import openfl.Vector; - class Polygon { - public var vertices:Vector = new Vector(); + public var vertices:Array = new Array(); public function new() {} diff --git a/spine-haxe/spine-haxe/spine/Pool.hx b/spine-haxe/spine-haxe/spine/Pool.hx index 1c4b87231..bd80fa9a0 100644 --- a/spine-haxe/spine-haxe/spine/Pool.hx +++ b/spine-haxe/spine-haxe/spine/Pool.hx @@ -29,8 +29,6 @@ package spine; -import openfl.Vector; - #if flash typedef Function = Dynamic; #else @@ -38,11 +36,11 @@ typedef Function = haxe.Constraints.Function; #end @:generic class Pool { - private var items:Vector; + private var items:Array; private var instantiator:Function; public function new(instantiator:Void->T) { - this.items = new Vector(); + this.items = new Array(); this.instantiator = instantiator; } @@ -56,13 +54,13 @@ typedef Function = haxe.Constraints.Function; items.push(item); } - public function freeAll(items:Vector):Void { + public function freeAll(items:Array):Void { for (item in items) { free(item); } } public function clear():Void { - items.length = 0; + items.resize(0); } } diff --git a/spine-haxe/spine-haxe/spine/PositionMode.hx b/spine-haxe/spine-haxe/spine/PositionMode.hx index 24525b72d..9fd0cef97 100644 --- a/spine-haxe/spine-haxe/spine/PositionMode.hx +++ b/spine-haxe/spine-haxe/spine/PositionMode.hx @@ -29,13 +29,11 @@ package spine; -import openfl.Vector; - class PositionMode { public static var fixed(default, never):PositionMode = new PositionMode("fixed"); public static var percent(default, never):PositionMode = new PositionMode("percent"); - public static var values(default, never):Vector = Vector.ofArray([fixed, percent]); + public static var values(default, never):Array = [fixed, percent]; public var name(default, null):String; diff --git a/spine-haxe/spine-haxe/spine/Rectangle.hx b/spine-haxe/spine-haxe/spine/Rectangle.hx new file mode 100644 index 000000000..bf0fe00ca --- /dev/null +++ b/spine-haxe/spine-haxe/spine/Rectangle.hx @@ -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; + } +} diff --git a/spine-haxe/spine-haxe/spine/RotateMode.hx b/spine-haxe/spine-haxe/spine/RotateMode.hx index 2358e2c56..758a94635 100644 --- a/spine-haxe/spine-haxe/spine/RotateMode.hx +++ b/spine-haxe/spine-haxe/spine/RotateMode.hx @@ -29,14 +29,12 @@ package spine; -import openfl.Vector; - class RotateMode { public static var tangent(default, never):RotateMode = new RotateMode("tangent"); public static var chain(default, never):RotateMode = new RotateMode("chain"); public static var chainScale(default, never):RotateMode = new RotateMode("chainScale"); - public static var values(default, never):Vector = Vector.ofArray([tangent, chain, chainScale]); + public static var values(default, never):Array = [tangent, chain, chainScale]; public var name(default, null):String; diff --git a/spine-haxe/spine-haxe/spine/Sequence.hx b/spine-haxe/spine-haxe/spine/Sequence.hx index 6763d509a..40b28a1f1 100644 --- a/spine-haxe/spine-haxe/spine/Sequence.hx +++ b/spine-haxe/spine-haxe/spine/Sequence.hx @@ -29,13 +29,11 @@ package spine; -import openfl.Vector; - class Sequence { private static var _nextID = 0; public var id = _nextID++; - public var regions:Vector; + public var regions:Array; public var start = 0; public var digits = 0; @@ -43,7 +41,8 @@ class Sequence { public var setupIndex = 0; public function new(count:Int) { - this.regions = new Vector(count); + this.regions = new Array(); + this.regions.resize(count); } public function copy():Sequence { diff --git a/spine-haxe/spine-haxe/spine/SequenceMode.hx b/spine-haxe/spine-haxe/spine/SequenceMode.hx index c403b4151..f20c22b41 100644 --- a/spine-haxe/spine-haxe/spine/SequenceMode.hx +++ b/spine-haxe/spine-haxe/spine/SequenceMode.hx @@ -29,8 +29,6 @@ package spine; -import openfl.Vector; - class SequenceMode { public static var hold(default, never):SequenceMode = new SequenceMode("hold", 0); 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 pingpongReverse(default, never):SequenceMode = new SequenceMode("pingpongReverse", 6); - public static var values(default, never):Vector = Vector.ofArray([hold, once, loop, pingpong, onceReverse, loopReverse, pingpongReverse]); + public static var values(default, never):Array = [hold, once, loop, pingpong, onceReverse, loopReverse, pingpongReverse]; public var name(default, null):String; public var value:Int; diff --git a/spine-haxe/spine-haxe/spine/Skeleton.hx b/spine-haxe/spine-haxe/spine/Skeleton.hx index 263b72f02..8db4a32b8 100644 --- a/spine-haxe/spine-haxe/spine/Skeleton.hx +++ b/spine-haxe/spine-haxe/spine/Skeleton.hx @@ -29,9 +29,8 @@ package spine; -import openfl.geom.Rectangle; -import openfl.utils.Dictionary; -import openfl.Vector; +import lime.math.Rectangle; +import haxe.ds.StringMap; import spine.attachments.Attachment; import spine.attachments.MeshAttachment; import spine.attachments.PathAttachment; @@ -40,14 +39,14 @@ import spine.attachments.RegionAttachment; class Skeleton { private var _data:SkeletonData; - public var bones:Vector; - public var slots:Vector; - public var drawOrder:Vector; - public var ikConstraints:Vector; - public var transformConstraints:Vector; - public var pathConstraints:Vector; + public var bones:Array; + public var slots:Array; + public var drawOrder:Array; + public var ikConstraints:Array; + public var transformConstraints:Array; + public var pathConstraints:Array; - private var _updateCache:Vector = new Vector(); + private var _updateCache:Array = new Array(); private var _skin:Skin; public var color:Color = new Color(1, 1, 1, 1); @@ -62,7 +61,7 @@ class Skeleton { } _data = data; - bones = new Vector(); + bones = new Array(); for (boneData in data.bones) { var bone:Bone; if (boneData.parent == null) { @@ -75,8 +74,8 @@ class Skeleton { bones.push(bone); } - slots = new Vector(); - drawOrder = new Vector(); + slots = new Array(); + drawOrder = new Array(); for (slotData in data.slots) { var bone = bones[slotData.boneData.index]; var slot:Slot = new Slot(slotData, bone); @@ -84,17 +83,17 @@ class Skeleton { drawOrder.push(slot); } - ikConstraints = new Vector(); + ikConstraints = new Array(); for (ikConstraintData in data.ikConstraints) { ikConstraints.push(new IkConstraint(ikConstraintData, this)); } - transformConstraints = new Vector(); + transformConstraints = new Array(); for (transformConstraintData in data.transformConstraints) { transformConstraints.push(new TransformConstraint(transformConstraintData, this)); } - pathConstraints = new Vector(); + pathConstraints = new Array(); for (pathConstraintData in data.pathConstraints) { 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 * added or removed. */ public function updateCache():Void { - _updateCache.length = 0; + _updateCache.resize(0); for (bone in bones) { bone.sorted = bone.data.skinRequired; @@ -113,7 +112,7 @@ class Skeleton { } if (skin != null) { - var skinBones:Vector = skin.bones; + var skinBones:Array = skin.bones; for (i in 0...skin.bones.length) { var bone:Bone = bones[skinBones[i].index]; do { @@ -164,7 +163,7 @@ class Skeleton { } } - private static function contains(list:Vector, element:ConstraintData):Bool { + private static function contains(list:Array, element:ConstraintData):Bool { return list.indexOf(element) != -1; } @@ -177,7 +176,7 @@ class Skeleton { var target:Bone = constraint.target; sortBone(target); - var constrained:Vector = constraint.bones; + var constrained:Array = constraint.bones; var parent:Bone = constrained[0]; sortBone(parent); @@ -222,7 +221,7 @@ class Skeleton { if (Std.isOfType(attachment, PathAttachment)) sortPathConstraintAttachment2(attachment, slotBone); - var constrainedBones:Vector = constraint.bones; + var constrainedBones:Array = constraint.bones; for (bone in constrainedBones) { sortBone(bone); } @@ -245,7 +244,7 @@ class Skeleton { sortBone(constraint.target); - var constrainedBones:Vector = constraint.bones; + var constrainedBones:Array = constraint.bones; if (constraint.data.local) { for (bone in constrainedBones) { sortBone(bone.parent); @@ -267,10 +266,10 @@ class Skeleton { } private function sortPathConstraintAttachment(skin:Skin, slotIndex:Int, slotBone:Bone):Void { - var dict:Dictionary = skin.attachments[slotIndex]; + var dict:StringMap = skin.attachments[slotIndex]; if (dict != null) { - for (attachment in dict.each()) { - sortPathConstraintAttachment2(attachment, slotBone); + for (attachment in dict.keyValueIterator()) { + sortPathConstraintAttachment2(attachment.value, slotBone); } } } @@ -279,7 +278,7 @@ class Skeleton { var pathAttachment:PathAttachment = cast(attachment, PathAttachment); if (pathAttachment == null) return; - var pathBones:Vector = pathAttachment.bones; + var pathBones:Array = pathAttachment.bones; if (pathBones == null) { sortBone(slotBone); } else { @@ -305,7 +304,7 @@ class Skeleton { _updateCache.push(bone); } - private function sortReset(bones:Vector):Void { + private function sortReset(bones:Array):Void { for (bone in bones) { if (!bone.active) continue; @@ -411,9 +410,9 @@ class Skeleton { return _data; } - public var getUpdateCache(get, never):Vector; + public var getUpdateCache(get, never):Array; - private function get_getUpdateCache():Vector { + private function get_getUpdateCache():Array { return _updateCache; } @@ -590,7 +589,7 @@ class Skeleton { return _data.name != null ? _data.name : "Skeleton?"; } - private var _tempVertices = new Vector(); + private var _tempVertices = new Array(); private var _bounds = new Rectangle(); public function getBounds():Rectangle { @@ -600,17 +599,17 @@ class Skeleton { var maxY:Float = Math.NEGATIVE_INFINITY; for (slot in drawOrder) { var verticesLength:Int = 0; - var vertices:Vector = null; + var vertices:Array = null; var attachment:Attachment = slot.attachment; if (Std.isOfType(attachment, RegionAttachment)) { verticesLength = 8; - _tempVertices.length = verticesLength; + _tempVertices.resize(verticesLength); vertices = _tempVertices; cast(attachment, RegionAttachment).computeWorldVertices(slot, vertices, 0, 2); } else if (Std.isOfType(attachment, MeshAttachment)) { var mesh:MeshAttachment = cast(attachment, MeshAttachment); verticesLength = mesh.worldVerticesLength; - _tempVertices.length = verticesLength; + _tempVertices.resize(verticesLength); vertices = _tempVertices; mesh.computeWorldVertices(slot, 0, verticesLength, vertices, 0, 2); } diff --git a/spine-haxe/spine-haxe/spine/SkeletonBinary.hx b/spine-haxe/spine-haxe/spine/SkeletonBinary.hx index 6b090abdd..7a6d97994 100644 --- a/spine-haxe/spine-haxe/spine/SkeletonBinary.hx +++ b/spine-haxe/spine-haxe/spine/SkeletonBinary.hx @@ -29,10 +29,8 @@ package spine; +import haxe.io.Bytes; import StringTools; -import openfl.Vector; -import openfl.utils.ByteArray; -import openfl.utils.Endian; import spine.animation.AlphaTimeline; import spine.animation.Animation; import spine.animation.AttachmentTimeline; @@ -78,7 +76,7 @@ class SkeletonBinary { public var attachmentLoader:AttachmentLoader; public var scale:Float = 1; - private var linkedMeshes:Vector = new Vector(); + private var linkedMeshes:Array = new Array(); private static inline var BONE_ROTATE:Int = 0; private static inline var BONE_TRANSLATE:Int = 1; @@ -113,8 +111,8 @@ class SkeletonBinary { this.attachmentLoader = attachmentLoader; } - public function readSkeletonData(bytes:ByteArray):SkeletonData { - bytes.endian = Endian.BIG_ENDIAN; + public function readSkeletonData(bytes:Bytes):SkeletonData { + // bytes.getData(). = Endian.BIG_ENDIAN; var skeletonData:SkeletonData = new SkeletonData(); skeletonData.name = null; @@ -291,7 +289,7 @@ class SkeletonBinary { if (linkedMesh.mesh.region != null) linkedMesh.mesh.updateRegion(); } - linkedMeshes.length = 0; + linkedMeshes.resize(0); // Events. n = input.readInt(true); @@ -327,7 +325,7 @@ class SkeletonBinary { skin = new Skin("default"); } else { skin = new Skin(input.readStringRef()); - skin.bones.length = input.readInt(true); + skin.bones.resize(input.readInt(true)); for (i in 0...skin.bones.length) { skin.bones[i] = skeletonData.bones[input.readInt(true)]; } @@ -436,12 +434,12 @@ class SkeletonBinary { path = input.readStringRef(); color = input.readInt32(); vertexCount = input.readInt(true); - var uvs:Vector = readFloatArray(input, vertexCount << 1, 1); - var triangles:Vector = readShortArray(input); + var uvs:Array = readFloatArray(input, vertexCount << 1, 1); + var triangles:Array = readShortArray(input); vertices = readVertices(input, vertexCount); var hullLength:Int = input.readInt(true); var sequence = readSequence(input); - var edges:Vector = null; + var edges:Array = null; if (nonessential) { edges = readShortArray(input); width = input.readFloat(); @@ -502,8 +500,8 @@ class SkeletonBinary { var constantSpeed:Bool = input.readBoolean(); vertexCount = input.readInt(true); vertices = readVertices(input, vertexCount); - var lengths:Vector = new Vector(); - lengths.length = Std.int(vertexCount / 3); + var lengths:Array = new Array(); + lengths.resize(Std.int(vertexCount / 3)); for (i in 0...lengths.length) { lengths[i] = input.readFloat() * scale; } @@ -567,8 +565,8 @@ class SkeletonBinary { vertices.vertices = readFloatArray(input, verticesLength, scale); return vertices; } - var weights:Vector = new Vector(); - var bonesArray:Vector = new Vector(); + var weights:Array = new Array(); + var bonesArray:Array = new Array(); for (i in 0...vertexCount) { var boneCount:Int = input.readInt(true); bonesArray.push(boneCount); @@ -584,8 +582,8 @@ class SkeletonBinary { return vertices; } - private function readFloatArray(input:BinaryInput, n:Int, scale:Float):Vector { - var array:Vector = new Vector(); + private function readFloatArray(input:BinaryInput, n:Int, scale:Float):Array { + var array:Array = new Array(); if (scale == 1) { for (i in 0...n) { array.push(input.readFloat()); @@ -598,9 +596,9 @@ class SkeletonBinary { return array; } - private function readShortArray(input:BinaryInput):Vector { + private function readShortArray(input:BinaryInput):Array { var n:Int = input.readInt(true); - var array:Vector = new Vector(); + var array:Array = new Array(); for (i in 0...n) { array.push(input.readShort()); } @@ -609,7 +607,7 @@ class SkeletonBinary { private function readAnimation(input:BinaryInput, name:String, skeletonData:SkeletonData):Animation { input.readInt(true); // Count of timelines. - var timelines:Vector = new Vector(); + var timelines:Array = new Array(); var i:Int = 0, n:Int = 0, ii:Int = 0, nn:Int = 0; var index:Int, slotIndex:Int, timelineType:Int, timelineScale:Float; @@ -1042,7 +1040,7 @@ class SkeletonBinary { case ATTACHMENT_DEFORM: var vertexAttachment = cast(attachment, VertexAttachment); var weighted:Bool = vertexAttachment.bones != null; - var vertices:Vector = vertexAttachment.vertices; + var vertices:Array = vertexAttachment.vertices; var deformLength:Int = weighted ? Std.int(vertices.length / 3 * 2) : vertices.length; bezierCount = input.readInt(true); @@ -1052,17 +1050,19 @@ class SkeletonBinary { frame = 0; bezier = 0; while (true) { - var deform:Vector; + var deform:Array; var end:Int = input.readInt(true); if (end == 0) { if (weighted) { - deform = new Vector(deformLength, true); + deform = new Array(); + deform.resize(deformLength); } else { deform = vertices; } } else { var v:Int, vn:Int; - deform = new Vector(deformLength, true); + deform = new Array(); + deform.resize(deformLength); var start:Int = input.readInt(true); end += start; if (scale == 1) { @@ -1118,12 +1118,14 @@ class SkeletonBinary { for (i in 0...drawOrderCount) { time = input.readFloat(); var offsetCount:Int = input.readInt(true); - var drawOrder:Vector = new Vector(slotCount, true); + var drawOrder:Array = new Array(); + drawOrder.resize(slotCount); var ii:Int = slotCount - 1; while (ii >= 0) { drawOrder[ii--] = -1; } - var unchanged:Vector = new Vector(slotCount - offsetCount, true); + var unchanged:Array = new Array(); + unchanged.resize(slotCount - offsetCount); var originalIndex:Int = 0, unchangedIndex:Int = 0; for (ii in 0...offsetCount) { slotIndex = input.readInt(true); @@ -1245,8 +1247,8 @@ class SkeletonBinary { } class Vertices { - public var vertices:Vector = new Vector(); - public var bones:Vector = new Vector(); + public var vertices:Array = new Array(); + public var bones:Array = new Array(); public function new() {} } diff --git a/spine-haxe/spine-haxe/spine/SkeletonClipping.hx b/spine-haxe/spine-haxe/spine/SkeletonClipping.hx index 34fe49261..6289220ef 100644 --- a/spine-haxe/spine-haxe/spine/SkeletonClipping.hx +++ b/spine-haxe/spine-haxe/spine/SkeletonClipping.hx @@ -29,22 +29,21 @@ package spine; -import openfl.Vector; import spine.attachments.ClippingAttachment; class SkeletonClipping { private var triangulator:Triangulator = new Triangulator(); - private var clippingPolygon:Vector = new Vector(); - private var clipOutput:Vector = new Vector(); + private var clippingPolygon:Array = new Array(); + private var clipOutput:Array = new Array(); - public var clippedVertices:Vector = new Vector(); - public var clippedUvs:Vector = new Vector(); - public var clippedTriangles:Vector = new Vector(); + public var clippedVertices:Array = new Array(); + public var clippedUvs:Array = new Array(); + public var clippedTriangles:Array = new Array(); - private var scratch:Vector = new Vector(); + private var scratch:Array = new Array(); private var clipAttachment:ClippingAttachment; - private var clippingPolygons:Vector>; + private var clippingPolygons:Array>; public function new() {} @@ -52,7 +51,7 @@ class SkeletonClipping { if (clipAttachment != null) return 0; clipAttachment = clip; - clippingPolygon.length = clip.worldVerticesLength; + clippingPolygon.resize(clip.worldVerticesLength); clip.computeWorldVertices(slot, 0, clippingPolygon.length, clippingPolygon, 0, 2); SkeletonClipping.makeClockwise(clippingPolygon); clippingPolygons = triangulator.decompose(clippingPolygon, triangulator.triangulate(clippingPolygon)); @@ -74,23 +73,23 @@ class SkeletonClipping { return; clipAttachment = null; clippingPolygons = null; - clippedVertices.length = 0; - clippedUvs.length = 0; - clippedTriangles.length = 0; - clippingPolygon.length = 0; - clipOutput.length = 0; + clippedVertices.resize(0); + clippedUvs.resize(0); + clippedTriangles.resize(0); + clippingPolygon.resize(0); + clipOutput.resize(0); } public function isClipping():Bool { return clipAttachment != null; } - public function clipTriangles(vertices:Vector, triangles:Vector, trianglesLength:Float, uvs:Vector):Void { + public function clipTriangles(vertices:Array, triangles:Array, trianglesLength:Float, uvs:Array):Void { var polygonsCount:Int = clippingPolygons.length; var index:Int = 0; - clippedVertices.length = 0; - clippedUvs.length = 0; - clippedTriangles.length = 0; + clippedVertices.resize(0); + clippedUvs.resize(0); + clippedTriangles.resize(0); var i:Int = 0; while (i < trianglesLength) { var vertexOffset:Int = triangles[i] << 1; @@ -110,9 +109,9 @@ class SkeletonClipping { for (p in 0...polygonsCount) { var s:Int = clippedVertices.length; - var clippedVerticesItems:Vector; - var clippedUvsItems:Vector; - var clippedTrianglesItems:Vector; + var clippedVerticesItems:Array; + var clippedUvsItems:Array; + var clippedTrianglesItems:Array; if (this.clip(x1, y1, x2, y2, x3, y3, clippingPolygons[p], clipOutput)) { var clipOutputLength:Int = clipOutput.length; if (clipOutputLength == 0) @@ -124,11 +123,11 @@ class SkeletonClipping { var d:Float = 1 / (d0 * d2 + d1 * (y1 - y3)); var clipOutputCount:Int = clipOutputLength >> 1; - var clipOutputItems:Vector = clipOutput; + var clipOutputItems:Array = clipOutput; clippedVerticesItems = clippedVertices; - clippedVerticesItems.length = s + clipOutputLength; + clippedVerticesItems.resize(s + clipOutputLength); clippedUvsItems = clippedUvs; - clippedUvsItems.length = s + clipOutputLength; + clippedUvsItems.resize(s + clipOutputLength); var ii:Int = 0; while (ii < clipOutputLength) { @@ -149,7 +148,7 @@ class SkeletonClipping { s = clippedTriangles.length; clippedTrianglesItems = clippedTriangles; - clippedTrianglesItems.length = s + 3 * (clipOutputCount - 2); + clippedTrianglesItems.resize(s + 3 * (clipOutputCount - 2)); clipOutputCount--; for (ii in 1...clipOutputCount) { clippedTrianglesItems[s] = index; @@ -160,7 +159,7 @@ class SkeletonClipping { index += clipOutputCount + 1; } else { clippedVerticesItems = clippedVertices; - clippedVerticesItems.length = s + 3 * 2; + clippedVerticesItems.resize(s + 3 * 2); clippedVerticesItems[s] = x1; clippedVerticesItems[s + 1] = y1; clippedVerticesItems[s + 2] = x2; @@ -169,7 +168,7 @@ class SkeletonClipping { clippedVerticesItems[s + 5] = y3; clippedUvsItems = clippedUvs; - clippedUvsItems.length = s + 3 * 2; + clippedUvsItems.resize(s + 3 * 2); clippedUvsItems[s] = u1; clippedUvsItems[s + 1] = v1; clippedUvsItems[s + 2] = u2; @@ -179,7 +178,7 @@ class SkeletonClipping { s = clippedTriangles.length; clippedTrianglesItems = clippedTriangles; - clippedTrianglesItems.length = s + 3; + clippedTrianglesItems.resize(s + 3); clippedTrianglesItems[s] = index; clippedTrianglesItems[s + 1] = (index + 1); 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 * 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, output:Vector):Bool { - var originalOutput:Vector = output; + public function clip(x1:Float, y1:Float, x2:Float, y2:Float, x3:Float, y3:Float, clippingArea:Array, output:Array):Bool { + var originalOutput:Array = output; var clipped:Bool = false; // Avoid copy at the end. - var input:Vector = null; + var input:Array = null; if (clippingArea.length % 4 >= 2) { input = output; output = scratch; @@ -207,7 +206,7 @@ class SkeletonClipping { input = scratch; } - input.length = 0; + input.resize(0); input.push(x1); input.push(y1); input.push(x2); @@ -216,9 +215,9 @@ class SkeletonClipping { input.push(y3); input.push(x1); input.push(y1); - output.length = 0; + output.resize(0); - var clippingVertices:Vector = clippingArea; + var clippingVertices:Array = clippingArea; var clippingVerticesLast:Int = clippingArea.length - 4; var c0:Float, c2:Float, s:Float, ua:Float; var i:Int = 0; @@ -230,7 +229,7 @@ class SkeletonClipping { edgeY2:Float = clippingVertices[i + 3]; var deltaX:Float = edgeX - edgeX2, deltaY:Float = edgeY - edgeY2; - var inputVertices:Vector = input; + var inputVertices:Array = input; var inputVerticesLength:Int = input.length - 2, outputStart:Int = output.length; var ii:Int = 0; @@ -283,7 +282,7 @@ class SkeletonClipping { if (outputStart == output.length) { // All edges outside. - originalOutput.length = 0; + originalOutput.resize(0); return true; } @@ -292,29 +291,29 @@ class SkeletonClipping { if (i == clippingVerticesLast) break; - var temp:Vector = output; + var temp:Array = output; output = input; - output.length = 0; + output.resize(0); input = temp; i += 2; } if (originalOutput != output) { - originalOutput.length = 0; + originalOutput.resize(0); n = output.length - 2; for (i in 0...n) { originalOutput[i] = output[i]; } } else { - originalOutput.length = originalOutput.length - 2; + originalOutput.resize(originalOutput.length - 2); } return clipped; } - public static function makeClockwise(polygon:Vector):Void { - var vertices:Vector = polygon; + public static function makeClockwise(polygon:Array):Void { + var vertices:Array = polygon; var verticeslength:Int = polygon.length; var area:Float = vertices[verticeslength - 2] * vertices[1] - vertices[0] * vertices[verticeslength - 1]; diff --git a/spine-haxe/spine-haxe/spine/SkeletonData.hx b/spine-haxe/spine-haxe/spine/SkeletonData.hx index e7423662e..a672d45af 100644 --- a/spine-haxe/spine-haxe/spine/SkeletonData.hx +++ b/spine-haxe/spine-haxe/spine/SkeletonData.hx @@ -29,7 +29,6 @@ package spine; -import openfl.Vector; import openfl.utils.Assets; import spine.animation.Animation; import spine.atlas.TextureAtlas; @@ -39,15 +38,15 @@ class SkeletonData { /** May be null. */ public var name:String; - public var bones:Vector = new Vector(); // Ordered parents first. - public var slots:Vector = new Vector(); // Setup pose draw order. - public var skins:Vector = new Vector(); + public var bones:Array = new Array(); // Ordered parents first. + public var slots:Array = new Array(); // Setup pose draw order. + public var skins:Array = new Array(); public var defaultSkin:Skin; - public var events:Vector = new Vector(); - public var animations:Vector = new Vector(); - public var ikConstraints:Vector = new Vector(); - public var transformConstraints:Vector = new Vector(); - public var pathConstraints:Vector = new Vector(); + public var events:Array = new Array(); + public var animations:Array = new Array(); + public var ikConstraints:Array = new Array(); + public var transformConstraints:Array = new Array(); + public var pathConstraints:Array = new Array(); public var x:Float = 0; public var y:Float = 0; public var width:Float = 0; diff --git a/spine-haxe/spine-haxe/spine/SkeletonJson.hx b/spine-haxe/spine-haxe/spine/SkeletonJson.hx index a7c849eab..28de8ca3d 100644 --- a/spine-haxe/spine-haxe/spine/SkeletonJson.hx +++ b/spine-haxe/spine-haxe/spine/SkeletonJson.hx @@ -31,8 +31,6 @@ package spine; import Reflect; import haxe.Json; -import openfl.Vector; -import openfl.utils.Object; import spine.animation.AlphaTimeline; import spine.animation.Animation; import spine.animation.AttachmentTimeline; @@ -78,7 +76,7 @@ class SkeletonJson { public var attachmentLoader:AttachmentLoader; public var scale:Float = 1; - private var linkedMeshes:Vector = new Vector(); + private var linkedMeshes:Array = new Array(); public function new(attachmentLoader:AttachmentLoader) { this.attachmentLoader = attachmentLoader; @@ -93,7 +91,7 @@ class SkeletonJson { var skeletonData:SkeletonData = new SkeletonData(); // Skeleton. - var skeletonMap:Object = getString(root, "skeleton", ""); + var skeletonMap = getString(root, "skeleton", ""); if (skeletonMap != null) { skeletonData.hash = getString(skeletonMap, "hash", ""); skeletonData.version = getString(skeletonMap, "spine", ""); @@ -318,11 +316,11 @@ class SkeletonJson { } if (Reflect.hasField(skinMap, "attachments")) { - var attachments:Object = Reflect.getProperty(skinMap, "attachments"); - for (slotName in attachments) { + var attachments:Dynamic = Reflect.getProperty(skinMap, "attachments"); + for (slotName in Reflect.fields(attachments)) { var slot:SlotData = skeletonData.findSlot(slotName); - var slotEntry:Object = Reflect.getProperty(attachments, slotName); - for (attachmentName in slotEntry) { + var slotEntry:Dynamic = Reflect.getProperty(attachments, slotName); + for (attachmentName in Reflect.fields(slotEntry)) { var attachment:Attachment = readAttachment(Reflect.getProperty(slotEntry, attachmentName), skin, slot.index, attachmentName, skeletonData); if (attachment != null) { @@ -352,12 +350,12 @@ class SkeletonJson { if (linkedMesh.mesh.region != null) linkedMesh.mesh.updateRegion(); } - linkedMeshes.length = 0; + linkedMeshes.resize(0); // Events. - var events:Object = Reflect.getProperty(root, "events"); - for (eventName in events) { - var eventMap:Map = events[eventName]; + var events:Dynamic = Reflect.getProperty(root, "events"); + for (eventName in Reflect.fields(events)) { + var eventMap:Map = Reflect.field(events, eventName); var eventData:EventData = new EventData(eventName); eventData.intValue = getInt(eventMap, "int"); eventData.floatValue = getFloat(eventMap, "float"); @@ -371,14 +369,14 @@ class SkeletonJson { } // Animations. - var animations:Object = Reflect.getProperty(root, "animations"); - for (animationName in animations) { - readAnimation(animations[animationName], animationName, skeletonData); + var animations:Dynamic = Reflect.getProperty(root, "animations"); + for (animationName in Reflect.fields(animations)) { + readAnimation(Reflect.field(animations, animationName), animationName, skeletonData); } return skeletonData; } - private function readSequence(map:Object) { + private function readSequence(map:Dynamic) { if (map == null) return null; var sequence = new Sequence(getInt(map, "count", 0)); @@ -388,15 +386,15 @@ class SkeletonJson { return sequence; } - private function readAttachment(map:Object, skin:Skin, slotIndex:Int, name:String, skeletonData:SkeletonData):Attachment { - if (map["name"] != null) - name = map["name"]; + private function readAttachment(map:Dynamic, skin:Skin, slotIndex:Int, name:String, skeletonData:SkeletonData):Attachment { + if (Reflect.field(map, "name") != null) + name = Reflect.field(map, "name"); var color:String; switch (AttachmentType.fromName(Reflect.hasField(map, "type") ? Reflect.getProperty(map, "type") : "region")) { case AttachmentType.region: 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); if (region == null) return null; @@ -419,7 +417,7 @@ class SkeletonJson { return region; case AttachmentType.mesh, AttachmentType.linkedmesh: 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); if (mesh == null) return null; @@ -434,20 +432,20 @@ class SkeletonJson { mesh.height = getFloat(map, "height") * scale; mesh.sequence = sequence; - if (map["parent"] != null) { - var inheritTimelines:Bool = map.hasOwnProperty("timelines") ? cast(map["timelines"], Bool) : true; - linkedMeshes.push(new LinkedMesh(mesh, map["skin"], slotIndex, map["parent"], inheritTimelines)); + if (Reflect.field(map, "parent") != null) { + var inheritTimelines:Bool = map.hasOwnProperty("timelines") ? cast(Reflect.field(map, "timelines"), Bool) : true; + linkedMeshes.push(new LinkedMesh(mesh, Reflect.field(map, "skin"), slotIndex, Reflect.field(map, "parent"), inheritTimelines)); return mesh; } - var uvs:Vector = getFloatArray(map, "uvs"); + var uvs:Array = getFloatArray(map, "uvs"); readVertices(map, mesh, uvs.length); mesh.triangles = getIntArray(map, "triangles"); mesh.regionUVs = uvs; if (mesh.region != null) mesh.updateRegion(); - if (map["edges"] != null) + if (Reflect.field(map, "edges") != null) mesh.edges = getIntArray(map, "edges"); mesh.hullLength = getInt(map, "hull") * 2; return mesh; @@ -455,18 +453,18 @@ class SkeletonJson { var box:BoundingBoxAttachment = attachmentLoader.newBoundingBoxAttachment(skin, name); if (box == null) return null; - readVertices(map, box, Std.parseInt(map["vertexCount"]) << 1); + readVertices(map, box, Std.parseInt(Reflect.field(map, "vertexCount")) << 1); return box; case AttachmentType.path: var path:PathAttachment = attachmentLoader.newPathAttachment(skin, name); if (path == null) return null; - path.closed = map.hasOwnProperty("closed") ? cast(map["closed"], Bool) : false; - path.constantSpeed = map.hasOwnProperty("constantSpeed") ? cast(map["constantSpeed"], Bool) : true; - var vertexCount:Int = Std.parseInt(map["vertexCount"]); + path.closed = map.hasOwnProperty("closed") ? cast(Reflect.field(map, "closed"), Bool) : false; + path.constantSpeed = map.hasOwnProperty("constantSpeed") ? cast(Reflect.field(map, "constantSpeed"), Bool) : true; + var vertexCount:Int = Std.parseInt(Reflect.field(map, "vertexCount")); readVertices(map, path, vertexCount << 1); - var lengths:Vector = new Vector(); - for (curves in cast(map["lengths"], Array)) { + var lengths:Array = new Array(); + for (curves in cast(Reflect.field(map, "lengths"), Array)) { lengths.push(Std.parseFloat(curves) * scale); } path.lengths = lengths; @@ -475,9 +473,9 @@ class SkeletonJson { var point:PointAttachment = attachmentLoader.newPointAttachment(skin, name); if (point == null) return null; - point.x = map.hasOwnProperty("x") ? Std.parseFloat(map["x"]) * scale : 0; - point.y = map.hasOwnProperty("y") ? Std.parseFloat(map["y"]) * scale : 0; - point.rotation = map.hasOwnProperty("rotation") ? Std.parseFloat(map["rotation"]) : 0; + point.x = getFloat(map, "x", 0) * scale; + point.y = getFloat(map, "y", 0) * scale; + point.rotation = getFloat(map, "rotation", 0); color = Reflect.getProperty(map, "color"); if (color != null) { point.color.setFromString(color); @@ -487,14 +485,14 @@ class SkeletonJson { var clip:ClippingAttachment = attachmentLoader.newClippingAttachment(skin, name); if (clip == null) return null; - var end:String = map["end"]; + var end:String = getString(map, "end", null); if (end != null) { var slot:SlotData = skeletonData.findSlot(end); if (slot == null) throw new SpineException("Clipping end slot not found: " + end); clip.endSlot = slot; } - var vertexCount:Int = Std.parseInt(map["vertexCount"]); + var vertexCount:Int = getInt(map, "vertexCount", 0); readVertices(map, clip, vertexCount << 1); color = Reflect.getProperty(map, "color"); if (color != null) { @@ -505,9 +503,9 @@ class SkeletonJson { 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; - var vertices:Vector = getFloatArray(map, "vertices"); + var vertices:Array = getFloatArray(map, "vertices"); if (verticesLength == vertices.length) { if (scale != 1) { for (i in 0...vertices.length) { @@ -518,8 +516,8 @@ class SkeletonJson { return; } - var weights:Vector = new Vector(); - var bones:Vector = new Vector(); + var weights:Array = new Array(); + var bones:Array = new Array(); var i:Int = 0; var n:Int = vertices.length; while (i < n) { @@ -539,28 +537,28 @@ class SkeletonJson { attachment.vertices = weights; } - private function readAnimation(map:Object, name:String, skeletonData:SkeletonData):Void { - var timelines:Vector = new Vector(); + private function readAnimation(map:Dynamic, name:String, skeletonData:SkeletonData):Void { + var timelines:Array = new Array(); - var slotMap:Object; + var slotMap:Dynamic; var slotIndex:Int; var slotName:String; - var timelineMap:Array; - var keyMap:Object; - var nextMap:Object; + var timelineMap:Array; + var keyMap:Dynamic; + var nextMap:Dynamic; var frame:Int, bezier:Int; var time:Float, time2:Float; - var curve:Object; + var curve:Dynamic; var timelineName:String; // Slot timelines. - var slots:Object = Reflect.getProperty(map, "slots"); - for (slotName in slots) { - slotMap = slots[slotName]; + var slots:Dynamic = Reflect.getProperty(map, "slots"); + for (slotName in Reflect.fields(slots)) { + slotMap = Reflect.field(slots, slotName); slotIndex = skeletonData.findSlot(slotName).index; - for (timelineName in slotMap) { - timelineMap = slotMap[timelineName]; + for (timelineName in Reflect.fields(slotMap)) { + timelineMap = Reflect.field(slotMap, timelineName); if (timelineMap == null) continue; if (timelineName == "attachment") { @@ -721,14 +719,14 @@ class SkeletonJson { } // Bone timelines. - var bones:Object = Reflect.getProperty(map, "bones"); - for (boneName in bones) { + var bones:Dynamic = Reflect.getProperty(map, "bones"); + for (boneName in Reflect.fields(bones)) { var boneIndex:Int = skeletonData.findBoneIndex(boneName); if (boneIndex == -1) throw new SpineException("Bone not found: " + boneName); - var boneMap:Object = bones[boneName]; - for (timelineName in boneMap) { - timelineMap = boneMap[timelineName]; + var boneMap:Dynamic = Reflect.field(bones, boneName); + for (timelineName in Reflect.fields(boneMap)) { + timelineMap = Reflect.field(boneMap, timelineName); if (timelineMap.length == 0) continue; @@ -768,9 +766,9 @@ class SkeletonJson { } // IK constraint timelines. - var iks:Object = Reflect.getProperty(map, "ik"); - for (ikConstraintName in iks) { - timelineMap = iks[ikConstraintName]; + var iks:Dynamic = Reflect.getProperty(map, "ik"); + for (ikConstraintName in Reflect.fields(iks)) { + timelineMap = Reflect.field(iks, ikConstraintName); keyMap = timelineMap[0]; if (keyMap == null) continue; @@ -819,9 +817,9 @@ class SkeletonJson { var mixRotate:Float, mixRotate2:Float; var mixX:Float, mixX2:Float; var mixY:Float, mixY2:Float; - var transforms:Object = Reflect.getProperty(map, "transform"); - for (transformName in transforms) { - timelineMap = transforms[transformName]; + var transforms:Dynamic = Reflect.getProperty(map, "transform"); + for (transformName in Reflect.fields(transforms)) { + timelineMap = Reflect.field(transforms, transformName); keyMap = timelineMap[0]; if (keyMap == null) continue; @@ -879,16 +877,16 @@ class SkeletonJson { } // Path constraint timelines. - var paths:Object = Reflect.getProperty(map, "path"); - for (pathName in paths) { + var paths:Dynamic = Reflect.getProperty(map, "path"); + for (pathName in Reflect.fields(paths)) { var index:Int = skeletonData.findPathConstraintIndex(pathName); if (index == -1) throw new SpineException("Path constraint not found: " + pathName); var pathData:PathConstraintData = skeletonData.pathConstraints[index]; - var pathMap:Object = paths[pathName]; - for (timelineName in pathMap) { - timelineMap = pathMap[timelineName]; + var pathMap:Dynamic = Reflect.field(paths, pathName); + for (timelineName in Reflect.fields(pathMap)) { + timelineMap = Reflect.field(pathMap, timelineName); keyMap = timelineMap[0]; if (keyMap == null) continue; @@ -941,26 +939,26 @@ class SkeletonJson { } // Attachment timelines. - var attachments:Object = Reflect.getProperty(map, "attachments"); - for (attachmentsName in attachments) { - var attachmentsMap:Object = attachments[attachmentsName]; + var attachments:Dynamic = Reflect.getProperty(map, "attachments"); + for (attachmentsName in Reflect.fields(attachments)) { + var attachmentsMap:Dynamic = Reflect.field(attachments, attachmentsName); var skin:Skin = skeletonData.findSkin(attachmentsName); if (skin == null) throw new SpineException("Skin not found: " + attachmentsName); - for (slotMapName in attachmentsMap) { - slotMap = attachmentsMap[slotMapName]; + for (slotMapName in Reflect.fields(attachmentsMap)) { + slotMap = Reflect.field(attachmentsMap, slotMapName); slotIndex = skeletonData.findSlot(slotMapName).index; if (slotIndex == -1) throw new SpineException("Slot not found: " + slotMapName); - for (attachmentMapName in slotMap) { - var attachmentMap = slotMap[attachmentMapName]; + for (attachmentMapName in Reflect.fields(slotMap)) { + var attachmentMap = Reflect.field(slotMap, attachmentMapName); var attachment:Attachment = skin.getAttachment(slotIndex, attachmentMapName); if (attachment == null) throw new SpineException("Timeline attachment not found: " + attachmentMapName); - for (timelineMapName in attachmentMap) { - var timelineMap = attachmentMap[timelineMapName]; + for (timelineMapName in Reflect.fields(attachmentMap)) { + var timelineMap = Reflect.field(attachmentMap, timelineMapName); var keyMap = timelineMap[0]; if (keyMap == null) continue; @@ -968,7 +966,7 @@ class SkeletonJson { if (timelineMapName == "deform") { var vertexAttachment = cast(attachment, VertexAttachment); var weighted:Bool = vertexAttachment.bones != null; - var vertices:Vector = vertexAttachment.vertices; + var vertices:Array = vertexAttachment.vertices; var deformLength:Int = weighted ? Std.int(vertices.length / 3 * 2) : vertices.length; var deformTimeline:DeformTimeline = new DeformTimeline(timelineMap.length, timelineMap.length, slotIndex, vertexAttachment); @@ -976,14 +974,20 @@ class SkeletonJson { frame = 0; bezier = 0; while (true) { - var deform:Vector; - var verticesValue:Vector = Reflect.getProperty(keyMap, "vertices"); + var deform:Array; + var verticesValue:Array = Reflect.getProperty(keyMap, "vertices"); if (verticesValue == null) { - deform = weighted ? new Vector(deformLength, true) : vertices; + if (weighted) { + deform = new Array(); + deform.resize(deformLength); + } else { + deform = vertices; + } } else { - deform = new Vector(deformLength, true); + deform = new Array(); + deform.resize(deformLength); var start:Int = getInt(keyMap, "offset"); - var temp:Vector = getFloatArray(keyMap, "vertices"); + var temp:Array = getFloatArray(keyMap, "vertices"); for (i in 0...temp.length) { deform[start + i] = temp[i]; } @@ -1040,21 +1044,23 @@ class SkeletonJson { // Draw order timelines. if (Reflect.hasField(map, "drawOrder")) { - var drawOrders:Array = cast(map["drawOrder"], Array); + var drawOrders:Array = cast(Reflect.field(map, "drawOrder"), Array); if (drawOrders != null) { var drawOrderTimeline:DrawOrderTimeline = new DrawOrderTimeline(drawOrders.length); var slotCount:Int = skeletonData.slots.length; frame = 0; for (drawOrderMap in drawOrders) { - var drawOrder:Vector = null; + var drawOrder:Array = null; var offsets:Array = Reflect.getProperty(drawOrderMap, "offsets"); if (offsets != null) { - drawOrder = new Vector(slotCount, true); + drawOrder = new Array(); + drawOrder.resize(slotCount); var i = slotCount - 1; while (i >= 0) { drawOrder[i--] = -1; } - var unchanged:Vector = new Vector(slotCount - offsets.length, true); + var unchanged:Array = new Array(); + unchanged.resize(slotCount - offsets.length); var originalIndex:Int = 0, unchangedIndex:Int = 0; for (offsetMap in offsets) { slotIndex = skeletonData.findSlot(Reflect.getProperty(offsetMap, "slot")).index; @@ -1087,7 +1093,7 @@ class SkeletonJson { // Event timelines. if (Reflect.hasField(map, "events")) { - var eventsMap:Array = cast(map["events"], Array); + var eventsMap:Array = cast(Reflect.field(map, "events"), Array); if (eventsMap != null) { var eventTimeline:EventTimeline = new EventTimeline(eventsMap.length); frame = 0; @@ -1120,21 +1126,21 @@ class SkeletonJson { } static private function readTimeline(keys:Array, timeline:CurveTimeline1, defaultValue:Float, scale:Float):CurveTimeline1 { - var keyMap:Object = keys[0]; + var keyMap:Dynamic = keys[0]; var time:Float = getFloat(keyMap, "time"); var value:Float = getFloat(keyMap, "value", defaultValue) * scale; var bezier:Int = 0; var frame:Int = 0; while (true) { timeline.setFrame(frame, time, value); - var nextMap:Object = keys[frame + 1]; + var nextMap:Dynamic = keys[frame + 1]; if (nextMap == null) { timeline.shrink(bezier); break; } var time2:Float = getFloat(nextMap, "time"); var value2:Float = getFloat(nextMap, "value", defaultValue) * scale; - var curve:Object = keyMap.curve; + var curve:Dynamic = keyMap.curve; if (curve != null) { bezier = readCurve(curve, timeline, bezier, frame, 0, time, time2, value, value2, scale); } @@ -1149,7 +1155,7 @@ class SkeletonJson { static private function readTimeline2(keys:Array, timeline:CurveTimeline2, name1:String, name2:String, defaultValue:Float, scale:Float):CurveTimeline2 { - var keyMap:Object = keys[0]; + var keyMap:Dynamic = keys[0]; var time:Float = getFloat(keyMap, "time"); var value1:Float = getFloat(keyMap, name1, defaultValue) * scale; var value2:Float = getFloat(keyMap, name2, defaultValue) * scale; @@ -1157,7 +1163,7 @@ class SkeletonJson { var frame:Int = 0; while (true) { timeline.setFrame(frame, time, value1, value2); - var nextMap:Object = keys[frame + 1]; + var nextMap:Dynamic = keys[frame + 1]; if (nextMap == null) { timeline.shrink(bezier); break; @@ -1165,7 +1171,7 @@ class SkeletonJson { var time2:Float = getFloat(nextMap, "time"); var nvalue1:Float = getFloat(nextMap, name1, defaultValue) * scale; var nvalue2:Float = getFloat(nextMap, name2, defaultValue) * scale; - var curve:Object = keyMap.curve; + var curve:Dynamic = keyMap.curve; if (curve != null) { bezier = readCurve(curve, timeline, bezier, frame, 0, time, time2, value1, nvalue1, scale); bezier = readCurve(curve, timeline, bezier, frame, 1, time, time2, value2, nvalue2, scale); @@ -1180,7 +1186,7 @@ class SkeletonJson { 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 { if (curve == "stepped") { timeline.setStepped(frame); @@ -1196,42 +1202,44 @@ class SkeletonJson { 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)) - return map[name]; + return Reflect.field(map, name); return defaultValue; } - static private function getString(value:Object, name:String, defaultValue:String):String { - if (Std.isOfType(value[name], String)) - return cast(value[name], String); + static private function getString(value:Dynamic, name:String, defaultValue:String):String { + if (Std.isOfType(Reflect.field(value, name), String)) + return cast(Reflect.field(value, name), String); return defaultValue; } - static private function getFloat(value:Object, name:String, defaultValue:Float = 0):Float { - if (Std.isOfType(value[name], Float)) - return cast(value[name], Float); + static private function getFloat(value:Dynamic, name:String, defaultValue:Float = 0):Float { + if (Std.isOfType(Reflect.field(value, name), Float)) + return cast(Reflect.field(value, name), Float); return defaultValue; } - static private function getFloatArray(map:Object, name:String):Vector { - var list:Array = cast(map[name], Array); - var values:Vector = new Vector(list.length, true); + static private function getFloatArray(map:Dynamic, name:String):Array { + var list:Array = cast(Reflect.field(map, name), Array); + var values:Array = new Array(); + values.resize(list.length); for (i in 0...list.length) { values[i] = cast(list[i], Float); } return values; } - static private function getInt(value:Object, name:String, defaultValue:Int = 0):Int { - if (Std.isOfType(value[name], Int)) - return cast(value[name], Int); + static private function getInt(value:Dynamic, name:String, defaultValue:Int = 0):Int { + if (Std.isOfType(Reflect.field(value, name), Int)) + return cast(Reflect.field(value, name), Int); return defaultValue; } - static private function getIntArray(map:Object, name:String):Vector { - var list:Array = cast(map[name], Array); - var values:Vector = new Vector(list.length, true); + static private function getIntArray(map:Dynamic, name:String):Array { + var list:Array = cast(Reflect.field(map, name), Array); + var values:Array = new Array(); + values.resize(list.length); for (i in 0...list.length) { values[i] = Std.int(list[i]); } diff --git a/spine-haxe/spine-haxe/spine/Skin.hx b/spine-haxe/spine-haxe/spine/Skin.hx index f78d4ef5b..74613f6cc 100644 --- a/spine-haxe/spine-haxe/spine/Skin.hx +++ b/spine-haxe/spine-haxe/spine/Skin.hx @@ -29,17 +29,16 @@ package spine; -import openfl.utils.Dictionary; -import openfl.Vector; +import haxe.ds.StringMap; import spine.attachments.Attachment; import spine.attachments.MeshAttachment; /** Stores attachments by slot index and attachment name. */ class Skin { private var _name:String; - private var _attachments:Vector> = new Vector>(); - private var _bones:Vector = new Vector(); - private var _constraints:Vector = new Vector(); + private var _attachments:Array> = new Array>(); + private var _bones:Array = new Array(); + private var _constraints:Array = new Array(); public function new(name:String) { if (name == null) @@ -51,10 +50,10 @@ class Skin { if (attachment == null) throw new SpineException("attachment cannot be null."); if (slotIndex >= _attachments.length) - _attachments.length = slotIndex + 1; + _attachments.resize(slotIndex + 1); if (_attachments[slotIndex] == null) - _attachments[slotIndex] = new Dictionary(); - _attachments[slotIndex][name] = attachment; + _attachments[slotIndex] = new StringMap(); + _attachments[slotIndex].set(name, attachment); } public function addSkin(skin:Skin):Void { @@ -85,7 +84,7 @@ class Skin { _constraints.push(constraint); } - var attachments:Vector = skin.getAttachments(); + var attachments:Array = skin.getAttachments(); for (i in 0...attachments.length) { var attachment:SkinEntry = attachments[i]; setAttachment(attachment.slotIndex, attachment.name, attachment.attachment); @@ -122,7 +121,7 @@ class Skin { _constraints.push(constraint); } - var attachments:Vector = skin.getAttachments(); + var attachments:Array = skin.getAttachments(); for (i in 0...attachments.length) { attachment = attachments[i]; if (attachment.attachment == null) @@ -141,23 +140,23 @@ class Skin { public function getAttachment(slotIndex:Int, name:String):Attachment { if (slotIndex >= _attachments.length) return null; - var dictionary:Dictionary = _attachments[slotIndex]; - return dictionary != null ? dictionary[name] : null; + var dictionary:StringMap = _attachments[slotIndex]; + return dictionary != null ? dictionary.get(name) : null; } public function removeAttachment(slotIndex:Int, name:String):Void { - var dictionary:Dictionary = _attachments[slotIndex]; + var dictionary:StringMap = _attachments[slotIndex]; if (dictionary != null) dictionary.remove(name); } - public function getAttachments():Vector { - var entries:Vector = new Vector(); + public function getAttachments():Array { + var entries:Array = new Array(); for (slotIndex in 0..._attachments.length) { - var attachments:Dictionary = _attachments[slotIndex]; + var attachments:StringMap = _attachments[slotIndex]; if (attachments != null) { - for (name in attachments.iterator()) { - var attachment:Attachment = attachments[name]; + for (name in attachments.keys()) { + var attachment:Attachment = attachments.get(name); if (attachment != null) entries.push(new SkinEntry(slotIndex, name, attachment)); } @@ -166,12 +165,12 @@ class Skin { return entries; } - public function getAttachmentsForSlot(slotIndex:Int):Vector { - var entries:Vector = new Vector(); - var attachments:Dictionary = _attachments[slotIndex]; + public function getAttachmentsForSlot(slotIndex:Int):Array { + var entries:Array = new Array(); + var attachments:StringMap = _attachments[slotIndex]; if (attachments != null) { - for (name in attachments.iterator()) { - var attachment:Attachment = attachments[name]; + for (name in attachments.keys()) { + var attachment:Attachment = attachments.get(name); if (attachment != null) entries.push(new SkinEntry(slotIndex, name, attachment)); } @@ -180,26 +179,26 @@ class Skin { } public function clear():Void { - _attachments.length = 0; - _bones.length = 0; - _constraints.length = 0; + _attachments.resize(0); + _bones.resize(0); + _constraints.resize(0); } - public var attachments(get, never):Vector>; + public var attachments(get, never):Array>; - private function get_attachments():Vector> { + private function get_attachments():Array> { return _attachments; } - public var bones(get, never):Vector; + public var bones(get, never):Array; - private function get_bones():Vector { + private function get_bones():Array { return _bones; } - public var constraints(get, never):Vector; + public var constraints(get, never):Array; - private function get_constraints():Vector { + private function get_constraints():Array { return _constraints; } @@ -221,9 +220,9 @@ class Skin { for (slot in skeleton.slots) { var slotAttachment:Attachment = slot.attachment; if (slotAttachment != null && slotIndex < oldSkin.attachments.length) { - var dictionary:Dictionary = oldSkin.attachments[slotIndex]; - for (name in dictionary) { - var skinAttachment:Attachment = dictionary[name]; + var dictionary:StringMap = oldSkin.attachments[slotIndex]; + for (name in dictionary.keys()) { + var skinAttachment:Attachment = dictionary.get(name); if (slotAttachment == skinAttachment) { var attachment:Attachment = getAttachment(slotIndex, name); if (attachment != null) diff --git a/spine-haxe/spine-haxe/spine/Slot.hx b/spine-haxe/spine-haxe/spine/Slot.hx index dcc750fd7..55ed96968 100644 --- a/spine-haxe/spine-haxe/spine/Slot.hx +++ b/spine-haxe/spine-haxe/spine/Slot.hx @@ -29,7 +29,6 @@ package spine; -import openfl.Vector; import spine.attachments.Attachment; import spine.attachments.VertexAttachment; @@ -45,7 +44,7 @@ class Slot { public var sequenceIndex = -1; public var attachmentState:Int = 0; - public var deform:Vector = new Vector(); + public var deform:Array = new Array(); public function new(data:SlotData, bone:Bone) { if (data == null) @@ -93,7 +92,7 @@ class Slot { if (!Std.isOfType(attachmentNew, VertexAttachment) || !Std.isOfType(attachment, VertexAttachment) || cast(attachmentNew, VertexAttachment).timelineAttachment != cast(attachment, VertexAttachment).timelineAttachment) { - deform = new Vector(); + deform = new Array(); } _attachment = attachmentNew; sequenceIndex = -1; diff --git a/spine-haxe/spine-haxe/spine/SpacingMode.hx b/spine-haxe/spine-haxe/spine/SpacingMode.hx index 6021addd7..2fa38a1d8 100644 --- a/spine-haxe/spine-haxe/spine/SpacingMode.hx +++ b/spine-haxe/spine-haxe/spine/SpacingMode.hx @@ -29,15 +29,13 @@ package spine; -import openfl.Vector; - class SpacingMode { public static var length(default, never):SpacingMode = new SpacingMode("length"); public static var fixed(default, never):SpacingMode = new SpacingMode("fixed"); public static var percent(default, never):SpacingMode = new SpacingMode("percent"); public static var proportional(default, never):SpacingMode = new SpacingMode("proportional"); - public static var values(default, never):Vector = Vector.ofArray([length, fixed, percent, proportional]); + public static var values(default, never):Array = [length, fixed, percent, proportional]; public var name(default, null):String; diff --git a/spine-haxe/spine-haxe/spine/TransformConstraint.hx b/spine-haxe/spine-haxe/spine/TransformConstraint.hx index a4fdfea77..0ecb794ab 100644 --- a/spine-haxe/spine-haxe/spine/TransformConstraint.hx +++ b/spine-haxe/spine-haxe/spine/TransformConstraint.hx @@ -29,11 +29,9 @@ package spine; -import openfl.Vector; - class TransformConstraint implements Updatable { private var _data:TransformConstraintData; - private var _bones:Vector; + private var _bones:Array; public var target:Bone; public var mixRotate:Float = 0; @@ -43,7 +41,7 @@ class TransformConstraint implements Updatable { public var mixScaleY:Float = 0; public var mixShearY:Float = 0; - private var _temp:Vector = new Vector(2, true); + private var _temp:Array = new Array(); public var active:Bool = false; @@ -59,7 +57,7 @@ class TransformConstraint implements Updatable { mixScaleX = data.mixScaleX; mixScaleY = data.mixScaleY; mixShearY = data.mixShearY; - _bones = new Vector(); + _bones = new Array(); for (boneData in data.bones) { _bones.push(skeleton.findBone(boneData.name)); } @@ -187,7 +185,7 @@ class TransformConstraint implements Updatable { } if (translate) { - var temp:Vector = _temp; + var temp:Array = _temp; temp[0] = _data.offsetX; temp[1] = _data.offsetY; target.localToWorld(temp); @@ -275,9 +273,9 @@ class TransformConstraint implements Updatable { return _data; } - public var bones(get, never):Vector; + public var bones(get, never):Array; - private function get_bones():Vector { + private function get_bones():Array { return _bones; } diff --git a/spine-haxe/spine-haxe/spine/TransformConstraintData.hx b/spine-haxe/spine-haxe/spine/TransformConstraintData.hx index f168fd1ac..086374492 100644 --- a/spine-haxe/spine-haxe/spine/TransformConstraintData.hx +++ b/spine-haxe/spine-haxe/spine/TransformConstraintData.hx @@ -29,10 +29,8 @@ package spine; -import openfl.Vector; - class TransformConstraintData extends ConstraintData { - private var _bones:Vector = new Vector(); + private var _bones:Array = new Array(); public var target:BoneData; public var mixRotate:Float = 0; @@ -54,9 +52,9 @@ class TransformConstraintData extends ConstraintData { super(name, 0, false); } - public var bones(get, never):Vector; + public var bones(get, never):Array; - private function get_bones():Vector { + private function get_bones():Array { return _bones; } } diff --git a/spine-haxe/spine-haxe/spine/TransformMode.hx b/spine-haxe/spine-haxe/spine/TransformMode.hx index 626935e83..b0bd340de 100644 --- a/spine-haxe/spine-haxe/spine/TransformMode.hx +++ b/spine-haxe/spine-haxe/spine/TransformMode.hx @@ -29,8 +29,6 @@ package spine; -import openfl.Vector; - class TransformMode { public static var normal(default, never):TransformMode = new TransformMode("normal"); 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 noScaleOrReflection(default, never):TransformMode = new TransformMode("noScaleOrReflection"); - public static var values:Vector = Vector.ofArray([normal, onlyTranslation, noRotationOrReflection, noScale, noScaleOrReflection]); + public static var values:Array = [normal, onlyTranslation, noRotationOrReflection, noScale, noScaleOrReflection]; public var name(default, null):String; diff --git a/spine-haxe/spine-haxe/spine/Triangulator.hx b/spine-haxe/spine-haxe/spine/Triangulator.hx index 8d96561d6..abdc908af 100644 --- a/spine-haxe/spine-haxe/spine/Triangulator.hx +++ b/spine-haxe/spine-haxe/spine/Triangulator.hx @@ -29,37 +29,35 @@ package spine; -import openfl.Vector; - class Triangulator { - private var convexPolygons:Vector> = new Vector>(); - private var convexPolygonsIndices:Vector> = new Vector>(); - private var indicesArray:Vector = new Vector(); - private var isConcaveArray:Vector = new Vector(); - private var triangles:Vector = new Vector(); - private var polygonPool:Pool> = new Pool(function():Dynamic { - return new Vector(); + private var convexPolygons:Array> = new Array>(); + private var convexPolygonsIndices:Array> = new Array>(); + private var indicesArray:Array = new Array(); + private var isConcaveArray:Array = new Array(); + private var triangles:Array = new Array(); + private var polygonPool:Pool> = new Pool(function():Dynamic { + return new Array(); }); - private var polygonIndicesPool:Pool> = new Pool(function():Dynamic { - return new Vector(); + private var polygonIndicesPool:Pool> = new Pool(function():Dynamic { + return new Array(); }); public function new() {} - public function triangulate(vertices:Vector):Vector { + public function triangulate(vertices:Array):Array { var vertexCount:Int = vertices.length >> 1; - indicesArray.length = 0; + indicesArray.resize(0); for (i in 0...vertexCount) { indicesArray.push(i); } - isConcaveArray.length = 0; + isConcaveArray.resize(0); for (i in 0...vertexCount) { isConcaveArray.push(isConcave(i, vertexCount, vertices, indicesArray)); } - triangles.length = 0; + triangles.resize(0); while (vertexCount > 3) { // Find ear tip. @@ -131,22 +129,22 @@ class Triangulator { return triangles; } - public function decompose(vertices:Vector, triangles:Vector):Vector> { + public function decompose(vertices:Array, triangles:Array):Array> { for (i in 0...convexPolygons.length) { this.polygonPool.free(convexPolygons[i]); } - convexPolygons.length = 0; + convexPolygons.resize(0); for (i in 0...convexPolygonsIndices.length) { this.polygonIndicesPool.free(convexPolygonsIndices[i]); } - convexPolygonsIndices.length = 0; + convexPolygonsIndices.resize(0); - var polygonIndices:Vector = polygonIndicesPool.obtain(); - polygonIndices.length = 0; + var polygonIndices:Array = polygonIndicesPool.obtain(); + polygonIndices.resize(0); - var polygon:Vector = polygonPool.obtain(); - polygon.length = 0; + var polygon:Array = polygonPool.obtain(); + polygon.resize(0); // Merge subsequent triangles if they form a triangle fan. var fanBaseIndex:Int = -1, lastWinding:Int = 0; @@ -188,7 +186,7 @@ class Triangulator { polygonIndicesPool.free(polygonIndices); } polygon = polygonPool.obtain(); - polygon.length = 0; + polygon.resize(0); polygon.push(x1); polygon.push(y1); polygon.push(x2); @@ -196,7 +194,7 @@ class Triangulator { polygon.push(x3); polygon.push(y3); polygonIndices = polygonIndicesPool.obtain(); - polygonIndices.length = 0; + polygonIndices.resize(0); polygonIndices.push(t1); polygonIndices.push(t2); polygonIndices.push(t3); @@ -238,7 +236,7 @@ class Triangulator { ii++; continue; } - var otherIndices:Vector = convexPolygonsIndices[ii]; + var otherIndices:Array = convexPolygonsIndices[ii]; if (otherIndices.length != 3) { ii++; continue; @@ -247,7 +245,7 @@ class Triangulator { var otherSecondIndex:Int = otherIndices[1]; var otherLastIndex:Int = otherIndices[2]; - var otherPoly:Vector = convexPolygons[ii]; + var otherPoly:Array = convexPolygons[ii]; x3 = otherPoly[otherPoly.length - 2]; y3 = otherPoly[otherPoly.length - 1]; @@ -258,8 +256,8 @@ class Triangulator { winding1 = Triangulator.winding(prevPrevX, prevPrevY, prevX, prevY, x3, y3); winding2 = Triangulator.winding(x3, y3, firstX, firstY, secondX, secondY); if (winding1 == currWinding && winding2 == currWinding) { - otherPoly.length = 0; - otherIndices.length = 0; + otherPoly.resize(0); + otherIndices.resize(0); polygon.push(x3); polygon.push(y3); polygonIndices.push(otherLastIndex); @@ -294,7 +292,7 @@ class Triangulator { return convexPolygons; } - private static function isConcave(index:Int, vertexCount:Int, vertices:Vector, indices:Vector):Bool { + private static function isConcave(index:Int, vertexCount:Int, vertices:Array, indices:Array):Bool { var previous:Int = indices[(vertexCount + index - 1) % vertexCount] << 1; var current:Int = indices[index] << 1; var next:Int = indices[(index + 1) % vertexCount] << 1; diff --git a/spine-haxe/spine-haxe/spine/animation/AlphaTimeline.hx b/spine-haxe/spine-haxe/spine/animation/AlphaTimeline.hx index 9b9ae7888..3090d54d3 100644 --- a/spine-haxe/spine-haxe/spine/animation/AlphaTimeline.hx +++ b/spine-haxe/spine-haxe/spine/animation/AlphaTimeline.hx @@ -29,7 +29,6 @@ package spine.animation; -import openfl.Vector; import spine.Event; import spine.Skeleton; import spine.Slot; @@ -43,7 +42,7 @@ class AlphaTimeline extends CurveTimeline1 implements SlotTimeline { private var slotIndex:Int = 0; 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; } @@ -55,7 +54,7 @@ class AlphaTimeline extends CurveTimeline1 implements SlotTimeline { return slotIndex; } - public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector, alpha:Float, blend:MixBlend, + public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array, alpha:Float, blend:MixBlend, direction:MixDirection):Void { var slot:Slot = skeleton.slots[slotIndex]; if (!slot.bone.active) diff --git a/spine-haxe/spine-haxe/spine/animation/Animation.hx b/spine-haxe/spine-haxe/spine/animation/Animation.hx index 5a2148b4a..c636b61b9 100644 --- a/spine-haxe/spine-haxe/spine/animation/Animation.hx +++ b/spine-haxe/spine-haxe/spine/animation/Animation.hx @@ -29,19 +29,18 @@ package spine.animation; -import openfl.utils.Dictionary; -import openfl.Vector; +import haxe.ds.StringMap; import spine.Event; import spine.Skeleton; class Animation { private var _name:String; - private var _timelines:Vector; - private var _timelineIds:Dictionary = new Dictionary(); + private var _timelines:Array; + private var _timelineIds:StringMap = new StringMap(); public var duration:Float = 0; - public function new(name:String, timelines:Vector, duration:Float) { + public function new(name:String, timelines:Array, duration:Float) { if (name == null) throw new SpineException("name cannot be null."); _name = name; @@ -49,29 +48,29 @@ class Animation { this.duration = duration; } - public function setTimelines(timelines:Vector) { + public function setTimelines(timelines:Array) { if (timelines == null) throw new SpineException("timelines cannot be null."); _timelines = timelines; - _timelineIds = new Dictionary(); + _timelineIds = new StringMap(); for (timeline in timelines) { - var ids:Vector = timeline.propertyIds; + var ids:Array = timeline.propertyIds; for (id in ids) { - _timelineIds[id] = true; + _timelineIds.set(id, true); } } } - public function hasTimeline(ids:Vector):Bool { + public function hasTimeline(ids:Array):Bool { for (id in ids) { - if (_timelineIds[id]) + if (_timelineIds.exists(id)) return true; } return false; } /** Poses the skeleton at the specified time for this animation. */ - public function apply(skeleton:Skeleton, lastTime:Float, time:Float, loop:Bool, events:Vector, alpha:Float, blend:MixBlend, + public function apply(skeleton:Skeleton, lastTime:Float, time:Float, loop:Bool, events:Array, alpha:Float, blend:MixBlend, direction:MixDirection):Void { if (skeleton == null) throw new SpineException("skeleton cannot be null."); @@ -97,9 +96,9 @@ class Animation { return _name; } - public var timelines(get, never):Vector; + public var timelines(get, never):Array; - private function get_timelines():Vector { + private function get_timelines():Array { return _timelines; } } diff --git a/spine-haxe/spine-haxe/spine/animation/AnimationState.hx b/spine-haxe/spine-haxe/spine/animation/AnimationState.hx index f52d0c401..94d128793 100644 --- a/spine-haxe/spine-haxe/spine/animation/AnimationState.hx +++ b/spine-haxe/spine-haxe/spine/animation/AnimationState.hx @@ -29,8 +29,7 @@ package spine.animation; -import openfl.utils.Dictionary; -import openfl.Vector; +import haxe.ds.StringMap; import spine.animation.Listeners.EventListeners; import spine.Event; import spine.Pool; @@ -45,12 +44,12 @@ class AnimationState { public static inline var SETUP:Int = 1; public static inline var CURRENT:Int = 2; - private static var emptyAnimation:Animation = new Animation("", new Vector(), 0); + private static var emptyAnimation:Animation = new Animation("", new Array(), 0); public var data:AnimationStateData; - public var tracks:Vector = new Vector(); + public var tracks:Array = new Array(); - private var events:Vector = new Vector(); + private var events:Array = new Array(); public var onStart:Listeners = new Listeners(); public var onInterrupt:Listeners = new Listeners(); @@ -193,12 +192,12 @@ class AnimationState { var animationLast:Float = current.animationLast, animationTime:Float = current.getAnimationTime(), applyTime:Float = animationTime; - var applyEvents:Vector = events; + var applyEvents:Array = events; if (current.reverse) { applyTime = current.animation.duration - applyTime; applyEvents = null; } - var timelines:Vector = current.animation.timelines; + var timelines:Array = current.animation.timelines; var timelineCount:Int = timelines.length; var timeline:Timeline; if ((i == 0 && mix == 1) || blend == MixBlend.add) { @@ -206,12 +205,12 @@ class AnimationState { timeline.apply(skeleton, animationLast, applyTime, applyEvents, mix, blend, MixDirection.mixIn); } } else { - var timelineMode:Vector = current.timelineMode; + var timelineMode:Array = current.timelineMode; var shortestRotation = current.shortestRotation; var firstFrame:Bool = !shortestRotation && current.timelinesRotation.length != timelineCount << 1; if (firstFrame) - current.timelinesRotation.length = timelineCount << 1; + current.timelinesRotation.resize(timelineCount << 1); for (ii in 0...timelineCount) { var timeline:Timeline = timelines[ii]; @@ -227,7 +226,7 @@ class AnimationState { } } queueEvents(current, animationTime); - events.length = 0; + events.resize(0); current.nextAnimationLast = animationTime; current.nextTrackLast = current.trackTime; } @@ -270,13 +269,13 @@ class AnimationState { var attachments:Bool = mix < from.attachmentThreshold, drawOrder:Bool = mix < from.drawOrderThreshold; var timelineCount:Int = from.animation.timelines.length; - var timelines:Vector = from.animation.timelines; + var timelines:Array = from.animation.timelines; var alphaHold:Float = from.alpha * to.interruptAlpha, alphaMix:Float = alphaHold * (1 - mix); var animationLast:Float = from.animationLast, animationTime:Float = from.getAnimationTime(), applyTime:Float = animationTime; - var applyEvents:Vector = null; + var applyEvents:Array = null; if (from.reverse) { applyTime = from.animation.duration - applyTime; } else if (mix < from.eventThreshold) { @@ -288,14 +287,14 @@ class AnimationState { timeline.apply(skeleton, animationLast, applyTime, applyEvents, alphaMix, blend, MixDirection.mixOut); } } else { - var timelineMode:Vector = from.timelineMode; - var timelineHoldMix:Vector = from.timelineHoldMix; + var timelineMode:Array = from.timelineMode; + var timelineHoldMix:Array = from.timelineHoldMix; var shortestRotation = from.shortestRotation; var firstFrame:Bool = !shortestRotation && from.timelinesRotation.length != timelineCount << 1; if (firstFrame) - from.timelinesRotation.length = timelineCount << 1; - var timelinesRotation:Vector = from.timelinesRotation; + from.timelinesRotation.resize(timelineCount << 1); + var timelinesRotation:Array = from.timelinesRotation; from.totalAlpha = 0; for (i in 0...timelineCount) { @@ -340,7 +339,7 @@ class AnimationState { if (to.mixDuration > 0) queueEvents(from, animationTime); - events.length = 0; + events.resize(0); from.nextAnimationLast = animationTime; from.nextTrackLast = from.trackTime; @@ -363,7 +362,7 @@ class AnimationState { slot.attachmentState = this.unkeyedState + SETUP; } - public function applyRotateTimeline(timeline:RotateTimeline, skeleton:Skeleton, time:Float, alpha:Float, blend:MixBlend, timelinesRotation:Vector, + public function applyRotateTimeline(timeline:RotateTimeline, skeleton:Skeleton, time:Float, alpha:Float, blend:MixBlend, timelinesRotation:Array, i:Int, firstFrame:Bool) { if (firstFrame) timelinesRotation[i] = 0; @@ -478,7 +477,7 @@ class AnimationState { for (i in 0...tracks.length) { clearTrack(i); } - tracks.length = 0; + tracks.resize(0); queue.drainDisabled = oldTrainDisabled; queue.drain(); } @@ -525,7 +524,7 @@ class AnimationState { 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); @@ -627,7 +626,7 @@ class AnimationState { private function expandToIndex(index:Int):TrackEntry { if (index < tracks.length) return tracks[index]; - tracks.length = index + 1; + tracks.resize(index + 1); return null; } @@ -698,13 +697,13 @@ class AnimationState { private function computeHold(entry:TrackEntry):Void { var to:TrackEntry = entry.mixingTo; - var timelines:Vector = entry.animation.timelines; + var timelines:Array = entry.animation.timelines; var timelinesCount:Int = entry.animation.timelines.length; - var timelineMode:Vector = entry.timelineMode; - timelineMode.length = timelinesCount; - entry.timelineHoldMix.length = 0; - var timelineHoldMix:Vector = entry.timelineHoldMix; - timelineHoldMix.length = timelinesCount; + var timelineMode:Array = entry.timelineMode; + timelineMode.resize(timelinesCount); + entry.timelineHoldMix.resize(0); + var timelineHoldMix:Array = entry.timelineHoldMix; + timelineHoldMix.resize(timelinesCount); if (to != null && to.holdPrevious) { for (i in 0...timelinesCount) { @@ -717,7 +716,7 @@ class AnimationState { for (i in 0...timelinesCount) { continueOuter = false; var timeline:Timeline = timelines[i]; - var ids:Vector = timeline.propertyIds; + var ids:Array = timeline.propertyIds; if (!propertyIDs.addAll(ids)) { timelineMode[i] = SUBSEQUENT; } else if (to == null @@ -761,12 +760,12 @@ class AnimationState { } public function clearListeners():Void { - onStart.listeners.length = 0; - onInterrupt.listeners.length = 0; - onEnd.listeners.length = 0; - onDispose.listeners.length = 0; - onComplete.listeners.length = 0; - onEvent.listeners.length = 0; + onStart.listeners.resize(0); + onInterrupt.listeners.resize(0); + onEnd.listeners.resize(0); + onDispose.listeners.resize(0); + onComplete.listeners.resize(0); + onEvent.listeners.resize(0); } public function clearListenerNotifications():Void { @@ -775,14 +774,14 @@ class AnimationState { } class StringSet { - private var entries:Dictionary = new Dictionary(); + private var entries:StringMap = new StringMap(); private var size:Int = 0; public function new() {} public function add(value:String):Bool { - var contains:Bool = entries[value]; - entries[value] = true; + var contains:Bool = entries.exists(value); + entries.set(value, true); if (!contains) { size++; return true; @@ -790,7 +789,7 @@ class StringSet { return false; } - public function addAll(values:Vector):Bool { + public function addAll(values:Array):Bool { var oldSize:Int = size; for (i in 0...values.length) { add(values[i]); @@ -799,11 +798,11 @@ class StringSet { } public function contains(value:String):Bool { - return entries[value]; + return entries.exists(value); } public function clear():Void { - entries = new Dictionary(); + entries = new StringMap(); size = 0; } } diff --git a/spine-haxe/spine-haxe/spine/animation/AnimationStateData.hx b/spine-haxe/spine-haxe/spine/animation/AnimationStateData.hx index 0c922f99b..0bf626ba9 100644 --- a/spine-haxe/spine-haxe/spine/animation/AnimationStateData.hx +++ b/spine-haxe/spine-haxe/spine/animation/AnimationStateData.hx @@ -29,12 +29,12 @@ package spine.animation; -import openfl.utils.Object; +import haxe.ds.StringMap; import spine.SkeletonData; class AnimationStateData { private var _skeletonData:SkeletonData; - private var animationToMixTime:Object = new Object(); + private var animationToMixTime:StringMap = new StringMap(); public var defaultMix:Float = 0; @@ -63,13 +63,13 @@ class AnimationStateData { throw new SpineException("from cannot be null."); if (to == 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 { - var time:Object = animationToMixTime[from.name + ":" + to.name]; - if (time == null) + if (animationToMixTime.exists(from.name + ":" + to.name)) + return animationToMixTime.get(from.name + ":" + to.name); + else return defaultMix; - return cast(time, Float); } } diff --git a/spine-haxe/spine-haxe/spine/animation/AttachmentTimeline.hx b/spine-haxe/spine-haxe/spine/animation/AttachmentTimeline.hx index eb7f5fb72..b6d7b1290 100644 --- a/spine-haxe/spine-haxe/spine/animation/AttachmentTimeline.hx +++ b/spine-haxe/spine-haxe/spine/animation/AttachmentTimeline.hx @@ -29,7 +29,6 @@ package spine.animation; -import openfl.Vector; import spine.Event; import spine.Skeleton; import spine.Slot; @@ -38,12 +37,13 @@ class AttachmentTimeline extends Timeline implements SlotTimeline { public var slotIndex:Int = 0; /** The attachment name for each key frame. May contain null values to clear the attachment. */ - public var attachmentNames:Vector; + public var attachmentNames:Array; public function new(frameCount:Int, slotIndex:Int) { - super(frameCount, Vector.ofArray([Property.attachment + "|" + slotIndex])); + super(frameCount, [Property.attachment + "|" + slotIndex]); this.slotIndex = slotIndex; - attachmentNames = new Vector(frameCount, true); + attachmentNames = new Array(); + attachmentNames.resize(frameCount); } public override function getFrameCount():Int { @@ -60,7 +60,7 @@ class AttachmentTimeline extends Timeline implements SlotTimeline { attachmentNames[frame] = attachmentName; } - public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector, alpha:Float, blend:MixBlend, + public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array, alpha:Float, blend:MixBlend, direction:MixDirection):Void { var slot:Slot = skeleton.slots[slotIndex]; if (!slot.bone.active) diff --git a/spine-haxe/spine-haxe/spine/animation/CurveTimeline.hx b/spine-haxe/spine-haxe/spine/animation/CurveTimeline.hx index 3ac761721..50e39c11d 100644 --- a/spine-haxe/spine-haxe/spine/animation/CurveTimeline.hx +++ b/spine-haxe/spine-haxe/spine/animation/CurveTimeline.hx @@ -29,8 +29,6 @@ package spine.animation; -import openfl.Vector; - /** Base class for frames that use an interpolation bezier curve. */ class CurveTimeline extends Timeline { 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_SIZE:Int = 18; - private var curves:Vector; // type, x, y, ... + private var curves:Array; // type, x, y, ... - public function new(frameCount:Int, bezierCount:Int, propertyIds:Vector) { + public function new(frameCount:Int, bezierCount:Int, propertyIds:Array) { super(frameCount, propertyIds); - curves = new Vector(frameCount + bezierCount * BEZIER_SIZE, true); + curves = new Array(); + curves.resize(frameCount + bezierCount * BEZIER_SIZE); curves[frameCount - 1] = STEPPED; } @@ -58,7 +57,7 @@ class CurveTimeline extends Timeline { * than the actual number of Bezier curves. */ public function shrink(bezierCount:Int):Void { 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 diff --git a/spine-haxe/spine-haxe/spine/animation/CurveTimeline1.hx b/spine-haxe/spine-haxe/spine/animation/CurveTimeline1.hx index d672efaa4..4dfc54122 100644 --- a/spine-haxe/spine-haxe/spine/animation/CurveTimeline1.hx +++ b/spine-haxe/spine-haxe/spine/animation/CurveTimeline1.hx @@ -30,15 +30,13 @@ package spine.animation; /** The base class for a {@link CurveTimeline} that sets one property. */ -import openfl.Vector; - class CurveTimeline1 extends CurveTimeline { private static inline var ENTRIES:Int = 2; private static inline var VALUE:Int = 1; /** @param bezierCount The maximum number of Bezier curves. See {@link #shrink(Int)}. * @param propertyIds Unique identifiers for the properties the timeline modifies. */ - public function new(frameCount:Int, bezierCount:Int, propertyIds:Vector) { + public function new(frameCount:Int, bezierCount:Int, propertyIds:Array) { super(frameCount, bezierCount, propertyIds); } diff --git a/spine-haxe/spine-haxe/spine/animation/CurveTimeline2.hx b/spine-haxe/spine-haxe/spine/animation/CurveTimeline2.hx index a085efa81..fc8cb1cd4 100644 --- a/spine-haxe/spine-haxe/spine/animation/CurveTimeline2.hx +++ b/spine-haxe/spine-haxe/spine/animation/CurveTimeline2.hx @@ -30,8 +30,6 @@ package spine.animation; /** The base class for a {@link CurveTimeline} which sets two properties. */ -import openfl.Vector; - class CurveTimeline2 extends CurveTimeline { private static inline var ENTRIES:Int = 3; 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 propertyIds Unique identifiers for the properties the timeline modifies. */ - public function new(frameCount:Int, bezierCount:Int, propertyIds:Vector) { + public function new(frameCount:Int, bezierCount:Int, propertyIds:Array) { super(frameCount, bezierCount, propertyIds); } diff --git a/spine-haxe/spine-haxe/spine/animation/DeformTimeline.hx b/spine-haxe/spine-haxe/spine/animation/DeformTimeline.hx index 4671103b5..fafdd54cd 100644 --- a/spine-haxe/spine-haxe/spine/animation/DeformTimeline.hx +++ b/spine-haxe/spine-haxe/spine/animation/DeformTimeline.hx @@ -29,7 +29,6 @@ package spine.animation; -import openfl.Vector; import spine.animation.Timeline; import spine.attachments.Attachment; import spine.attachments.VertexAttachment; @@ -44,13 +43,14 @@ class DeformTimeline extends CurveTimeline implements SlotTimeline { public var attachment:VertexAttachment; /** The vertices for each key frame. */ - public var vertices:Vector>; + public var vertices:Array>; 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.attachment = attachment; - vertices = new Vector>(frameCount, true); + vertices = new Array>(); + vertices.resize(frameCount); } 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. * @param vertices Vertex positions for an unweighted VertexAttachment, or deform offsets if it has weights. */ - public function setFrame(frame:Int, time:Float, verticesOrDeform:Vector):Void { + public function setFrame(frame:Int, time:Float, verticesOrDeform:Array):Void { frames[frame] = time; vertices[frame] = verticesOrDeform; } @@ -129,7 +129,7 @@ class DeformTimeline extends CurveTimeline implements SlotTimeline { return y + (1 - y) * (time - x) / (frames[frame + getFrameEntries()] - x); } - public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector, alpha:Float, blend:MixBlend, + public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array, alpha:Float, blend:MixBlend, direction:MixDirection):Void { var slot:Slot = skeleton.slots[slotIndex]; if (!slot.bone.active) @@ -140,23 +140,23 @@ class DeformTimeline extends CurveTimeline implements SlotTimeline { if (!Std.isOfType(slotAttachment, VertexAttachment) || cast(slotAttachment, VertexAttachment).timelineAttachment != attachment) return; - var deform:Vector = slot.deform; + var deform:Array = slot.deform; if (deform.length == 0) blend = MixBlend.setup; var vertexCount:Int = vertices[0].length; - var i:Int, setupVertices:Vector; + var i:Int, setupVertices:Array; if (time < frames[0]) { switch (blend) { case MixBlend.setup: - deform.length = 0; + deform.resize(0); case MixBlend.first: if (alpha == 1) { - deform.length = 0; + deform.resize(0); return; } - deform.length = vertexCount; + deform.resize(vertexCount); var vertexAttachment:VertexAttachment = cast(slotAttachment, VertexAttachment); if (vertexAttachment.bones == null) { // Unweighted vertex positions. @@ -175,11 +175,11 @@ class DeformTimeline extends CurveTimeline implements SlotTimeline { return; } - deform.length = vertexCount; + deform.resize(vertexCount); var setup:Float; if (time >= frames[frames.length - 1]) // Time is after last frame. { - var lastVertices:Vector = vertices[frames.length - 1]; + var lastVertices:Array = vertices[frames.length - 1]; if (alpha == 1) { if (blend == MixBlend.add) { 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. var frame:Int = Timeline.search1(frames, time); var percent:Float = getCurvePercent(time, frame); - var prevVertices:Vector = vertices[frame], prev:Float; - var nextVertices:Vector = vertices[frame + 1]; + var prevVertices:Array = vertices[frame], prev:Float; + var nextVertices:Array = vertices[frame + 1]; if (alpha == 1) { if (blend == MixBlend.add) { diff --git a/spine-haxe/spine-haxe/spine/animation/DrawOrderTimeline.hx b/spine-haxe/spine-haxe/spine/animation/DrawOrderTimeline.hx index 06645f4b8..bc301a96f 100644 --- a/spine-haxe/spine-haxe/spine/animation/DrawOrderTimeline.hx +++ b/spine-haxe/spine-haxe/spine/animation/DrawOrderTimeline.hx @@ -29,17 +29,17 @@ package spine.animation; -import openfl.Vector; import spine.Event; import spine.Skeleton; import spine.Slot; class DrawOrderTimeline extends Timeline { - public var drawOrders:Vector>; + public var drawOrders:Array>; public function new(frameCount:Int) { - super(frameCount, Vector.ofArray([Std.string(Property.drawOrder)])); - drawOrders = new Vector>(frameCount, true); + super(frameCount, [Std.string(Property.drawOrder)]); + drawOrders = new Array>(); + drawOrders.resize(frameCount); } public var frameCount(get, never):Int; @@ -49,15 +49,15 @@ class DrawOrderTimeline extends Timeline { } /** Sets the time and value of the specified keyframe. */ - public function setFrame(frame:Int, time:Float, drawOrder:Vector):Void { + public function setFrame(frame:Int, time:Float, drawOrder:Array):Void { frames[frame] = time; drawOrders[frame] = drawOrder; } - override public function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector, alpha:Float, blend:MixBlend, + override public function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array, alpha:Float, blend:MixBlend, direction:MixDirection):Void { - var drawOrder:Vector = skeleton.drawOrder; - var slots:Vector = skeleton.slots; + var drawOrder:Array = skeleton.drawOrder; + var slots:Array = skeleton.slots; var i:Int = 0, n:Int = slots.length; if (direction == MixDirection.mixOut) { @@ -78,7 +78,7 @@ class DrawOrderTimeline extends Timeline { return; } - var drawOrderToSetupIndex:Vector = drawOrders[Timeline.search1(frames, time)]; + var drawOrderToSetupIndex:Array = drawOrders[Timeline.search1(frames, time)]; if (drawOrderToSetupIndex == null) { for (i in 0...n) { drawOrder[i] = slots[i]; diff --git a/spine-haxe/spine-haxe/spine/animation/EventTimeline.hx b/spine-haxe/spine-haxe/spine/animation/EventTimeline.hx index 204b2b33b..c5268b001 100644 --- a/spine-haxe/spine-haxe/spine/animation/EventTimeline.hx +++ b/spine-haxe/spine-haxe/spine/animation/EventTimeline.hx @@ -29,17 +29,17 @@ package spine.animation; -import openfl.Vector; import spine.animation.Timeline; import spine.Event; import spine.Skeleton; class EventTimeline extends Timeline { - public var events:Vector; + public var events:Array; public function new(frameCount:Int) { - super(frameCount, Vector.ofArray([Std.string(Property.event)])); - events = new Vector(frameCount, true); + super(frameCount, [Std.string(Property.event)]); + events = new Array(); + events.resize(frameCount); } public override function getFrameCount():Int { @@ -53,7 +53,7 @@ class EventTimeline extends Timeline { } /** Fires events for frames > `lastTime` and <= `time`. */ - public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector, alpha:Float, blend:MixBlend, + public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array, alpha:Float, blend:MixBlend, direction:MixDirection):Void { if (events == null) return; diff --git a/spine-haxe/spine-haxe/spine/animation/IkConstraintTimeline.hx b/spine-haxe/spine-haxe/spine/animation/IkConstraintTimeline.hx index 4f51af457..6b95cfb1f 100644 --- a/spine-haxe/spine-haxe/spine/animation/IkConstraintTimeline.hx +++ b/spine-haxe/spine-haxe/spine/animation/IkConstraintTimeline.hx @@ -29,7 +29,6 @@ package spine.animation; -import openfl.Vector; import spine.Event; import spine.IkConstraint; import spine.Skeleton; @@ -46,7 +45,7 @@ class IkConstraintTimeline extends CurveTimeline { public var ikConstraintIndex:Int = 0; 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; } @@ -65,7 +64,7 @@ class IkConstraintTimeline extends CurveTimeline { frames[frame + STRETCH] = stretch ? 1 : 0; } - public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector, alpha:Float, blend:MixBlend, + public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array, alpha:Float, blend:MixBlend, direction:MixDirection):Void { var constraint:IkConstraint = skeleton.ikConstraints[ikConstraintIndex]; if (!constraint.active) diff --git a/spine-haxe/spine-haxe/spine/animation/Listeners.hx b/spine-haxe/spine-haxe/spine/animation/Listeners.hx index d7b99f7d9..de422b538 100644 --- a/spine-haxe/spine-haxe/spine/animation/Listeners.hx +++ b/spine-haxe/spine-haxe/spine/animation/Listeners.hx @@ -29,19 +29,17 @@ package spine.animation; -import openfl.Vector; - class Listeners { - private var _listeners:VectorVoid>; + private var _listeners:ArrayVoid>; - public var listeners(get, never):VectorVoid>; + public var listeners(get, never):ArrayVoid>; - private function get_listeners():VectorVoid> { + private function get_listeners():ArrayVoid> { return _listeners; } public function new() { - _listeners = new VectorVoid>(); + _listeners = new ArrayVoid>(); } public function invoke(entry:TrackEntry) { @@ -68,16 +66,16 @@ class Listeners { } class EventListeners { - private var _listeners:VectorEvent->Void>; + private var _listeners:ArrayEvent->Void>; - public var listeners(get, never):VectorEvent->Void>; + public var listeners(get, never):ArrayEvent->Void>; - private function get_listeners():VectorEvent->Void> { + private function get_listeners():ArrayEvent->Void> { return _listeners; } public function new() { - _listeners = new VectorEvent->Void>(); + _listeners = new ArrayEvent->Void>(); } public function invoke(entry:TrackEntry, event:Event) { diff --git a/spine-haxe/spine-haxe/spine/animation/PathConstraintMixTimeline.hx b/spine-haxe/spine-haxe/spine/animation/PathConstraintMixTimeline.hx index 35f5564bf..e993c6eba 100644 --- a/spine-haxe/spine-haxe/spine/animation/PathConstraintMixTimeline.hx +++ b/spine-haxe/spine-haxe/spine/animation/PathConstraintMixTimeline.hx @@ -29,7 +29,6 @@ package spine.animation; -import openfl.Vector; import spine.Event; import spine.PathConstraint; import spine.Skeleton; @@ -44,7 +43,7 @@ class PathConstraintMixTimeline extends CurveTimeline { public var pathConstraintIndex:Int = 0; 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; } @@ -60,7 +59,7 @@ class PathConstraintMixTimeline extends CurveTimeline { frames[frame + Y] = mixY; } - public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector, alpha:Float, blend:MixBlend, + public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array, alpha:Float, blend:MixBlend, direction:MixDirection):Void { var constraint:PathConstraint = skeleton.pathConstraints[pathConstraintIndex]; if (!constraint.active) diff --git a/spine-haxe/spine-haxe/spine/animation/PathConstraintPositionTimeline.hx b/spine-haxe/spine-haxe/spine/animation/PathConstraintPositionTimeline.hx index ba2d907c0..0d3bd789b 100644 --- a/spine-haxe/spine-haxe/spine/animation/PathConstraintPositionTimeline.hx +++ b/spine-haxe/spine-haxe/spine/animation/PathConstraintPositionTimeline.hx @@ -29,7 +29,6 @@ package spine.animation; -import openfl.Vector; import spine.Event; import spine.PathConstraint; import spine.Skeleton; @@ -39,11 +38,11 @@ class PathConstraintPositionTimeline extends CurveTimeline1 { public var pathConstraintIndex:Int = 0; 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; } - public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector, alpha:Float, blend:MixBlend, + public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array, alpha:Float, blend:MixBlend, direction:MixDirection):Void { var constraint:PathConstraint = skeleton.pathConstraints[pathConstraintIndex]; if (!constraint.active) diff --git a/spine-haxe/spine-haxe/spine/animation/PathConstraintSpacingTimeline.hx b/spine-haxe/spine-haxe/spine/animation/PathConstraintSpacingTimeline.hx index 5d81ca08c..8a298b67b 100644 --- a/spine-haxe/spine-haxe/spine/animation/PathConstraintSpacingTimeline.hx +++ b/spine-haxe/spine-haxe/spine/animation/PathConstraintSpacingTimeline.hx @@ -29,7 +29,6 @@ package spine.animation; -import openfl.Vector; import spine.Event; import spine.PathConstraint; import spine.Skeleton; @@ -39,11 +38,11 @@ class PathConstraintSpacingTimeline extends CurveTimeline1 { public var pathConstraintIndex:Int = 0; 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; } - public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector, alpha:Float, blend:MixBlend, + public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array, alpha:Float, blend:MixBlend, direction:MixDirection):Void { var constraint:PathConstraint = skeleton.pathConstraints[pathConstraintIndex]; if (!constraint.active) diff --git a/spine-haxe/spine-haxe/spine/animation/RGB2Timeline.hx b/spine-haxe/spine-haxe/spine/animation/RGB2Timeline.hx index 46367b23f..474686c86 100644 --- a/spine-haxe/spine-haxe/spine/animation/RGB2Timeline.hx +++ b/spine-haxe/spine-haxe/spine/animation/RGB2Timeline.hx @@ -29,8 +29,6 @@ package spine.animation; -import openfl.Vector; - class RGB2Timeline extends CurveTimeline implements SlotTimeline { private static inline var ENTRIES:Int = 7; private static inline var R:Int = 1; @@ -43,7 +41,7 @@ class RGB2Timeline extends CurveTimeline implements SlotTimeline { private var slotIndex:Int = 0; 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; } @@ -67,7 +65,7 @@ class RGB2Timeline extends CurveTimeline implements SlotTimeline { frames[frame + B2] = b2; } - public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector, alpha:Float, blend:MixBlend, + public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array, alpha:Float, blend:MixBlend, direction:MixDirection):Void { var slot:Slot = skeleton.slots[slotIndex]; if (!slot.bone.active) diff --git a/spine-haxe/spine-haxe/spine/animation/RGBA2Timeline.hx b/spine-haxe/spine-haxe/spine/animation/RGBA2Timeline.hx index 56b1d8ee1..ae63d5014 100644 --- a/spine-haxe/spine-haxe/spine/animation/RGBA2Timeline.hx +++ b/spine-haxe/spine-haxe/spine/animation/RGBA2Timeline.hx @@ -29,8 +29,6 @@ package spine.animation; -import openfl.Vector; - class RGBA2Timeline extends CurveTimeline implements SlotTimeline { private static inline var ENTRIES:Int = 8; private static inline var R:Int = 1; @@ -44,11 +42,11 @@ class RGBA2Timeline extends CurveTimeline implements SlotTimeline { private var slotIndex:Int = 0; public function new(frameCount:Int, bezierCount:Int, slotIndex:Int) { - super(frameCount, bezierCount, Vector.ofArray([ + super(frameCount, bezierCount, [ Property.rgb + "|" + slotIndex, Property.alpha + "|" + slotIndex, Property.rgb2 + "|" + slotIndex - ])); + ]); this.slotIndex = slotIndex; } @@ -73,7 +71,7 @@ class RGBA2Timeline extends CurveTimeline implements SlotTimeline { frames[frame + B2] = b2; } - public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector, alpha:Float, blend:MixBlend, + public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array, alpha:Float, blend:MixBlend, direction:MixDirection):Void { var slot:Slot = skeleton.slots[slotIndex]; if (!slot.bone.active) diff --git a/spine-haxe/spine-haxe/spine/animation/RGBATimeline.hx b/spine-haxe/spine-haxe/spine/animation/RGBATimeline.hx index 523568fa3..b9983b0e8 100644 --- a/spine-haxe/spine-haxe/spine/animation/RGBATimeline.hx +++ b/spine-haxe/spine-haxe/spine/animation/RGBATimeline.hx @@ -29,8 +29,6 @@ package spine.animation; -import openfl.Vector; - class RGBATimeline extends CurveTimeline implements SlotTimeline { private static inline var ENTRIES:Int = 5; private static inline var R:Int = 1; @@ -41,7 +39,7 @@ class RGBATimeline extends CurveTimeline implements SlotTimeline { private var slotIndex:Int = 0; 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; } @@ -63,7 +61,7 @@ class RGBATimeline extends CurveTimeline implements SlotTimeline { frames[frame + A] = a; } - public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector, alpha:Float, blend:MixBlend, + public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array, alpha:Float, blend:MixBlend, direction:MixDirection):Void { var slot:Slot = skeleton.slots[slotIndex]; if (!slot.bone.active) diff --git a/spine-haxe/spine-haxe/spine/animation/RGBTimeline.hx b/spine-haxe/spine-haxe/spine/animation/RGBTimeline.hx index d4e56c2ee..161748998 100644 --- a/spine-haxe/spine-haxe/spine/animation/RGBTimeline.hx +++ b/spine-haxe/spine-haxe/spine/animation/RGBTimeline.hx @@ -29,8 +29,6 @@ package spine.animation; -import openfl.Vector; - class RGBTimeline extends CurveTimeline implements SlotTimeline { private static inline var ENTRIES:Int = 4; private static inline var R:Int = 1; @@ -40,7 +38,7 @@ class RGBTimeline extends CurveTimeline implements SlotTimeline { private var slotIndex:Int = 0; 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; } @@ -61,7 +59,7 @@ class RGBTimeline extends CurveTimeline implements SlotTimeline { frames[frame + B] = b; } - public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector, alpha:Float, blend:MixBlend, + public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array, alpha:Float, blend:MixBlend, direction:MixDirection):Void { var slot:Slot = skeleton.slots[slotIndex]; if (!slot.bone.active) diff --git a/spine-haxe/spine-haxe/spine/animation/RotateTimeline.hx b/spine-haxe/spine-haxe/spine/animation/RotateTimeline.hx index 3b37eee53..e3088ad9b 100644 --- a/spine-haxe/spine-haxe/spine/animation/RotateTimeline.hx +++ b/spine-haxe/spine-haxe/spine/animation/RotateTimeline.hx @@ -29,7 +29,6 @@ package spine.animation; -import openfl.Vector; import spine.Bone; import spine.Event; import spine.Skeleton; @@ -38,7 +37,7 @@ class RotateTimeline extends CurveTimeline1 implements BoneTimeline { public var boneIndex:Int = 0; 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; } @@ -46,7 +45,7 @@ class RotateTimeline extends CurveTimeline1 implements BoneTimeline { return boneIndex; } - override public function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector, alpha:Float, blend:MixBlend, + override public function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array, alpha:Float, blend:MixBlend, direction:MixDirection):Void { var bone:Bone = skeleton.bones[boneIndex]; if (!bone.active) diff --git a/spine-haxe/spine-haxe/spine/animation/ScaleTimeline.hx b/spine-haxe/spine-haxe/spine/animation/ScaleTimeline.hx index c0c808bea..8c725aad4 100644 --- a/spine-haxe/spine-haxe/spine/animation/ScaleTimeline.hx +++ b/spine-haxe/spine-haxe/spine/animation/ScaleTimeline.hx @@ -29,7 +29,6 @@ package spine.animation; -import openfl.Vector; import spine.Bone; import spine.Event; import spine.MathUtils; @@ -39,7 +38,7 @@ class ScaleTimeline extends CurveTimeline2 implements BoneTimeline { private var boneIndex:Int = 0; 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; } @@ -47,7 +46,7 @@ class ScaleTimeline extends CurveTimeline2 implements BoneTimeline { return boneIndex; } - override public function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector, alpha:Float, blend:MixBlend, + override public function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array, alpha:Float, blend:MixBlend, direction:MixDirection):Void { var bone:Bone = skeleton.bones[boneIndex]; if (!bone.active) diff --git a/spine-haxe/spine-haxe/spine/animation/ScaleXTimeline.hx b/spine-haxe/spine-haxe/spine/animation/ScaleXTimeline.hx index 093e890b5..76f856d73 100644 --- a/spine-haxe/spine-haxe/spine/animation/ScaleXTimeline.hx +++ b/spine-haxe/spine-haxe/spine/animation/ScaleXTimeline.hx @@ -29,7 +29,6 @@ package spine.animation; -import openfl.Vector; import spine.Bone; import spine.Event; import spine.MathUtils; @@ -39,7 +38,7 @@ class ScaleXTimeline extends CurveTimeline1 implements BoneTimeline { private var boneIndex:Int = 0; 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; } @@ -47,7 +46,7 @@ class ScaleXTimeline extends CurveTimeline1 implements BoneTimeline { return boneIndex; } - override public function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector, alpha:Float, blend:MixBlend, + override public function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array, alpha:Float, blend:MixBlend, direction:MixDirection):Void { var bone:Bone = skeleton.bones[boneIndex]; if (!bone.active) diff --git a/spine-haxe/spine-haxe/spine/animation/ScaleYTimeline.hx b/spine-haxe/spine-haxe/spine/animation/ScaleYTimeline.hx index 13e854a4b..2d64737e7 100644 --- a/spine-haxe/spine-haxe/spine/animation/ScaleYTimeline.hx +++ b/spine-haxe/spine-haxe/spine/animation/ScaleYTimeline.hx @@ -29,7 +29,6 @@ package spine.animation; -import openfl.Vector; import spine.Bone; import spine.Event; import spine.MathUtils; @@ -39,7 +38,7 @@ class ScaleYTimeline extends CurveTimeline1 implements BoneTimeline { private var boneIndex:Int = 0; 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; } @@ -47,7 +46,7 @@ class ScaleYTimeline extends CurveTimeline1 implements BoneTimeline { return boneIndex; } - override public function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector, alpha:Float, blend:MixBlend, + override public function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array, alpha:Float, blend:MixBlend, direction:MixDirection):Void { var bone:Bone = skeleton.bones[boneIndex]; if (!bone.active) diff --git a/spine-haxe/spine-haxe/spine/animation/SequenceTimeline.hx b/spine-haxe/spine-haxe/spine/animation/SequenceTimeline.hx index 6e7089ebe..0d043b89c 100644 --- a/spine-haxe/spine-haxe/spine/animation/SequenceTimeline.hx +++ b/spine-haxe/spine-haxe/spine/animation/SequenceTimeline.hx @@ -29,7 +29,6 @@ package spine.animation; -import openfl.Vector; import spine.attachments.VertexAttachment; import spine.attachments.Attachment; @@ -42,9 +41,9 @@ class SequenceTimeline extends Timeline implements SlotTimeline { var 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) - ])); + ]); this.slotIndex = slotIndex; this.attachment = attachment; } @@ -71,7 +70,7 @@ class SequenceTimeline extends Timeline implements SlotTimeline { frames[frame + SequenceTimeline.DELAY] = delay; } - public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector, alpha:Float, blend:MixBlend, + public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array, alpha:Float, blend:MixBlend, direction:MixDirection):Void { var slot = skeleton.slots[this.slotIndex]; if (!slot.bone.active) diff --git a/spine-haxe/spine-haxe/spine/animation/ShearTimeline.hx b/spine-haxe/spine-haxe/spine/animation/ShearTimeline.hx index ade82a410..8970c3d70 100644 --- a/spine-haxe/spine-haxe/spine/animation/ShearTimeline.hx +++ b/spine-haxe/spine-haxe/spine/animation/ShearTimeline.hx @@ -29,7 +29,6 @@ package spine.animation; -import openfl.Vector; import spine.Bone; import spine.Event; import spine.Skeleton; @@ -38,7 +37,7 @@ class ShearTimeline extends CurveTimeline2 implements BoneTimeline { private var boneIndex:Int = 0; 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; } @@ -46,7 +45,7 @@ class ShearTimeline extends CurveTimeline2 implements BoneTimeline { return boneIndex; } - override public function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector, alpha:Float, blend:MixBlend, + override public function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array, alpha:Float, blend:MixBlend, direction:MixDirection):Void { var bone:Bone = skeleton.bones[boneIndex]; if (!bone.active) diff --git a/spine-haxe/spine-haxe/spine/animation/ShearXTimeline.hx b/spine-haxe/spine-haxe/spine/animation/ShearXTimeline.hx index 07db98022..842137abf 100644 --- a/spine-haxe/spine-haxe/spine/animation/ShearXTimeline.hx +++ b/spine-haxe/spine-haxe/spine/animation/ShearXTimeline.hx @@ -29,7 +29,6 @@ package spine.animation; -import openfl.Vector; import spine.Bone; import spine.Event; import spine.Skeleton; @@ -38,7 +37,7 @@ class ShearXTimeline extends CurveTimeline1 implements BoneTimeline { private var boneIndex:Int = 0; 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; } @@ -46,7 +45,7 @@ class ShearXTimeline extends CurveTimeline1 implements BoneTimeline { return boneIndex; } - override public function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector, alpha:Float, blend:MixBlend, + override public function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array, alpha:Float, blend:MixBlend, direction:MixDirection):Void { var bone:Bone = skeleton.bones[boneIndex]; if (!bone.active) diff --git a/spine-haxe/spine-haxe/spine/animation/ShearYTimeline.hx b/spine-haxe/spine-haxe/spine/animation/ShearYTimeline.hx index c865d6a3b..483fc5285 100644 --- a/spine-haxe/spine-haxe/spine/animation/ShearYTimeline.hx +++ b/spine-haxe/spine-haxe/spine/animation/ShearYTimeline.hx @@ -29,7 +29,6 @@ package spine.animation; -import openfl.Vector; import spine.Bone; import spine.Event; import spine.Skeleton; @@ -38,7 +37,7 @@ class ShearYTimeline extends CurveTimeline1 implements BoneTimeline { private var boneIndex:Int = 0; 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; } @@ -46,7 +45,7 @@ class ShearYTimeline extends CurveTimeline1 implements BoneTimeline { return boneIndex; } - override public function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector, alpha:Float, blend:MixBlend, + override public function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array, alpha:Float, blend:MixBlend, direction:MixDirection):Void { var bone:Bone = skeleton.bones[boneIndex]; if (!bone.active) diff --git a/spine-haxe/spine-haxe/spine/animation/Timeline.hx b/spine-haxe/spine-haxe/spine/animation/Timeline.hx index 37aa194fe..59273c1d4 100644 --- a/spine-haxe/spine-haxe/spine/animation/Timeline.hx +++ b/spine-haxe/spine-haxe/spine/animation/Timeline.hx @@ -31,15 +31,15 @@ package spine.animation; import spine.Event; import spine.Skeleton; -import openfl.Vector; class Timeline { - public var propertyIds:Vector; - public var frames:Vector; + public var propertyIds:Array; + public var frames:Array; - public function new(frameCount:Int, propertyIds:Vector) { + public function new(frameCount:Int, propertyIds:Array) { this.propertyIds = propertyIds; - frames = new Vector(frameCount * getFrameEntries(), true); + frames = new Array(); + frames.resize(frameCount * getFrameEntries()); } public function getFrameEntries():Int { @@ -54,11 +54,11 @@ class Timeline { return frames[frames.length - getFrameEntries()]; } - public function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector, alpha:Float, blend:MixBlend, direction:MixDirection):Void { + public function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array, alpha:Float, blend:MixBlend, direction:MixDirection):Void { throw new SpineException("Timeline implementations must override apply()"); } - public static function search1(frames:Vector, time:Float):Int { + public static function search1(frames:Array, time:Float):Int { var n:Int = frames.length; for (i in 1...n) { if (frames[i] > time) @@ -67,7 +67,7 @@ class Timeline { return n - 1; } - public static function search(values:Vector, time:Float, step:Int):Int { + public static function search(values:Array, time:Float, step:Int):Int { var n:Int = values.length; var i:Int = step; while (i < n) { diff --git a/spine-haxe/spine-haxe/spine/animation/TrackEntry.hx b/spine-haxe/spine-haxe/spine/animation/TrackEntry.hx index 3228e2f27..ac3833308 100644 --- a/spine-haxe/spine-haxe/spine/animation/TrackEntry.hx +++ b/spine-haxe/spine-haxe/spine/animation/TrackEntry.hx @@ -29,7 +29,6 @@ package spine.animation; -import openfl.Vector; import spine.animation.Listeners.EventListeners; import spine.Poolable; @@ -68,9 +67,9 @@ class TrackEntry implements Poolable { public var interruptAlpha:Float = 0; public var totalAlpha:Float = 0; public var mixBlend:MixBlend = MixBlend.replace; - public var timelineMode:Vector = new Vector(); - public var timelineHoldMix:Vector = new Vector(); - public var timelinesRotation:Vector = new Vector(); + public var timelineMode:Array = new Array(); + public var timelineHoldMix:Array = new Array(); + public var timelinesRotation:Array = new Array(); public var shortestRotation = false; public function new() {} @@ -105,18 +104,18 @@ class TrackEntry implements Poolable { mixingFrom = null; mixingTo = null; animation = null; - onStart.listeners.length = 0; - onInterrupt.listeners.length = 0; - onEnd.listeners.length = 0; - onDispose.listeners.length = 0; - onComplete.listeners.length = 0; - onEvent.listeners.length = 0; - timelineMode.length = 0; - timelineHoldMix.length = 0; - timelinesRotation.length = 0; + onStart.listeners.resize(0); + onInterrupt.listeners.resize(0); + onEnd.listeners.resize(0); + onDispose.listeners.resize(0); + onComplete.listeners.resize(0); + onEvent.listeners.resize(0); + timelineMode.resize(0); + timelineHoldMix.resize(0); + timelinesRotation.resize(0); } public function resetRotationDirection():Void { - timelinesRotation.length = 0; + timelinesRotation.resize(0); } } diff --git a/spine-haxe/spine-haxe/spine/animation/TransformConstraintTimeline.hx b/spine-haxe/spine-haxe/spine/animation/TransformConstraintTimeline.hx index 1b975d008..c5f5ae4cc 100644 --- a/spine-haxe/spine-haxe/spine/animation/TransformConstraintTimeline.hx +++ b/spine-haxe/spine-haxe/spine/animation/TransformConstraintTimeline.hx @@ -29,7 +29,6 @@ package spine.animation; -import openfl.Vector; import spine.Event; import spine.Skeleton; import spine.TransformConstraint; @@ -48,7 +47,7 @@ class TransformConstraintTimeline extends CurveTimeline { public var transformConstraintIndex:Int = 0; 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; } @@ -68,7 +67,7 @@ class TransformConstraintTimeline extends CurveTimeline { frames[frame + SHEARY] = mixShearY; } - override public function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector, alpha:Float, blend:MixBlend, + override public function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array, alpha:Float, blend:MixBlend, direction:MixDirection):Void { var constraint:TransformConstraint = skeleton.transformConstraints[transformConstraintIndex]; if (!constraint.active) diff --git a/spine-haxe/spine-haxe/spine/animation/TranslateTimeline.hx b/spine-haxe/spine-haxe/spine/animation/TranslateTimeline.hx index 52d98b096..b7ce20ec0 100644 --- a/spine-haxe/spine-haxe/spine/animation/TranslateTimeline.hx +++ b/spine-haxe/spine-haxe/spine/animation/TranslateTimeline.hx @@ -29,7 +29,6 @@ package spine.animation; -import openfl.Vector; import spine.Bone; import spine.Event; import spine.Skeleton; @@ -38,7 +37,7 @@ class TranslateTimeline extends CurveTimeline2 implements BoneTimeline { public var boneIndex:Int = 0; 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; } @@ -46,7 +45,7 @@ class TranslateTimeline extends CurveTimeline2 implements BoneTimeline { return boneIndex; } - override public function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector, alpha:Float, blend:MixBlend, + override public function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array, alpha:Float, blend:MixBlend, direction:MixDirection):Void { var bone:Bone = skeleton.bones[boneIndex]; if (!bone.active) diff --git a/spine-haxe/spine-haxe/spine/animation/TranslateXTimeline.hx b/spine-haxe/spine-haxe/spine/animation/TranslateXTimeline.hx index aaa970d98..f40a571b5 100644 --- a/spine-haxe/spine-haxe/spine/animation/TranslateXTimeline.hx +++ b/spine-haxe/spine-haxe/spine/animation/TranslateXTimeline.hx @@ -29,7 +29,6 @@ package spine.animation; -import openfl.Vector; import spine.Bone; import spine.Event; import spine.Skeleton; @@ -38,7 +37,7 @@ class TranslateXTimeline extends CurveTimeline1 implements BoneTimeline { public var boneIndex:Int = 0; 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; } @@ -46,7 +45,7 @@ class TranslateXTimeline extends CurveTimeline1 implements BoneTimeline { return boneIndex; } - public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector, alpha:Float, blend:MixBlend, + public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array, alpha:Float, blend:MixBlend, direction:MixDirection):Void { var bone:Bone = skeleton.bones[boneIndex]; if (!bone.active) diff --git a/spine-haxe/spine-haxe/spine/animation/TranslateYTimeline.hx b/spine-haxe/spine-haxe/spine/animation/TranslateYTimeline.hx index 333b6a1da..4adcd5b17 100644 --- a/spine-haxe/spine-haxe/spine/animation/TranslateYTimeline.hx +++ b/spine-haxe/spine-haxe/spine/animation/TranslateYTimeline.hx @@ -29,7 +29,6 @@ package spine.animation; -import openfl.Vector; import spine.Bone; import spine.Event; import spine.Skeleton; @@ -38,7 +37,7 @@ class TranslateYTimeline extends CurveTimeline1 implements BoneTimeline { public var boneIndex:Int = 0; 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; } @@ -46,7 +45,7 @@ class TranslateYTimeline extends CurveTimeline1 implements BoneTimeline { return boneIndex; } - public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Vector, alpha:Float, blend:MixBlend, + public override function apply(skeleton:Skeleton, lastTime:Float, time:Float, events:Array, alpha:Float, blend:MixBlend, direction:MixDirection):Void { var bone:Bone = skeleton.bones[boneIndex]; if (!bone.active) diff --git a/spine-haxe/spine-haxe/spine/atlas/Format.hx b/spine-haxe/spine-haxe/spine/atlas/Format.hx index d90823ed1..5e3a176cf 100644 --- a/spine-haxe/spine-haxe/spine/atlas/Format.hx +++ b/spine-haxe/spine-haxe/spine/atlas/Format.hx @@ -29,8 +29,6 @@ package spine.atlas; -import openfl.Vector; - class Format { public static var alpha(default, never):Format = new Format(0, "alpha"); 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 rgba8888(default, never):Format = new Format(6, "rgba8888"); - public static var values(default, never):Vector = Vector.ofArray([alpha, intensity, luminanceAlpha, rgb565, rgba4444, rgb888, rgba8888]); + public static var values(default, never):Array = [alpha, intensity, luminanceAlpha, rgb565, rgba4444, rgb888, rgba8888]; public var ordinal(default, null):Int; public var name(default, null):String; diff --git a/spine-haxe/spine-haxe/spine/atlas/TextureAtlas.hx b/spine-haxe/spine-haxe/spine/atlas/TextureAtlas.hx index 9720b5185..c1b328963 100644 --- a/spine-haxe/spine-haxe/spine/atlas/TextureAtlas.hx +++ b/spine-haxe/spine-haxe/spine/atlas/TextureAtlas.hx @@ -29,14 +29,12 @@ package spine.atlas; +import haxe.ds.StringMap; import openfl.utils.Assets; -import openfl.utils.ByteArray; -import openfl.utils.Dictionary; -import openfl.Vector; class TextureAtlas { - private var pages = new Vector(); - private var regions = new Vector(); + private var pages = new Array(); + private var regions = new Array(); private var textureLoader:TextureLoader; public static function fromAssets(path:String) { @@ -51,17 +49,14 @@ class TextureAtlas { } /** @param object A String or ByteArray. */ - public function new(object:Dynamic, textureLoader:TextureLoader) { - if (object == null) { - return; + public function new(atlasText:String, textureLoader:TextureLoader) { + if (atlasText == null) { + throw new SpineException("atlasText must not be null"); } - if (Std.isOfType(object, String)) { - load(cast(object, String), textureLoader); - } 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."); + if (textureLoader == null) { + throw new SpineException("textureLoader must not be null"); } + load(atlasText, textureLoader); } private function load(atlasText:String, textureLoader:TextureLoader):Void { @@ -71,71 +66,72 @@ class TextureAtlas { this.textureLoader = textureLoader; var reader:Reader = new Reader(atlasText); - var entry:Vector = new Vector(5, true); + var entry:Array = new Array(); + entry.resize(5); var page:TextureAtlasPage = null; var region:TextureAtlasRegion = null; - var pageFields:DictionaryVoid> = new DictionaryVoid>(); - pageFields["size"] = function():Void { + var pageFields:StringMapVoid> = new StringMapVoid>(); + pageFields.set("size", function():Void { page.width = Std.parseInt(entry[1]); page.height = Std.parseInt(entry[2]); - }; - pageFields["format"] = function():Void { + }); + pageFields.set("format", function():Void { page.format = Format.fromName(entry[0]); - }; - pageFields["filter"] = function():Void { + }); + pageFields.set("filter", function():Void { page.minFilter = TextureFilter.fromName(entry[1]); page.magFilter = TextureFilter.fromName(entry[2]); - }; - pageFields["repeat"] = function():Void { + }); + pageFields.set("repeat", function():Void { if (entry[1].indexOf('x') != -1) page.uWrap = TextureWrap.repeat; if (entry[1].indexOf('y') != -1) page.vWrap = TextureWrap.repeat; - }; - pageFields["pma"] = function():Void { + }); + pageFields.set("pma", function():Void { page.pma = entry[1] == "true"; - }; + }); - var regionFields:DictionaryVoid> = new DictionaryVoid>(); - regionFields["xy"] = function():Void { + var regionFields:StringMapVoid> = new StringMapVoid>(); + regionFields.set("xy", function():Void { region.x = Std.parseInt(entry[1]); region.y = Std.parseInt(entry[2]); - }; - regionFields["size"] = function():Void { + }); + regionFields.set("size", function():Void { region.width = Std.parseInt(entry[1]); region.height = Std.parseInt(entry[2]); - }; - regionFields["bounds"] = function():Void { + }); + regionFields.set("bounds", function():Void { region.x = Std.parseInt(entry[1]); region.y = Std.parseInt(entry[2]); region.width = Std.parseInt(entry[3]); region.height = Std.parseInt(entry[4]); - }; - regionFields["offset"] = function():Void { + }); + regionFields.set("offset", function():Void { region.offsetX = Std.parseInt(entry[1]); region.offsetY = Std.parseInt(entry[2]); - }; - regionFields["orig"] = function():Void { + }); + regionFields.set("orig", function():Void { region.originalWidth = Std.parseInt(entry[1]); region.originalHeight = Std.parseInt(entry[2]); - }; - regionFields["offsets"] = function():Void { + }); + regionFields.set("offsets", function():Void { region.offsetX = Std.parseInt(entry[1]); region.offsetY = Std.parseInt(entry[2]); region.originalWidth = Std.parseInt(entry[3]); region.originalHeight = Std.parseInt(entry[4]); - }; - regionFields["rotate"] = function():Void { + }); + regionFields.set("rotate", function():Void { var value:String = entry[1]; if (value == "true") region.degrees = 90; else if (value != "false") region.degrees = Std.parseInt(value); - }; - regionFields["index"] = function():Void { + }); + regionFields.set("index", function():Void { region.index = Std.parseInt(entry[1]); - }; + }); var line:String = reader.readLine(); // Ignore empty lines before first entry. @@ -153,8 +149,8 @@ class TextureAtlas { } // Page and region entries. - var names:Vector = null; - var values:Vector> = null; + var names:Array = null; + var values:Array> = null; var field:Void->Void; while (true) { if (line == null) @@ -167,7 +163,7 @@ class TextureAtlas { while (true) { if (reader.readEntry(entry, line = reader.readLine()) == 0) break; - field = pageFields[entry[0]]; + field = pageFields.get(entry[0]); if (field != null) { field(); } @@ -180,16 +176,17 @@ class TextureAtlas { var count:Int = reader.readEntry(entry, line = reader.readLine()); if (count == 0) break; - field = regionFields[entry[0]]; + field = regionFields.get(entry[0]); if (field != null) { field(); } else { if (names == null) { - names = new Vector(); - values = new Vector>(); + names = new Array(); + values = new Array>(); } names.push(entry[0]); - var entryValues:Vector = new Vector(count, true); + var entryValues:Array = new Array(); + entryValues.resize(count); for (i in 0...count) { entryValues[i] = Std.parseInt(entry[i + 1]); } @@ -262,7 +259,7 @@ class Reader { return index >= lines.length ? null : lines[index++]; } - public function readEntry(entry:Vector, line:String):Int { + public function readEntry(entry:Array, line:String):Int { if (line == null) return 0; if (line.length == 0) diff --git a/spine-haxe/spine-haxe/spine/atlas/TextureAtlasRegion.hx b/spine-haxe/spine-haxe/spine/atlas/TextureAtlasRegion.hx index f1a537f24..dfa29c0c3 100644 --- a/spine-haxe/spine-haxe/spine/atlas/TextureAtlasRegion.hx +++ b/spine-haxe/spine-haxe/spine/atlas/TextureAtlasRegion.hx @@ -29,18 +29,16 @@ package spine.atlas; -import openfl.Vector; - class TextureAtlasRegion extends TextureRegion { public var page:TextureAtlasPage; public var name:String; public var x:Int = 0; public var y:Int = 0; public var index:Int = 0; - public var splits:Vector; - public var pads:Vector; - public var names:Vector; - public var values:Vector>; + public var splits:Array; + public var pads:Array; + public var names:Array; + public var values:Array>; public function new(page:TextureAtlasPage, name:String) { super(); diff --git a/spine-haxe/spine-haxe/spine/atlas/TextureFilter.hx b/spine-haxe/spine-haxe/spine/atlas/TextureFilter.hx index f492e9b75..86741c564 100644 --- a/spine-haxe/spine-haxe/spine/atlas/TextureFilter.hx +++ b/spine-haxe/spine-haxe/spine/atlas/TextureFilter.hx @@ -29,8 +29,6 @@ package spine.atlas; -import openfl.Vector; - class TextureFilter { public static var nearest(default, never):TextureFilter = new TextureFilter(0, "nearest"); 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 mipMapLinearLinear(default, never):TextureFilter = new TextureFilter(6, "mipMapLinearLinear"); - public static var values(default, never):Vector = Vector.ofArray([ + public static var values(default, never):Array = [ nearest, linear, mipMap, @@ -48,7 +46,7 @@ class TextureFilter { mipMapLinearNearest, mipMapNearestLinear, mipMapLinearLinear - ]); + ]; public var ordinal(default, null):Int; public var name(default, null):String; diff --git a/spine-haxe/spine-haxe/spine/atlas/TextureWrap.hx b/spine-haxe/spine-haxe/spine/atlas/TextureWrap.hx index d9d3a4659..0554e6330 100644 --- a/spine-haxe/spine-haxe/spine/atlas/TextureWrap.hx +++ b/spine-haxe/spine-haxe/spine/atlas/TextureWrap.hx @@ -29,14 +29,12 @@ package spine.atlas; -import openfl.Vector; - class TextureWrap { 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 repeat(default, never):TextureWrap = new TextureWrap(2, "repeat"); - public static var values(default, never):Vector = Vector.ofArray([mirroredRepeat, clampToEdge, repeat]); + public static var values(default, never):Array = [mirroredRepeat, clampToEdge, repeat]; public var ordinal(default, null):Int; public var name(default, null):String; diff --git a/spine-haxe/spine-haxe/spine/attachments/AttachmentType.hx b/spine-haxe/spine-haxe/spine/attachments/AttachmentType.hx index 8ebb7d913..cb4465812 100644 --- a/spine-haxe/spine-haxe/spine/attachments/AttachmentType.hx +++ b/spine-haxe/spine-haxe/spine/attachments/AttachmentType.hx @@ -29,8 +29,6 @@ package spine.attachments; -import openfl.Vector; - class AttachmentType { public static var region(default, never):AttachmentType = new AttachmentType(0, "region"); 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 clipping(default, never):AttachmentType = new AttachmentType(6, "clipping"); - public static var values(default, never):Vector = Vector.ofArray([region, boundingbox, mesh, linkedmesh, path, point, clipping]); + public static var values(default, never):Array = [region, boundingbox, mesh, linkedmesh, path, point, clipping]; public var ordinal(default, null):Int; public var name(default, null):String; diff --git a/spine-haxe/spine-haxe/spine/attachments/MeshAttachment.hx b/spine-haxe/spine-haxe/spine/attachments/MeshAttachment.hx index 977439214..d712f457d 100644 --- a/spine-haxe/spine-haxe/spine/attachments/MeshAttachment.hx +++ b/spine-haxe/spine-haxe/spine/attachments/MeshAttachment.hx @@ -29,21 +29,20 @@ package spine.attachments; -import openfl.Vector; import spine.Color; import spine.atlas.TextureAtlasRegion; class MeshAttachment extends VertexAttachment implements HasTextureRegion { public var region:TextureRegion; public var path:String; - public var regionUVs = new Vector(); - public var uvs = new Vector(); - public var triangles = new Vector(); + public var regionUVs = new Array(); + public var uvs = new Array(); + public var triangles = new Array(); public var color:Color = new Color(1, 1, 1, 1); public var width:Float = 0; public var height:Float = 0; public var hullLength:Int = 0; - public var edges = new Vector(); + public var edges = new Array(); public var rendererObject:Dynamic; public var sequence:Sequence; @@ -60,8 +59,10 @@ class MeshAttachment extends VertexAttachment implements HasTextureRegion { return; } var regionUVs = this.regionUVs; - if (uvs.length != regionUVs.length) - uvs = new Vector(regionUVs.length, true); + if (uvs.length != regionUVs.length) { + uvs = new Array(); + uvs.resize(regionUVs.length); + } var n = uvs.length; var u = region.u, v = region.v, width:Float = 0, height:Float = 0; if (Std.isOfType(region, TextureAtlasRegion)) { @@ -156,15 +157,15 @@ class MeshAttachment extends VertexAttachment implements HasTextureRegion { copy.rendererObject = rendererObject; this.copyTo(copy); - copy.regionUVs = regionUVs.concat(); - copy.uvs = uvs.concat(); - copy.triangles = triangles.concat(); + copy.regionUVs = regionUVs.copy(); + copy.uvs = uvs.copy(); + copy.triangles = triangles.copy(); copy.hullLength = hullLength; copy.sequence = sequence != null ? sequence.copy() : null; if (edges != null) { - copy.edges = edges.concat(); + copy.edges = edges.copy(); } copy.width = width; copy.height = height; @@ -172,7 +173,7 @@ class MeshAttachment extends VertexAttachment implements HasTextureRegion { return copy; } - public override function computeWorldVertices(slot:Slot, start:Int, count:Int, worldVertices:Vector, offset:Int, stride:Int):Void { + public override function computeWorldVertices(slot:Slot, start:Int, count:Int, worldVertices:Array, offset:Int, stride:Int):Void { if (sequence != null) sequence.apply(slot, this); super.computeWorldVertices(slot, start, count, worldVertices, offset, stride); diff --git a/spine-haxe/spine-haxe/spine/attachments/PathAttachment.hx b/spine-haxe/spine-haxe/spine/attachments/PathAttachment.hx index ead20adbb..51976d107 100644 --- a/spine-haxe/spine-haxe/spine/attachments/PathAttachment.hx +++ b/spine-haxe/spine-haxe/spine/attachments/PathAttachment.hx @@ -29,11 +29,10 @@ package spine.attachments; -import openfl.Vector; import spine.Color; class PathAttachment extends VertexAttachment { - public var lengths:Vector; + public var lengths:Array; public var closed:Bool = false; public var constantSpeed:Bool = false; public var color:Color = new Color(0, 0, 0, 0); @@ -45,7 +44,7 @@ class PathAttachment extends VertexAttachment { override public function copy():Attachment { var copy:PathAttachment = new PathAttachment(name); copyTo(copy); - copy.lengths = lengths.concat(); + copy.lengths = lengths.copy(); copy.closed = closed; copy.constantSpeed = constantSpeed; return copy; diff --git a/spine-haxe/spine-haxe/spine/attachments/PointAttachment.hx b/spine-haxe/spine-haxe/spine/attachments/PointAttachment.hx index cab84d42e..ec01ac494 100644 --- a/spine-haxe/spine-haxe/spine/attachments/PointAttachment.hx +++ b/spine-haxe/spine-haxe/spine/attachments/PointAttachment.hx @@ -29,7 +29,6 @@ package spine.attachments; -import openfl.Vector; import spine.Bone; import spine.Color; import spine.MathUtils; @@ -44,7 +43,7 @@ class PointAttachment extends VertexAttachment { super(name); } - public function computeWorldPosition(bone:Bone, point:Vector):Vector { + public function computeWorldPosition(bone:Bone, point:Array):Array { point[0] = x * bone.a + y * bone.b + bone.worldX; point[1] = x * bone.c + y * bone.d + bone.worldY; return point; diff --git a/spine-haxe/spine-haxe/spine/attachments/RegionAttachment.hx b/spine-haxe/spine-haxe/spine/attachments/RegionAttachment.hx index 9b7df0279..aec47acfb 100644 --- a/spine-haxe/spine-haxe/spine/attachments/RegionAttachment.hx +++ b/spine-haxe/spine-haxe/spine/attachments/RegionAttachment.hx @@ -29,8 +29,6 @@ package spine.attachments; -import openfl.Vector; -import spine.Bone; import spine.Color; class RegionAttachment extends Attachment implements HasTextureRegion { @@ -56,9 +54,9 @@ class RegionAttachment extends Attachment implements HasTextureRegion { public var region:TextureRegion; public var sequence:Sequence; - private var offsets:Vector = new Vector(8, true); + private var offsets:Array = new Array(); - public var uvs:Vector = new Vector(8, true); + public var uvs:Array = new Array(); public function new(name:String, path:String) { super(name); @@ -128,7 +126,7 @@ class RegionAttachment extends Attachment implements HasTextureRegion { } } - public function computeWorldVertices(slot:Slot, worldVertices:Vector, offset:Int, stride:Int):Void { + public function computeWorldVertices(slot:Slot, worldVertices:Array, offset:Int, stride:Int):Void { if (sequence != null) sequence.apply(slot, this); @@ -173,8 +171,8 @@ class RegionAttachment extends Attachment implements HasTextureRegion { copy.rotation = rotation; copy.width = width; copy.height = height; - copy.uvs = uvs.concat(); - copy.offsets = offsets.concat(); + copy.uvs = uvs.copy(); + copy.offsets = offsets.copy(); copy.color.setFromColor(color); copy.sequence = sequence != null ? sequence.copy() : null; return copy; diff --git a/spine-haxe/spine-haxe/spine/attachments/VertexAttachment.hx b/spine-haxe/spine-haxe/spine/attachments/VertexAttachment.hx index 1aa5222f5..ad12506d3 100644 --- a/spine-haxe/spine-haxe/spine/attachments/VertexAttachment.hx +++ b/spine-haxe/spine-haxe/spine/attachments/VertexAttachment.hx @@ -29,7 +29,6 @@ package spine.attachments; -import openfl.Vector; import spine.Bone; import spine.Skeleton; import spine.Slot; @@ -37,8 +36,8 @@ import spine.Slot; class VertexAttachment extends Attachment { private static var nextID:Int = 0; - public var bones:Vector; - public var vertices = new Vector(); + public var bones:Array; + public var vertices = new Array(); public var worldVerticesLength:Int = 0; public var id:Int = nextID++; public var timelineAttachment:VertexAttachment; @@ -59,10 +58,10 @@ class VertexAttachment extends Attachment { * `stride` / 2. * @param offset The `worldVertices` index to begin writing values. * @param stride The number of `worldVertices` entries between the value pairs written. */ - public function computeWorldVertices(slot:Slot, start:Int, count:Int, worldVertices:Vector, offset:Int, stride:Int):Void { + public function computeWorldVertices(slot:Slot, start:Int, count:Int, worldVertices:Array, offset:Int, stride:Int):Void { count = offset + (count >> 1) * stride; var skeleton:Skeleton = slot.skeleton; - var deform:Vector = slot.deform; + var deform:Array = slot.deform; var v:Int, w:Int, n:Int, i:Int, skip:Int, b:Int, f:Int; var vx:Float, vy:Float; @@ -100,7 +99,7 @@ class VertexAttachment extends Attachment { skip += n; i += 2; } - var skeletonBones:Vector = skeleton.bones; + var skeletonBones:Array = skeleton.bones; if (deform.length == 0) { w = offset; b = skip * 3; @@ -152,13 +151,13 @@ class VertexAttachment extends Attachment { public function copyTo(attachment:VertexAttachment):Void { if (bones != null) { - attachment.bones = bones.concat(); + attachment.bones = bones.copy(); } else { attachment.bones = null; } if (this.vertices != null) { - attachment.vertices = vertices.concat(); + attachment.vertices = vertices.copy(); } attachment.worldVerticesLength = worldVerticesLength; diff --git a/spine-haxe/spine-haxe/spine/starling/SkeletonSprite.hx b/spine-haxe/spine-haxe/spine/starling/SkeletonSprite.hx index 7445b074b..54fc057b7 100644 --- a/spine-haxe/spine-haxe/spine/starling/SkeletonSprite.hx +++ b/spine-haxe/spine-haxe/spine/starling/SkeletonSprite.hx @@ -30,7 +30,6 @@ package spine.starling; import starling.animation.IAnimatable; -import openfl.Vector; import openfl.geom.Matrix; import openfl.geom.Point; import openfl.geom.Rectangle; @@ -58,8 +57,8 @@ import starling.utils.Max; class SkeletonSprite extends DisplayObject implements IAnimatable { static private var _tempPoint:Point = new Point(); static private var _tempMatrix:Matrix = new Matrix(); - static private var _tempVertices:Vector = new Vector(); - static private var blendModes:Vector = Vector.ofArray([BlendMode.NORMAL, BlendMode.ADD, BlendMode.MULTIPLY, BlendMode.SCREEN]); + static private var _tempVertices:Array = new Array(); + static private var blendModes:Array = [BlendMode.NORMAL, BlendMode.ADD, BlendMode.MULTIPLY, BlendMode.SCREEN]; private var _skeleton:Skeleton; @@ -68,7 +67,7 @@ class SkeletonSprite extends DisplayObject implements IAnimatable { private var _smoothing:String = "bilinear"; private static var clipper:SkeletonClipping = new SkeletonClipping(); - private static var QUAD_INDICES:Vector = Vector.ofArray([0, 1, 2, 2, 3, 0]); + private static var QUAD_INDICES:Array = [0, 1, 2, 2, 3, 0]; private var tempLight: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 g:Float = skeleton.color.g * 255; var b:Float = skeleton.color.b * 255; - var drawOrder:Vector = skeleton.drawOrder; + var drawOrder:Array = skeleton.drawOrder; var attachmentColor:spine.Color; var rgb:Int; var a:Float; @@ -98,9 +97,9 @@ class SkeletonSprite extends DisplayObject implements IAnimatable { var verticesCount:Int; var indicesLength:Int; var indexData:IndexData; - var indices:Vector = null; + var indices:Array = null; var vertexData:VertexData; - var uvs:Vector; + var uvs:Array; for (slot in drawOrder) { if (!slot.bone.active) { @@ -108,13 +107,13 @@ class SkeletonSprite extends DisplayObject implements IAnimatable { continue; } - var worldVertices:Vector = _tempVertices; + var worldVertices:Array = _tempVertices; if (Std.isOfType(slot.attachment, RegionAttachment)) { var region:RegionAttachment = cast(slot.attachment, RegionAttachment); verticesLength = 8; verticesCount = verticesLength >> 1; if (worldVertices.length < verticesLength) - worldVertices.length = verticesLength; + worldVertices.resize(verticesLength); region.computeWorldVertices(slot, worldVertices, 0, 2); mesh = null; @@ -142,7 +141,7 @@ class SkeletonSprite extends DisplayObject implements IAnimatable { verticesLength = meshAttachment.worldVerticesLength; verticesCount = verticesLength >> 1; if (worldVertices.length < verticesLength) - worldVertices.length = verticesLength; + worldVertices.resize(verticesLength); meshAttachment.computeWorldVertices(slot, 0, meshAttachment.worldVerticesLength, worldVertices, 0, 2); mesh = null; @@ -237,8 +236,8 @@ class SkeletonSprite extends DisplayObject implements IAnimatable { var minY:Float = Max.MAX_VALUE; var maxX:Float = -Max.MAX_VALUE; var maxY:Float = -Max.MAX_VALUE; - var slots:Vector = skeleton.slots; - var worldVertices:Vector = _tempVertices; + var slots:Array = skeleton.slots; + var worldVertices:Array = _tempVertices; var empty:Bool = true; for (i in 0...slots.length) { var slot:Slot = slots[i]; @@ -254,7 +253,7 @@ class SkeletonSprite extends DisplayObject implements IAnimatable { var mesh:MeshAttachment = cast(attachment, MeshAttachment); verticesLength = mesh.worldVerticesLength; if (worldVertices.length < verticesLength) - worldVertices.length = verticesLength; + worldVertices.resize(verticesLength); mesh.computeWorldVertices(slot, 0, verticesLength, worldVertices, 0, 2); } else { continue;