@@ -105,10 +105,8 @@ class FlxFrame implements IFlxDestroyable
105105
106106 /**
107107 * UV coordinates for this frame.
108- * WARNING: For optimization purposes, width and height of this rect
109- * contain right and bottom coordinates (`x + width` and `y + height`).
110108 */
111- public var uv : FlxRect ;
109+ public var uv : FlxUVRect ;
112110
113111 public var parent : FlxGraphic ;
114112
@@ -683,6 +681,7 @@ class FlxFrame implements IFlxDestroyable
683681 clone .frame = FlxRect .get ().copyFrom (frame );
684682 clone .type = type ;
685683 clone .name = name ;
684+ clone .duration = duration ;
686685 clone .cacheFrameMatrix ();
687686 return clone ;
688687 }
@@ -709,7 +708,7 @@ class FlxFrame implements IFlxDestroyable
709708 if (value != null )
710709 {
711710 if (uv == null )
712- uv = FlxRect .get ();
711+ uv = FlxUVRect .get ();
713712
714713 uv .set (value .x / parent .width , value .y / parent .height , value .right / parent .width , value .bottom / parent .height );
715714 }
@@ -736,3 +735,50 @@ enum abstract FlxFrameAngle(Int) from Int to Int
736735 var ANGLE_NEG_90 = - 90 ;
737736 var ANGLE_270 = - 90 ;
738737}
738+
739+ /**
740+ * FlxRect, but instead of `x`, `y`, `width` and `height`, it takes a `left`, `right`, `top` and
741+ * `bottom`. This is for optimization reasons, to reduce arithmetic when drawing vertices
742+ */
743+ @:forward (put )
744+ abstract FlxUVRect (FlxRect ) from FlxRect to flixel.util. FlxPool . IFlxPooled
745+ {
746+ public var left (get , set ): Float ;
747+ inline function get_left (): Float { return this .x ; }
748+ inline function set_left (value ): Float { return this .x = value ; }
749+
750+ /** Top */
751+ public var right (get , set ): Float ;
752+ inline function get_right (): Float { return this .y ; }
753+ inline function set_right (value ): Float { return this .y = value ; }
754+
755+ /** Right */
756+ public var top (get , set ): Float ;
757+ inline function get_top (): Float { return this .width ; }
758+ inline function set_top (value ): Float { return this .width = value ; }
759+
760+ /** Bottom */
761+ public var bottom (get , set ): Float ;
762+ inline function get_bottom (): Float { return this .height ; }
763+ inline function set_bottom (value ): Float { return this .height = value ; }
764+
765+ public inline function set (l , t , r , b )
766+ {
767+ this .set (l , t , r , b );
768+ }
769+
770+ public inline function copyTo (uv : FlxUVRect )
771+ {
772+ uv .set (left , top , right , bottom );
773+ }
774+
775+ public inline function copyFrom (uv : FlxUVRect )
776+ {
777+ set (uv .left , uv .top , uv .right , uv .bottom );
778+ }
779+
780+ public static function get (l = 0.0 , t = 0.0 , r = 0.0 , b = 0.0 )
781+ {
782+ return FlxRect .get (l , t , r , b );
783+ }
784+ }
0 commit comments