Skip to content

Commit

Permalink
DisplayObject: Replace Vector with Array
Browse files Browse the repository at this point in the history
  • Loading branch information
dimensionscape committed Jul 10, 2024
1 parent 86ec55d commit 1163b16
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/starling/animation/Juggler.hx
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ class Juggler implements IAnimatable {

while (i < numObjects)
__objects[currentIndex++] = __objects[i++];

#if (haxe_ver >= 4.0)
__objects.resize(currentIndex);
#else
Expand Down
12 changes: 8 additions & 4 deletions src/starling/display/DisplayObject.hx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import openfl.geom.Vector3D;
import openfl.system.Capabilities;
import openfl.ui.Mouse;
import openfl.ui.MouseCursor;
import openfl.Vector;

import starling.core.Starling;
import starling.errors.AbstractMethodError;
Expand All @@ -40,6 +39,7 @@ import starling.utils.Color;
import starling.utils.MathUtil;
import starling.utils.MatrixUtil;
import starling.utils.SystemUtil;
import starling.utils.ArrayUtil;

/** Dispatched when an object is added to a parent. */
@:meta(Event(name="added", type="starling.events.Event"))
Expand Down Expand Up @@ -159,7 +159,7 @@ class DisplayObject extends EventDispatcher

// helper objects

private static var sAncestors:Vector<DisplayObject> = new Vector<DisplayObject>();
private static var sAncestors:Array<DisplayObject> = new Array<DisplayObject>();
private static var sHelperPoint:Point = new Point();
private static var sHelperPoint3D:Vector3D = new Vector3D();
private static var sHelperPointAlt3D:Vector3D = new Vector3D();
Expand Down Expand Up @@ -627,7 +627,7 @@ class DisplayObject extends EventDispatcher
}

/** Transforms a point from global (stage) coordinates to the 3D local coordinate system.
* If you pass an <code>out</code>-vector, the result will be stored in this point instead of
* If you pass an <code>out</code>-Array, the result will be stored in this point instead of
* creating a new object. */
public function globalToLocal3D(globalPoint:Point, out:Vector3D=null):Vector3D
{
Expand Down Expand Up @@ -797,7 +797,11 @@ class DisplayObject extends EventDispatcher
while (currentObject != null && sAncestors.indexOf(currentObject) == -1)
currentObject = currentObject.__parent;

sAncestors.length = 0;
#if (haxe_ver >= 4.0)
sAncestors.resize(0);
#else
ArrayUtil.resize(sAncestors, 0);
#end

if (currentObject != null) return currentObject;
else throw new ArgumentError("Object not connected to target");
Expand Down

0 comments on commit 1163b16

Please sign in to comment.