Skip to content

Commit

Permalink
Add a FlxAction demo (#268)
Browse files Browse the repository at this point in the history
  • Loading branch information
larsiusprime authored and Gama11 committed Sep 7, 2018
1 parent b53d0e5 commit 617fedc
Show file tree
Hide file tree
Showing 9 changed files with 642 additions and 0 deletions.
60 changes: 60 additions & 0 deletions Input/FlxAction/FlxAction.hxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="utf-8"?>
<project version="2">
<!-- Output SWF options -->
<output>
<movie outputType="CustomBuild" />
<movie input="" />
<movie path="Project.xml" />
<movie fps="60" />
<movie width="672" />
<movie height="480" />
<movie version="1" />
<movie minorVersion="0" />
<movie platform="Lime" />
<movie background="000000" />
</output>
<!-- Other classes to be compiled into your SWF -->
<classpaths>
<class path="T:\git\flixel" />
<class path="T:\git\openfl" />
<class path="T:\git\lime" />
<class path="C:\HaxeToolkit\haxe\lib\hscript\2,0,5" />
<class path="T:\git\flixel-addons" />
<class path="source" />
<class path="T:\git\openfl\extern" />
<class path="export\windows\neko\haxe" />
</classpaths>
<!-- Build options -->
<build>
<option directives="flixel=4.0.0&#xA;openfl=3.6.0&#xA;lime=2.9.0&#xA;hscript=2.0.5&#xA;flixel-addons=2.0.0&#xA;openfl-next&#xA;tools=2.9.0&#xA;NAPE_NO_INLINE&#xA;no-compilation&#xA;native&#xA;FLX_NO_TOUCH&#xA;lime-native&#xA;openfl-native&#xA;windows&#xA;desktop&#xA;display" />
<option flashStrict="False" />
<option noInlineOnDebug="False" />
<option mainClass="ApplicationMain" />
<option enabledebug="False" />
<option additional="--remap flash:openfl&#xA;--macro flixel.system.macros.FlxDefines.run()&#xA;#--macro keep(&quot;Main&quot;)&#xA;-debug " />
</build>
<!-- haxelib libraries -->
<haxelib>
<!-- example: <library name="..." /> -->
</haxelib>
<!-- Class files to compile (other referenced classes will automatically be included) -->
<compileTargets>
<!-- example: <compile path="..." /> -->
</compileTargets>
<!-- Paths to exclude from the Project Explorer tree -->
<hiddenPaths>
<hidden path="obj" />
</hiddenPaths>
<!-- Executed before build -->
<preBuildCommand>"$(CompilerPath)/haxelib" run lime build "$(OutputFile)" $(TargetBuild) -$(BuildConfig) -Dfdb</preBuildCommand>
<!-- Executed after build -->
<postBuildCommand alwaysRun="False" />
<!-- Other project options -->
<options>
<option showHiddenPaths="False" />
<option testMovie="Custom" />
<option testMovieCommand="" />
</options>
<!-- Plugin storage -->
<storage />
</project>
82 changes: 82 additions & 0 deletions Input/FlxAction/Project.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<!------------------------------APPLICATION SETTINGS---------------------------->

<app title="FlxAction" file="FlxAction" main="Main" version="0.0.1" company="HaxeFlixel" />

<!--The flixel preloader is not accurate in Chrome. You can use it regularly if you embed the swf into a html file
<!--or you can set the actual size of your file manually at "FlxPreloaderBase-onUpdate-bytesTotal"!-->
<app preloader="flixel.system.FlxPreloader" />

<!--Minimum without FLX_NO_GAMEPAD: 11.8, without FLX_NO_NATIVE_CURSOR: 11.2 -->
<set name="SWF_VERSION" value="11.8" />

<!--------------------------------WINDOW SETTINGS------------------------------->

<!--These window settings apply to all targets-->
<window width="672" height="480" fps="60" background="#000000" hardware="true" vsync="true" />

<!--HTML5-specific-->
<window if="html5" resizable="false" />

<!--Desktop-specific-->
<window if="desktop" orientation="landscape" fullscreen="false" resizable="true" />

<!--Mobile-specific-->
<window if="mobile" orientation="landscape" fullscreen="true" width="0" height="0" />

<!--------------------------------PATHS SETTINGS-------------------------------->

<set name="BUILD_DIR" value="export" />
<classpath name="source" />
<assets path="assets" />

<!--------------------------------LIBRARIES------------------------------------->

<haxelib name="flixel"/>

<!--In case you want to use the addons package-->
<haxelib name="flixel-addons" />

<!--In case you want to use the ui package-->
<!--<haxelib name="flixel-ui" />-->

<!--In case you want to use nape with flixel-->
<!--<haxelib name="nape" />-->

<!--------------------------------HAXEDEFINES----------------------------------->

<!--Enable the Flixel core recording system-->
<!--<haxedef name="FLX_RECORD" />-->

<!--Disable the right and middle mouse buttons-->
<!--<haxedef name="FLX_NO_MOUSE_ADVANCED" />-->

<!--Disable the Native cursor api for Flash target-->
<!--<haxedef name="FLX_NO_NATIVE_CURSOR" />-->

<!--Optimise inputs, be careful you will get null errors if you don't use conditionals in your game-->
<haxedef name="FLX_NO_MOUSE" if="mobile" />
<haxedef name="FLX_NO_KEYBOARD" if="mobile" />
<haxedef name="FLX_NO_TOUCH" if="desktop" />
<!--<haxedef name="FLX_NO_GAMEPAD" />-->

<!--Disable the Flixel core sound tray-->
<!--<haxedef name="FLX_NO_SOUND_TRAY" />-->

<!--Disable the Flixel sound management code-->
<!--<haxedef name="FLX_NO_SOUND_SYSTEM" />-->

<!--Disable the Flixel core focus lost screen-->
<!--<haxedef name="FLX_NO_FOCUS_LOST_SCREEN" />-->

<!--Disable the Flixel core debugger. Automatically gets set whenever you compile in release mode!-->
<haxedef name="FLX_NO_DEBUG" unless="debug" />

<!--Enable this for Nape release builds for a serious peformance improvement-->
<haxedef name="NAPE_RELEASE_BUILD" unless="debug" />

<!--------------------------------CUSTOM---------------------------------------->

<!--Place custom nodes like icons here (higher priority to override the HaxeFlixel icon)-->
</project>
26 changes: 26 additions & 0 deletions Input/FlxAction/assets/data/map.tmx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.0" orientation="orthogonal" renderorder="right-down" width="21" height="15" tilewidth="32" tileheight="32" nextobjectid="2">
<tileset firstgid="1" name="level" tilewidth="32" tileheight="32" tilecount="3" columns="3">
<image source="tilesheet.png" width="96" height="32"/>
</tileset>
<layer name="Background" width="21" height="15" visible="0">
<properties>
<property name="nocollide" value="true"/>
<property name="tileset" value="level"/>
</properties>
<data encoding="base64">
AgAAAAIAAAACAAAAAgAAAAIAAAACAAAAAgAAAAIAAAACAAAAAgAAAAIAAAACAAAAAgAAAAIAAAACAAAAAgAAAAIAAAACAAAAAgAAAAIAAAACAAAAAgAAAAIAAAACAAA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AAAIAAAACAAAAAgAAAAIAAAACAAAAAgAAAAIAAAACAAAAAgAAAAIAAAACAAAAAgAAAAIAAAACAAAAAgAAAAIAAAACAAAAAgAAAAIAAAACAAAAAgAAAAIAAAACAAAAAgAAAAIAAAACAAAAAgAAAAIAAAACAAAAAgAAAAIAAAACAAAAAgAAAAIAAAACAAAAAgAAAAIAAAACAAAAAgAAAAIAAAACAAAAAgAAAAIAAAACAAAAAgAAAAIAAAACAAAAAgAAAAIAAAACAAAAAgAAAAIAAAACAAAAAgAAAAIAAAACAAAAAgAAAAIAAAACAAAAAgAAAAIAAAACAAAAAgAAAAIAAAACAAAAAgAAAAIAAAACAAAAAgAAAAIAAAACAAAAAgAAAAIAAAACAAAAAgAAAAIAAAACAAAAAgAAAAIAAAACAAAAAgAAAAIAAAACAAAAAgAAAAIAAAACAAAA
</data>
</layer>
<layer name="Foreground" width="21" height="15">
<properties>
<property name="tileset" value="level"/>
</properties>
<data encoding="base64">
AwAAAAMAAAADAAAAAwAAAAMAAAADAAAAAwAAAAMAAAADAAAAAwAAAAMAAAADAAAAAwAAAAMAAAADAAAAAwAAAAMAAAADAAAAAwAAAAMAAAADAAAAAwAAAAMAAAADAAAAAwAAAAMAAAADAAAAAwAAAAMAAAADAAAAAwAAAAMAAAADAAAAAwAAAAMAAAADAAAAAwAAAAMAAAADAAAAAwAAAAMAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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AAAAAwAAAAMAAAADAAAAAwAAAAMAAAADAAAAAwAAAAMAAAADAAAAAwAAAAMAAAADAAAAAwAAAAMAAAADAAAA
</data>
</layer>
<objectgroup color="#b83333" name="player start" visible="0">
<object id="1" name="start" type="player_start" x="144" y="144" width="16" height="16"/>
</objectgroup>
</map>
Binary file added Input/FlxAction/assets/data/tilesheet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
77 changes: 77 additions & 0 deletions Input/FlxAction/source/AnalogWidget.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package;

import flixel.FlxG;
import flixel.group.FlxSpriteGroup;
import flixel.ui.FlxBar;

class AnalogWidget extends FlxSpriteGroup
{
public var xPos:Float = 0;
public var xNeg:Float = 0;
public var yPos:Float = 0;
public var yNeg:Float = 0;
public var l:Float = 0;
public var r:Float = 0;

var xAxisPos:FlxBar;
var yAxisPos:FlxBar;
var xAxisNeg:FlxBar;
var yAxisNeg:FlxBar;
var lBar:FlxBar;
var rBar:FlxBar;

public function new()
{
super();

xAxisPos = new FlxBar(0, 0, FlxBarFillDirection.LEFT_TO_RIGHT, 64, 16, this, "xPos", 0.0, 1.0, true);
xAxisNeg = new FlxBar(0, 0, FlxBarFillDirection.RIGHT_TO_LEFT, 64, 16, this, "xNeg", 0.0, 1.0, true);
yAxisPos = new FlxBar(0, 0, FlxBarFillDirection.TOP_TO_BOTTOM, 16, 64, this, "yPos", 0.0, 1.0, true);
yAxisNeg = new FlxBar(0, 0, FlxBarFillDirection.BOTTOM_TO_TOP, 16, 64, this, "yNeg", 0.0, 1.0, true);
lBar = new FlxBar(0, 0, FlxBarFillDirection.BOTTOM_TO_TOP, 16, 144, this, "l", 0.0, 1.0, true);
rBar = new FlxBar(0, 0, FlxBarFillDirection.BOTTOM_TO_TOP, 16, 144, this, "r", 0.0, 1.0, true);

xAxisPos.x = (xAxisPos.height) / 2;
xAxisPos.y = -(xAxisPos.height) / 2;

xAxisNeg.x = -(xAxisNeg.width) - (xAxisPos.height / 2);
xAxisNeg.y = -(xAxisNeg.height) / 2;

yAxisPos.x = -(yAxisPos.width) / 2;
yAxisPos.y = (yAxisNeg.width / 2);

yAxisNeg.x = -(yAxisNeg.width) / 2;
yAxisNeg.y = -(yAxisPos.height) - (yAxisPos.width / 2);

lBar.x = xAxisNeg.x - lBar.width - 8;
rBar.x = xAxisPos.x + xAxisPos.width + 8;
lBar.y = rBar.y = yAxisNeg.y;

add(xAxisPos);
add(xAxisNeg);
add(yAxisPos);
add(yAxisNeg);
add(lBar);
add(rBar);

var xoff = FlxG.width - width/2 - 5;
var yoff = FlxG.height - height/2 - 5;

x = xoff;
y = yoff;
}

public function setValues(X:Float, Y:Float):Void
{
xPos = 0;
xNeg = 0;
yPos = 0;
yNeg = 0;

if (X > 0) xPos = X;
else xNeg = -X;

if (Y > 0) yPos = Y;
else yNeg = -Y;
}
}
13 changes: 13 additions & 0 deletions Input/FlxAction/source/Main.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package;

import flixel.FlxGame;
import openfl.display.Sprite;

class Main extends Sprite
{
public function new()
{
super();
addChild(new FlxGame(672, 480, PlayState));
}
}
57 changes: 57 additions & 0 deletions Input/FlxAction/source/PlayState.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package;

import flixel.FlxG;
import flixel.FlxState;
import flixel.text.FlxText;

class PlayState extends FlxState
{
public var player:Player;
var _level:TiledLevel;
var _howto:FlxText;

override public function create():Void
{
FlxG.mouse.visible = false;
bgColor = 0xFF18A068;

// Load the level's tilemaps
_level = new TiledLevel("assets/data/map.tmx");

// Add tilemaps
add(_level.backgroundTiles);

// Add tilemaps
add(_level.foregroundTiles);

// Load player and objects of the Tiled map
_level.loadObjects(this);

#if !mobile
// Set and create Txt Howto
_howto = new FlxText(0, 20, FlxG.width);
_howto.scale.set(2, 2);
_howto.alignment = CENTER;
_howto.text = "Digital: ARROWS, WASD, D-PAD, BUTTONS, LEFT STICK\nAnalog: MOUSE motion, RIGHT STICK, TRIGGERS";
_howto.scrollFactor.set(0, 0);
add(_howto);
#end
}

override public function update(elapsed:Float):Void
{
super.update(elapsed);

// Collide with foreground tile layer
_level.collideWithLevel(player);
}

override public function destroy():Void
{
super.destroy();

player = null;
_level = null;
_howto = null;
}
}
Loading

0 comments on commit 617fedc

Please sign in to comment.