-
Notifications
You must be signed in to change notification settings - Fork 494
Add FlxG.centerGraphic() and camera.centerGraphic() #3329
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
base: 6.2.0
Are you sure you want to change the base?
Changes from 1 commit
ec3b8c5
c4a41ff
55ace96
5603edd
a593d5a
f720a2b
ea9c93f
5b47432
cbf91ce
e3f9d55
7628284
6caea68
e38d45b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1883,6 +1883,12 @@ class FlxCamera extends FlxBasic | |
| */ | ||
| public function center<T:FlxSprite>(sprite:T, axes:FlxAxes = XY):T | ||
| { | ||
| // We need to disable these flags to get accurate graphic bounds | ||
| final pixelPerfectPosition = sprite.pixelPerfectPosition; | ||
| final pixelPerfectRender = sprite.pixelPerfectRender; | ||
| sprite.pixelPerfectPosition = false; | ||
| @:bypassAccessor sprite.pixelPerfectRender = false; | ||
|
||
|
|
||
| final graphicBounds = sprite.getScreenBounds(null, this); | ||
|
|
||
| if (axes.x) | ||
|
|
@@ -1897,6 +1903,9 @@ class FlxCamera extends FlxBasic | |
| sprite.y = (height - graphicBounds.height) / 2 + offset; | ||
| } | ||
|
|
||
| // Now we set flags back to their original state | ||
| sprite.pixelPerfectPosition = pixelPerfectPosition; | ||
| @:bypassAccessor sprite.pixelPerfectRender = pixelPerfectRender; | ||
| graphicBounds.put(); | ||
| return sprite; | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.