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

Auto detect window size and etc. #1811

Merged
merged 22 commits into from
Apr 11, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions flixel/FlxGame.hx
Original file line number Diff line number Diff line change
Expand Up @@ -223,16 +223,16 @@ class FlxGame extends Sprite
/**
* Instantiate a new game object.
*
* @param GameSizeX The width of your game in game pixels, not necessarily final display pixels (see Zoom).
* @param GameSizeY The height of your game in game pixels, not necessarily final display pixels (see Zoom).
* @param GameSizeX The width of your game in game pixels, not necessarily final display pixels (see Zoom). If it is not a positive number, HaxeFlixel will auto detect the width according to the current window.
* @param GameSizeY The height of your game in game pixels, not necessarily final display pixels (see Zoom). If it is not a positive number, HaxeFlixel will auto detect the height according to the current window.
* @param InitialState The class name of the state you want to create and switch to first (e.g. MenuState).
* @param Zoom The default level of zoom for the game's cameras (e.g. 2 = all pixels are now drawn at 2x). Default = 1.
* @param UpdateFramerate How frequently the game should update (default is 60 times per second).
* @param DrawFramerate Sets the actual display / draw framerate for the game (default is 60 times per second).
* @param SkipSplash Whether you want to skip the flixel splash screen in FLX_NO_DEBUG or not.
* @param StartFullscreen Whether to start the game in fullscreen mode (desktop targets only), false by default
*/
public function new(GameSizeX:Int = 640, GameSizeY:Int = 480, ?InitialState:Class<FlxState>, Zoom:Float = 1, UpdateFramerate:Int = 60, DrawFramerate:Int = 60, SkipSplash:Bool = false, StartFullscreen:Bool = false)
public function new(GameSizeX:Int = 0, GameSizeY:Int = 0, ?InitialState:Class<FlxState>, Zoom:Float = 1, UpdateFramerate:Int = 60, DrawFramerate:Int = 60, SkipSplash:Bool = false, StartFullscreen:Bool = false)
{
super();

Expand All @@ -243,6 +243,14 @@ class FlxGame extends Sprite
// Super high priority init stuff
_inputContainer = new Sprite();

if (GameSizeX <= 0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should stick to only == 0. Something like new FlxGame(-10, -50, PlayState) would result in windowSize x windowHeight, which seems a little weird.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I don't understand what do you mean by windowSize x windowHeight.
Another reason I can think of is to reserve the negative values for possible more implements in the future.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant windowWidth x windowHeight.

What I meant is that it seems confusing to the reader that random negative values would turn into a FlxGame instance which uses the window dimensions, wheareas with 0, you can at least guess that it probably has some special meaning.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the comments, so it is easier to be understood.
Just think if somehow a negative value is passed in, FlxGame can deal with it.

{
GameSizeX = Std.int(Lib.current.stage.stageWidth);
}
if (GameSizeY <= 0)
{
GameSizeY = Std.int(Lib.current.stage.stageHeight);
}
// Basic display and update setup stuff
FlxG.init(this, GameSizeX, GameSizeY, Zoom);

Expand Down
13 changes: 13 additions & 0 deletions flixel/math/FlxPoint.hx
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,19 @@ class FlxPoint implements IFlxPooled
return this;
}

/**
* Scale this point.
*
* @param k - scale coefficient
* @return scaled point
*/
public function scale(k:Float):FlxPoint
{
x *= k;
y *= k;
return this;
}

/**
* Helper function, just copies the values from the specified point.
*
Expand Down
2 changes: 1 addition & 1 deletion flixel/math/FlxVector.hx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class FlxVector extends FlxPoint
* @param k - scale coefficient
* @return scaled vector
*/
public inline function scale(k:Float):FlxVector
public override function scale(k:Float):FlxVector
{
x *= k;
y *= k;
Expand Down
4 changes: 2 additions & 2 deletions flixel/text/FlxText.hx
Original file line number Diff line number Diff line change
Expand Up @@ -1062,10 +1062,10 @@ class FlxTextFormat
private var format(default, null):TextFormat;

/**
* @param FontColor Set the font color. By default, inherits from the default format.
* @param FontColor Set the font color, in 0xRRGGBB format. By default, inherits from the default format.
* @param Bold Set the font to bold. The font must support bold. By default, false.
* @param Italic Set the font to italics. The font must support italics. Only works in Flash. By default, false.
* @param BorderColor Set the border color. By default, no border (null / transparent).
* @param BorderColor Set the border color, in 0xAARRGGBB format. By default, no border (null / transparent).
*/
public function new(?FontColor:FlxColor, ?Bold:Bool, ?Italic:Bool, ?BorderColor:FlxColor)
{
Expand Down