Explorar o código

minor getSize() fix + empty out bounds parameter in getBounds/getSize

ncannasse %!s(int64=9) %!d(string=hai) anos
pai
achega
767a3e5802
Modificáronse 1 ficheiros con 4 adicións e 2 borrados
  1. 4 2
      h2d/Sprite.hx

+ 4 - 2
h2d/Sprite.hx

@@ -50,7 +50,7 @@ class Sprite {
 		You can pass an already allocated bounds or getBounds will allocate one for you and return it.
 		You can pass an already allocated bounds or getBounds will allocate one for you and return it.
 	**/
 	**/
 	public function getBounds( ?relativeTo : Sprite, ?out : h2d.col.Bounds ) : h2d.col.Bounds {
 	public function getBounds( ?relativeTo : Sprite, ?out : h2d.col.Bounds ) : h2d.col.Bounds {
-		if( out == null ) out = new h2d.col.Bounds();
+		if( out == null ) out = new h2d.col.Bounds() else out.empty();
 		if( relativeTo != null )
 		if( relativeTo != null )
 			relativeTo.syncPos();
 			relativeTo.syncPos();
 		if( relativeTo != this )
 		if( relativeTo != this )
@@ -70,7 +70,9 @@ class Sprite {
 		the full glyphs size whereas getSize() will ignore the pixels under the baseline.
 		the full glyphs size whereas getSize() will ignore the pixels under the baseline.
 	**/
 	**/
 	public function getSize( ?out : h2d.col.Bounds ) : h2d.col.Bounds {
 	public function getSize( ?out : h2d.col.Bounds ) : h2d.col.Bounds {
-		if( out == null ) out = new h2d.col.Bounds();
+		if( out == null ) out = new h2d.col.Bounds() else out.empty();
+		if( parent != null )
+			parent.syncPos();
 		getBoundsRec(parent, out, true);
 		getBoundsRec(parent, out, true);
 		if( out.isEmpty() ) {
 		if( out.isEmpty() ) {
 			addBounds(parent, out, -1, -1, 2, 2);
 			addBounds(parent, out, -1, -1, 2, 2);