Skip to content

Commit

Permalink
a little bit better version of the latest change (imho)
Browse files Browse the repository at this point in the history
  • Loading branch information
Beeblerox committed Nov 8, 2015
1 parent 970c7ca commit 81c3dd0
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions flixel/FlxSprite.hx
Expand Up @@ -258,16 +258,21 @@ class FlxSprite extends FlxObject
colorTransform = null;
blend = null;

destroyInnerFrameGraphic();

frames = null;
graphic = null;
_frame = FlxDestroyUtil.destroy(_frame);
}

private inline function destroyInnerFrameGraphic():Void
{
#if FLX_RENDER_TILE
if (_frame != null && frame != null && frame.parent != _frame.parent)
{
_frame.parent.destroy();
}
#end

frames = null;
graphic = null;
_frame = FlxDestroyUtil.destroy(_frame);
}

public function clone():FlxSprite
Expand Down Expand Up @@ -506,6 +511,15 @@ class FlxSprite extends FlxObject
height = frameHeight;
}

/**
* Helper method just for convinience, so you don't need to type:
* sprite.frame = sprite.frame;
*/
public inline function resetFrame():Void
{

This comment has been minimized.

Copy link
@gamedevsam

gamedevsam Nov 8, 2015

Contributor

What does this do exactly?

This comment has been minimized.

Copy link
@Beeblerox

Beeblerox Nov 8, 2015

Author Member

i've added this method for the user convinience:
if you calculate (generate) framePixels of the sprite then it will use it for rendering in tile render mode (which means more draw calls, since framePixels will be unique bitmap and will break batching).
But if you reset frame of sprite then it will use original graphic, like if there is no calculated framePixels (framePixels will be ignored)

This comment has been minimized.

Copy link
@gamedevsam

gamedevsam Nov 8, 2015

Contributor

Ahh, thanks for the explanation! 👍

frame = this.frame;
}

/**
* Helper function to set the graphic's dimensions by using scale, allowing you to keep the current aspect ratio
* should one of the Integers be <= 0. It might make sense to call updateHitbox() afterwards!
Expand Down Expand Up @@ -926,11 +940,7 @@ class FlxSprite extends FlxObject

// recreate _frame for native target, so it will use modified framePixels
#if FLX_RENDER_TILE
if (frame.parent != _frame.parent)
{
_frame.parent.destroy();
}

destroyInnerFrameGraphic();
var graph:FlxGraphic = FlxGraphic.fromBitmapData(framePixels, false, null, false);
_frame = graph.imageFrame.frame.copyTo(_frame);
#end
Expand Down

6 comments on commit 81c3dd0

@MSGhero
Copy link
Member

@MSGhero MSGhero commented on 81c3dd0 Nov 8, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this affect #1593 at all? I'm not really sure what tile render mode is.

@Beeblerox
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MSGhero no, it doesn't affect this issue at all. As you may know i've started work on it earlier, but haven't finished it. I will write down my thoughts on it next week on slack (i want to break some existing behavior, like origin handling).

@xbelanch
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if this is the right place but only want to say that FlxGlitchSprite seems to stop working properly after last commit.

@Beeblerox
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xbelanch probably i know what's the problem. I'll try to fix it tonight

@Beeblerox
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xbelanch it should be fixed now

@xbelanch
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Beeblerox Thanks! it works like a charm

Please sign in to comment.