Skip to content

Instantly share code, notes, and snippets.

@azrafe7
Created September 25, 2014 14:40
Show Gist options
  • Save azrafe7/324b4996411bd7254860 to your computer and use it in GitHub Desktop.
Save azrafe7/324b4996411bd7254860 to your computer and use it in GitHub Desktop.
FullScreen with HaxePunk 2.5.3
import com.haxepunk.Engine;
import com.haxepunk.HXP;
import com.haxepunk.Scene;
import com.haxepunk.utils.Input;
import com.haxepunk.utils.Key;
import flash.system.System;
import openfl.display.StageDisplayState;
import openfl.system.Capabilities;
class Main extends Engine {
public function new():Void
{
super();
HXP.console.enable();
HXP.fullscreen = true;
HXP.scene = new TestScene();
HXP.log("SCREEN: " + Capabilities.screenResolutionX + "x" + Capabilities.screenResolutionY + " " +
"HXP: " + HXP.width + "x" + HXP.height);
}
}
class TestScene extends Scene {
override public function update()
{
super.update();
if (Input.pressed(Key.SPACE)) { // use ESC to switch to normal mode in Flash
HXP.fullscreen = !HXP.fullscreen;
}
if (Input.check(Key.ESCAPE)) {
quit();
}
}
public function quit():Void
{
#if (flash || html5)
System.exit(1);
#else
Sys.exit(1);
#end
}
}
<?xml version="1.0" encoding="utf-8"?>
<project>
<!-- NMML reference: https://gist.github.com/1763850 -->
<!-- metadata, make sure 'package' is at least 3 segments (ie. com.mycompany.myproject) -->
<meta title="Test" package="com.haxepunk.tests" version="0.1" company="azrafe7" />
<!-- output -->
<app main="Main" file="Test" path="bin" />
<window background="#101010" fps="60" />
<window width="640" height="480" unless="mobile" />
<window orientation="landscape" vsync="false" antialiasing="0" if="cpp" />
<set name="SWF_VERSION" value="11.2" />
<!-- classpath, haxe libs -->
<source path="src" />
<haxelib name="openfl" />
<haxelib name="HaxePunk" />
<!-- compiler flags -->
<haxeflag name="--no-traces" if="release" />
<!--<haxeflag name="-v" />-->
<set name="SHOW_CONSOLE" value="1" if="debug" />
<!-- assets -->
<assets path="../assets/graphics" rename="graphics" include="*.png|*.jpg" />
<assets path="../assets/audio" rename="audio" include="*.mp3" if="flash" />
<assets path="../assets/audio" rename="audio" include="*.wav|*.ogg" unless="flash" />
<assets path="../assets/font" rename="font" include="*.ttf" />
<icon path="../assets/HaxePunk.svg" />
<!-- optimize output -->
<haxeflag name="-dce std" />
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment