flixel
flixel copied to clipboard
Add FlxG.centerGraphic() and camera.centerGraphic()
Closes #3309
Another attempt at #3310 based on Geokureli's suggestion.
Adds FlxG.centerGraphic() and camera.centerGraphic() for centering sprites by their graphic size and FlxG.centerHitbox() and camera.centerHitbox() for centering objects by their hitbox size.
To Do
- [x] Fix inconsistent behaviour of
FlxG.centerGraphic()andcamera.centerGraphic()on sprites withpixelPerfectPositionorpixelPerfectRenderflags set to true. - [x] Fix unit tests,
FlxGTest.testCenterGraphic()andFlxCameraTest.testCenterGraphic()are failing on rotated sprites for seemingly no reason. - [ ] Add docs for new methods.
I'm not really sure if reflection in c++ works when using generics.
Because both FlxG.random.shuffle and FlxG.random.getObject both don't exist in reflection due to generics
I'm not really sure if reflection in c++ works when using generics.
Because both FlxG.random.shuffle and FlxG.random.getObject both don't exist in reflection due to generics
As far as i know the reason why FlxG.random.shuffle and FlxG.random.getObject doesn't exist in reflection is due to @:generic metadata.
I've also made a small test to confirm that:
class Main {
static function main() {
var stringField:String;
var intField:Int;
var floatField:Float;
stringField = test1("some string");
intField = test1(30);
floatField = test1(1.0034);
stringField = test2("some string");
intField = test2(30);
floatField = test2(1.0034);
trace(Reflect.getProperty(Main, "test1")); // returns test1 function
trace(Reflect.getProperty(Main, "test2")); // returns null
}
static function test1<T>(v:T):T {
trace("test generic func #1 (" + Std.string(v) + ")");
return v;
}
@:generic
static function test2<T>(v:T):T {
trace("test generic func #2 (" + Std.string(v) + ")");
return v;
}
}
Damn, i wonder why haxe wouldn't generate a base one for reflection purposes
Fixed the shaking issue by adding "accurate" methods for getting sprite bounds which does not honor pixelPerfect properties.
Sorry, but this PR is gonna be put on hold for a bit, I have some relevant changes that need to go in first, though I'm a bit swamped with work atm
Fixed the shaking issue by adding "accurate" methods for getting sprite bounds which does not honor pixelPerfect properties.
Alternatively we can deprecate getScreenBounds in favor of getViewBounds that will have honorPixelPerfect argument. Just no longer like solution that i provided. Thoughts? (no hurry btw!)