-
Notifications
You must be signed in to change notification settings - Fork 450
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 FlxObject.defaultMoves field #2980
Conversation
this is just useless, it's already got a default value, why need a variable for that? and you can just use |
because this is a static var that determines the default value of every FlxObject created, similar to FlxSprite.defaultAntiAliasing |
I mean, that’s great but this probably should be in FlxG like you suggested earlier since it would make it in line with the other code, in contrast with defaultAntialiasing |
Having statics in FlxObject and FlxSprite is actually the current convention, in the future these might move to FlxG, and when that happens we can move this too. But its gonna take some planning before that happens so lets just make a static in FlxObject for now |
sounds good |
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.
almost all good, but one point still remains
Few notes:
- static fields should come before instance fields. this should be moved so it is just after defaultPixelPerfectPositioning which is on line 80
Edit: looks like you fixed this
I notice this comment on
can you confirm that FlxText, FlxTilemap and FlxTileBlock default to false even when defaultMoves is true? In fact we should probably have unit tests that verify this |
in the future, please do not make PRs to flixel using your fork's dev branch, create a new feature branch, so it's easier for others to test and make changes to it |
tested this with the following code, it works fine package states;
import flixel.FlxG;
import flixel.FlxObject;
import flixel.FlxSprite;
import flixel.text.FlxText;
import flixel.tile.FlxTilemap;
import flixel.tile.FlxTileblock;
class DefaultMovesTestState2980 extends flixel.FlxState
{
override function create()
{
super.create();
assertMoves(new FlxObject());
assertMoves(new FlxSprite());
assertNotMoves(new FlxText());
assertNotMoves(new FlxTilemap());
assertNotMoves(new FlxTileblock(0, 0, 1, 1));
FlxObject.defaultMoves = false;
assertNotMoves(new FlxObject());
assertNotMoves(new FlxSprite());
assertNotMoves(new FlxText());
assertNotMoves(new FlxTilemap());
assertNotMoves(new FlxTileblock(0, 0, 1, 1));
FlxObject.defaultMoves = true;
assertMoves(new FlxObject());
assertMoves(new FlxSprite());
assertNotMoves(new FlxText());
assertNotMoves(new FlxTilemap());
assertNotMoves(new FlxTileblock(0, 0, 1, 1));
}
function assertMoves(obj:FlxObject)
{
if (obj.moves == false)
throw 'Expected obj: $obj, moves:TRUE, got FALSE';
}
function assertNotMoves(obj:FlxObject)
{
if (obj.moves)
throw 'Expected obj: $obj, moves:FALSE, got TRUE';
}
} |
Simple static variable to change the default value of
moves