Last active
April 26, 2017 10:53
-
-
Save theRemix/7459357 to your computer and use it in GitHub Desktop.
Main class for HaxePunk with variable screen size for mobile, tablet, and desktop
discussion: http://www.openfl.org/community/general-discussion/developing-multiple-devices-screen-sizes/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package scenes; | |
| import com.haxepunk.Scene; | |
| class GameScene extends Scene | |
| { | |
| public function new() | |
| { | |
| super(); | |
| } | |
| public override function begin() | |
| { | |
| } | |
| public override function update() | |
| { | |
| super.update(); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package; | |
| import flash.Lib; | |
| import flash.display.Sprite; | |
| import com.haxepunk.Engine; | |
| class Main extends Sprite | |
| { | |
| public static var engine:Engine; | |
| public function new() | |
| { | |
| super(); | |
| var _stageWidth:Int = Lib.current.stage.stageWidth; | |
| var _stageHeight:Int = Lib.current.stage.stageHeight; | |
| var baseGameWidth = 0; | |
| var baseGameHeight = 0; | |
| //Check to see if the device is tablet sized | |
| if(_stageWidth >= 1024 || _stageHeight >= 1024){ | |
| baseGameWidth = 1024; | |
| baseGameHeight = 768; | |
| }else{ | |
| baseGameWidth = 640; | |
| baseGameHeight = 480; | |
| } | |
| engine = new Engine(baseGameWidth,baseGameHeight,60); //Use the base Game Size | |
| addChild(engine); | |
| engine.scaleX = _stageWidth/baseGameWidth; | |
| engine.scaleY = _stageHeight/baseGameHeight; | |
| #if debug | |
| HXP.console.enable(); | |
| #end | |
| HXP.scene = new scenes.GameScene(); | |
| } | |
| public static function main() { Lib.current.addChild(new Main()); } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="utf-8"?> | |
| <project> | |
| <meta title="MyGame" package="com.example.MyGame" version="0.0.1" company="My Company" /> | |
| <app main="Main" path="Export" file="MyGame" /> | |
| <window fps="30" background="0x333333" /> | |
| <window width="1024" height="768" unless="mobile" /> | |
| <window width="0" height="0" if="mobile" /> | |
| <window fullscreen="true" if="mobile" /> | |
| <window orientation="landscape" vsync="true" antialiasing="0" if="cpp" /> | |
| <source path="Source" /> | |
| <haxelib name="openfl" /> | |
| <haxelib name="openfl-bitfive" if="html5" /> | |
| <haxelib name="HaxePunk" /> | |
| <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" /> | |
| </project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment