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: Add FlxG.onMobile #1904

Merged
merged 3 commits into from
Aug 21, 2016
Merged
Show file tree
Hide file tree
Changes from 2 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
18 changes: 18 additions & 0 deletions flixel/FlxG.hx
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ class FlxG
*/
public static var drawFramerate(default, set):Int;

public static var onMobile(get, null):Bool;

public static var renderMethod(default, null):FlxRenderMethod;

public static var renderBlit(default, null):Bool;
Expand Down Expand Up @@ -707,6 +709,22 @@ class FlxG
{
return game._state;
}

private static inline function get_onMobile():Bool
{
if (onMobile == null)
Copy link
Member

Choose a reason for hiding this comment

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

What's the point of this check? Why not make it @:isVar public static var onMobile(get, never):Bool and

private static inline function get_onMobile():Bool {
   return #if js blah #elseif mobile true #else false #end;
}

{
#if js
onMobile = html5.onMobile;
#elseif mobile
onMobile = true;
#else
onMobile = false;
#end
}

return onMobile;
}
}

enum FlxRenderMethod
Expand Down
6 changes: 3 additions & 3 deletions flixel/system/frontEnds/HTML5FrontEnd.hx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class HTML5FrontEnd
{
public var browser(default, null):FlxBrowser;
public var platform(default, null):FlxPlatform;
public var isMobile(default, null):Bool;
public var onMobile(default, null):Bool;
public var browserWidth(get, never):Int;
public var browserHeight(get, never):Int;
public var browserPosition(get, null):FlxPoint;
Expand All @@ -21,7 +21,7 @@ class HTML5FrontEnd
{
browser = getBrowser();
platform = getPlatform();
isMobile = getIsMobile();
onMobile = getOnMobile();
}

private function getBrowser():FlxBrowser
Expand Down Expand Up @@ -90,7 +90,7 @@ class HTML5FrontEnd
else return FlxPlatform.UNKNOWN;
}

private function getIsMobile():Bool
private function getOnMobile():Bool
{
return
switch (platform)
Expand Down