Skip to content
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

FlxG.camera.bgColor isn't reset on state switch #3252

Closed
DetectiveBaldi opened this issue Sep 18, 2024 · 3 comments
Closed

FlxG.camera.bgColor isn't reset on state switch #3252

DetectiveBaldi opened this issue Sep 18, 2024 · 3 comments
Labels
Milestone

Comments

@DetectiveBaldi
Copy link
Contributor

DetectiveBaldi commented Sep 18, 2024

I'm not sure if this is intentional, but it seems this getter for FlxG.cameras.bgColor is the cause.
When FlxG.cameras.reset is called when switching states, a new camera is created, but because of this getter, it ends up taking the bgColor from the last FlxG.camera.
I'm not sure why this getter exists, in my opinion it makes more sense for FlxG.cameras.bgColor to just be a setter that isn't automatically determined by the bgColor of FlxG.camera.
If there is a reason for this or if it is actually a bug, I would like to know. In my opinion it seems like strange behavior.

@Geokureli Geokureli added this to the 6.0.0 milestone Sep 18, 2024
@Geokureli
Copy link
Member

Geokureli commented Sep 18, 2024

yeah this seems unintentional, but I do think this is kind of a breaking change, so I'm adding it to the 6.0.0 release, so we can add it to the migration guide

couple solutions:

  1. Calling FlxG.cameras.reset will set the bgColor back to the default, by setting FlxG.camera = null; before creating the new cam
  2. Somewhere in the state switching process before cameras are reset, FlxG.camera.bgColor is set to the default color, this means direct calls toFlxG.cameras.reset will not change the bgColor, but state switches will

I'm leaning towards 1

I also don't like the fact that CameraFrontEnd.bgColor's setter/getter reads/writes to/from cameras, and wouldn't mind if it was actually a variable, that camera's used when they have a null/uninitialized bgColor, but that seems like topic for another day, and would still require one of the solutions above

@DetectiveBaldi
Copy link
Contributor Author

DetectiveBaldi commented Sep 18, 2024

Yeah I understand merging something like this into 6.0.0. I honestly would vouch for removing the writing bgColor does to existing cameras in the same pull request, I think it's related enough.
Either way I can have a pull request fixing this issue in a couple hours.

@Geokureli
Copy link
Member

Looks like "Closes: [issue number]" doesn't actually close them. In the future try, "Fixes", instead. i tried editing it but that didn't work because only happens when it's merged, I presume

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants