-
Notifications
You must be signed in to change notification settings - Fork 435
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add "flipX / flipY" property to animations #1670
Conversation
… with FlxSprite's own flipX/flipY
I tried that first, but it's only a numeric operator, not a boolean. There's no boolean xor. |
You could also just use |
if (!doFlipX && !doFlipY && _frame.type == FlxFrameType.REGULAR) | ||
{ | ||
framePixels = _frame.paint(framePixels, _flashPointZero, false, true); | ||
} | ||
else | ||
{ | ||
framePixels = _frame.paintRotatedAndFlipped(framePixels, _flashPointZero, FlxFrameAngle.ANGLE_0, flipX, flipY, false, true); | ||
framePixels = _frame.paintRotatedAndFlipped(framePixels, _flashPointZero, FlxFrameAngle.ANGLE_0, checkFlipX(), checkFlipY(), false, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why call the check functions again here when the results are locally cached a few lines earlier in doFlipX
/ Y
?
Ah, you're right. Well in any case the logic as it stands now is what I actually intend. |
Ah. Well, in that case, I'd prefer the original approach, since doing it this way introduces some redundancy. :P |
To be clear, this is what you mean? private inline function checkFlipX():Bool
{
var doFlipX = (flipX != _frame.flipX);
if (animation.curAnim != null)
{
return (doFlipX != animation.curAnim.flipX);
}
return doFlipX;
} |
Yes. |
Cool. Incoming. |
Oh, right. Yeah this looks a bit nicer. |
Why are flipX and Y parameters added only to a couple of the flxanimcontroller functions? |
The use case I have in mind is that you set those when you create a new animation, so I put it in the functions that create new FlxAnimations. Are there some others you think it should be added to? If so, which ones? EDIT: Oh I see, I missed a bunch. |
👍 I guess it doesn't make sense adding it to |
I can't test it right now, but it looks fine to me. |
Bump for final review? |
Add "flipX / flipY" property to animations
...and also make it interact properly with FlxSprite's own flipX / flipY.
Rationale: for games with big sprite sheets, it can save a lot of memory to re-use frames in animations by vertically flipping them. So if I can re-use a walk cycle and just tell it to flip the frames right in the animation call, that's extremely convenient. Much easier to do than messing around with individual frames in the atlas.
Before this pull, we have had the ability to apply flipX/flipY to individual flxFrames (such as those loaded from an atlas) -- so this means the user can now set flipX/flipY in three places:
The effect should cascade properly. So you can have a particular frame in an animation that has flipX=true, used in an animation that has flipX=true, and then the sprite itself has flipX=true, which will resolve to true because (true XOR true XOR true) == true.