From 493fe254013ea22dafd40e9531ef7f997e38fb33 Mon Sep 17 00:00:00 2001 From: George Kurelic Date: Tue, 27 Feb 2024 21:25:31 -0800 Subject: [PATCH] Flixel 6 compatibility (#331) * remove warnings (for flixel 6) * fix demos for flixel 6 --- .vscode/settings.json | 92 ++++++++++- Arcade/Breakout/source/PlayState.hx | 2 +- Arcade/FlxLightPuzzle/source/Color.hx | 3 +- Arcade/FlxPongApi/source/MenuState.hx | 4 +- Arcade/FlxPongApi/source/PlayState.hx | 4 +- Arcade/FlxTeroids/source/MenuState.hx | 2 +- Arcade/FlxTeroids/source/PlayState.hx | 2 +- Arcade/MinimalistTD/source/MenuState.hx | 2 +- Arcade/MinimalistTD/source/PlayState.hx | 2 +- Effects/BlendModeShaders/source/Main.hx | 1 - Effects/BlendModeShaders/source/PlayState.hx | 19 +-- .../{openfl8 => }/blends/ColorBurnShader.hx | 2 +- .../{openfl8 => }/blends/HardMixShader.hx | 2 +- .../{openfl8 => }/blends/LightenShader.hx | 2 +- .../{openfl8 => }/blends/LinearDodgeShader.hx | 2 +- .../{openfl8 => }/blends/MultiplyShader.hx | 2 +- .../{openfl8 => }/blends/VividLightShader.hx | 2 +- .../{openfl8 => }/effects/BlendModeEffect.hx | 10 +- .../{openfl8 => }/effects/ColorSwapEffect.hx | 24 +-- .../{openfl8 => }/effects/ShutterEffect.hx | 28 ++-- .../{openfl8 => }/effects/WiggleEffect.hx | 14 +- .../source/openfl3/blends/ColorBurnShader.hx | 40 ----- .../source/openfl3/blends/HardMixShader.hx | 59 ------- .../source/openfl3/blends/LightenShader.hx | 30 ---- .../openfl3/blends/LinearDodgeShader.hx | 38 ----- .../source/openfl3/blends/MultiplyShader.hx | 30 ---- .../source/openfl3/blends/VividLightShader.hx | 50 ------ .../source/openfl3/effects/BlendModeEffect.hx | 32 ---- .../source/openfl3/effects/ColorSwapEffect.hx | 116 ------------- .../source/openfl3/effects/ShutterEffect.hx | 154 ------------------ .../source/openfl3/effects/WiggleEffect.hx | 129 --------------- .../DynamicShadows/source/PlayStateShader.hx | 8 +- Effects/Filters/source/PlayState.hx | 54 +++--- .../source/{openfl8 => filters}/Grain.hx | 2 +- .../source/{openfl8 => filters}/Hq2x.hx | 2 +- .../source/{openfl8 => filters}/Scanline.hx | 2 +- .../source/{openfl8 => filters}/Tiltshift.hx | 2 +- Effects/Filters/source/openfl3/Grain.hx | 149 ----------------- Effects/Filters/source/openfl3/Hq2x.hx | 33 ---- Effects/Filters/source/openfl3/Scanline.hx | 22 --- Effects/Filters/source/openfl3/Tiltshift.hx | 89 ---------- Effects/FlxTrailArea/source/BlurState.hx | 2 +- Effects/FlxTrailArea/source/ParticleState.hx | 2 +- Effects/Transitions/source/MenuState.hx | 63 +++---- Effects/Transitions/source/MenuStateB.hx | 4 +- Features/FlxNapeTilemap/source/Main.hx | 1 - .../source/{states => }/PlayState.hx | 4 +- Features/Replay/source/PlayState.hx | 2 +- Features/ScaleModes/source/PlayState.hx | 3 +- .../source/generate/GenerateState.hx | 2 +- Other/BSPMapGen/source/play/PlayState.hx | 2 +- Other/Calculator/source/State.hx | 1 - Other/FlxCollisions/source/PlayState.hx | 2 +- Other/FlxCollisions/source/PlayState2.hx | 2 +- Other/FlxCollisions/source/PlayState3.hx | 2 +- Other/FrameCollections/source/PlayState.hx | 2 +- .../PixelPerfectCollision/source/PlayState.hx | 1 - .../source/entities/Character.hx | 4 +- Platformers/Mode/source/MenuState.hx | 4 +- Platformers/Mode/source/PlayState.hx | 4 +- Platformers/Mode/source/Player.hx | 2 +- Platformers/Mode/source/VictoryState.hx | 2 +- Platformers/ProjectJumper/source/MenuState.hx | 2 +- Platformers/ProjectJumper/source/PlayState.hx | 2 +- Platformers/Revenge/source/EndState.hx | 2 +- Platformers/Revenge/source/MenuState.hx | 2 +- Platformers/Revenge/source/PlayState.hx | 2 +- Tutorials/TurnBasedRPG/source/CombatHUD.hx | 2 +- Tutorials/TurnBasedRPG/source/Enemy.hx | 4 +- .../TurnBasedRPG/source/GameOverState.hx | 11 +- Tutorials/TurnBasedRPG/source/HUD.hx | 2 +- Tutorials/TurnBasedRPG/source/MenuState.hx | 4 +- Tutorials/TurnBasedRPG/source/OptionsState.hx | 14 +- Tutorials/TurnBasedRPG/source/PlayState.hx | 4 +- Tutorials/TurnBasedRPG/source/Player.hx | 2 +- .../FlxBitmapText/source/PlayState.hx | 4 +- .../RPGInterface/source/State_Battle.hx | 7 +- .../RPGInterface/source/State_CodeTest.hx | 7 +- .../RPGInterface/source/State_DefaultTest.hx | 7 +- .../RPGInterface/source/State_SaveMenu.hx | 7 +- .../RPGInterface/source/State_TestMenu.hx | 7 +- .../RPGInterface/source/State_Title.hx | 17 +- UserInterface/Tooltips/source/State_Demo.hx | 11 +- UserInterface/Tooltips/source/State_Demo2.hx | 4 +- .../Tooltips/source/State_DemoCode.hx | 48 +++--- 85 files changed, 343 insertions(+), 1202 deletions(-) rename Effects/BlendModeShaders/source/{openfl8 => }/blends/ColorBurnShader.hx (97%) rename Effects/BlendModeShaders/source/{openfl8 => }/blends/HardMixShader.hx (98%) rename Effects/BlendModeShaders/source/{openfl8 => }/blends/LightenShader.hx (95%) rename Effects/BlendModeShaders/source/{openfl8 => }/blends/LinearDodgeShader.hx (97%) rename Effects/BlendModeShaders/source/{openfl8 => }/blends/MultiplyShader.hx (95%) rename Effects/BlendModeShaders/source/{openfl8 => }/blends/VividLightShader.hx (97%) rename Effects/BlendModeShaders/source/{openfl8 => }/effects/BlendModeEffect.hx (96%) rename Effects/BlendModeShaders/source/{openfl8 => }/effects/ColorSwapEffect.hx (98%) rename Effects/BlendModeShaders/source/{openfl8 => }/effects/ShutterEffect.hx (98%) rename Effects/BlendModeShaders/source/{openfl8 => }/effects/WiggleEffect.hx (98%) delete mode 100644 Effects/BlendModeShaders/source/openfl3/blends/ColorBurnShader.hx delete mode 100644 Effects/BlendModeShaders/source/openfl3/blends/HardMixShader.hx delete mode 100644 Effects/BlendModeShaders/source/openfl3/blends/LightenShader.hx delete mode 100644 Effects/BlendModeShaders/source/openfl3/blends/LinearDodgeShader.hx delete mode 100644 Effects/BlendModeShaders/source/openfl3/blends/MultiplyShader.hx delete mode 100644 Effects/BlendModeShaders/source/openfl3/blends/VividLightShader.hx delete mode 100644 Effects/BlendModeShaders/source/openfl3/effects/BlendModeEffect.hx delete mode 100644 Effects/BlendModeShaders/source/openfl3/effects/ColorSwapEffect.hx delete mode 100644 Effects/BlendModeShaders/source/openfl3/effects/ShutterEffect.hx delete mode 100644 Effects/BlendModeShaders/source/openfl3/effects/WiggleEffect.hx rename Effects/Filters/source/{openfl8 => filters}/Grain.hx (99%) rename Effects/Filters/source/{openfl8 => filters}/Hq2x.hx (98%) rename Effects/Filters/source/{openfl8 => filters}/Scanline.hx (96%) rename Effects/Filters/source/{openfl8 => filters}/Tiltshift.hx (99%) delete mode 100644 Effects/Filters/source/openfl3/Grain.hx delete mode 100644 Effects/Filters/source/openfl3/Hq2x.hx delete mode 100644 Effects/Filters/source/openfl3/Scanline.hx delete mode 100644 Effects/Filters/source/openfl3/Tiltshift.hx rename Features/FlxNapeTilemap/source/{states => }/PlayState.hx (97%) diff --git a/.vscode/settings.json b/.vscode/settings.json index 390ca28a4..bc601fbda 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,8 +1,94 @@ { "search.exclude": { - "**/export/**/*.hx": true + "**/export/**": true }, "[haxe]": { - "editor.formatOnSave": true - } + "editor.formatOnSave": true, + "editor.formatOnSaveMode": "modifications" + }, + "lime.projectFile": "Tutorials/TurnBasedRPG/Project.xml", + "haxecheckstyle.sourceFolders": [ + "Arcade/Breakout/source", + "Arcade/Flappybalt/source", + "Arcade/Flixius/source", + "Arcade/FlxInvaders/source", + "Arcade/FlxLightPuzzle/source", + "Arcade/FlxPongApi/source", + "Arcade/FlxSnake/source", + "Arcade/FlxTeroids/source", + "Arcade/MinimalistTD/source", + "Editors/FlxPexParser/source", + "Editors/FlxSpine/source", + "Editors/TexturePackerAtlas/source", + "Effects/BlendModes/source", + "Effects/BlendModesShaders/source", + "Effects/DynamicShadows/source", + "Effects/Filters/source", + "Effects/FloodFill/source", + "Effects/FlxBloom/source", + "Effects/FlxBlur/source", + "Effects/FlxClothSprite/source", + "Effects/FlxEffectSprite/source", + "Effects/FlxFloodFill/source", + "Effects/FlxSimplex/source", + "Effects/FlxSkewedSprite/source", + "Effects/FlxSpriteFilters/source", + "Effects/FlxTrailArea/source", + "Effects/FlxTween/source", + "Effects/MosaicEffect/source", + "Effects/Parallax/source", + "Effects/PostProcess/source", + "Effects/Transitions/source", + "Features/CollisionAndGrouping/source", + "Features/Colors/source", + "Features/FlxCamera/source", + "Features/FlxFSM/source", + "Features/FlxNape/source", + "Features/FlxTerrain/source", + "Features/FlxTilemap/source", + "Features/FlxPieDial/source", + "Features/FlxScene/source", + "Features/FlxShape/source", + "Features/FlxSound/source", + "Features/HeatmapPathfinding/source", + "Features/Particles/source", + "Features/Pathfinding/source", + "Features/Replay/source", + "Features/ScaleModes/source", + "Features/SetTileProperties/source", + "Features/SplitScreen/source", + "Features/SubState/source", + "Features/Tilemap/source", + "Graphics/FlxAsepriteUtils/source", + "Input/FlxAccelerometer/source", + "Input/FlxAction/source", + "Input/FlxMouseEvent/source", + "Input/GamepadTest/source", + "Input/GridMovement/source", + "Input/Multitouch/source", + "Other/BSPMapGen/source", + "Other/Calculator/source", + "Other/FlxAsyncLoop/source", + "Other/FlxAtlas/source", + "Other/FrameCollections/source", + "Other/FlxBunnyMark/source", + "Other/FlxRandom/source", + "Other/NeonVector/source", + "Other/PixelPerfectCollision/source", + "Platformers/EZPlatformer/source", + "Platformers/FlipRotationAnimationTiles/source", + "Platformers/FlxCaveGenerator/source", + "Platformers/FlxTilemapExt/source", + "Platformers/Mode/source", + "Platformers/ProjectJumper/source", + "Platformers/Revenge/source", + "Tutorials/TurnBasedRPG/source", + "UserInterface/Cursor/source", + "UserInterface/FileBrowser/source", + "UserInterface/FlxBitmapText/source", + "UserInterface/FlxTextFormat/source", + "UserInterface/FlxTypeText/source", + "UserInterface/RPGInterface/source", + "UserInterface/Tooltips/source" + ] } \ No newline at end of file diff --git a/Arcade/Breakout/source/PlayState.hx b/Arcade/Breakout/source/PlayState.hx index 2d8a3631e..0d89ecdb2 100644 --- a/Arcade/Breakout/source/PlayState.hx +++ b/Arcade/Breakout/source/PlayState.hx @@ -115,7 +115,7 @@ class PlayState extends FlxState { if (swipe.distance > 100) { - if ((swipe.angle < 10 && swipe.angle > -10) || (swipe.angle > 170 || swipe.angle < -170)) + if ((swipe.degrees < 10 && swipe.degrees > -10) || (swipe.degrees > 170 || swipe.degrees < -170)) { FlxG.resetState(); } diff --git a/Arcade/FlxLightPuzzle/source/Color.hx b/Arcade/FlxLightPuzzle/source/Color.hx index 18a0b6fd2..f05b8d156 100644 --- a/Arcade/FlxLightPuzzle/source/Color.hx +++ b/Arcade/FlxLightPuzzle/source/Color.hx @@ -5,8 +5,7 @@ package; * Abstract Int so that colors can be easily combined using the | (or) operator. * @author MSGHero */ -@:enum -abstract Color(Int) from Int to Int +enum abstract Color(Int) from Int to Int { var MIRROR = 0x01 << 0; var RED = 0x01 << 1; diff --git a/Arcade/FlxPongApi/source/MenuState.hx b/Arcade/FlxPongApi/source/MenuState.hx index 1c9bcd573..8f92d0e3c 100644 --- a/Arcade/FlxPongApi/source/MenuState.hx +++ b/Arcade/FlxPongApi/source/MenuState.hx @@ -335,13 +335,13 @@ class MenuState extends FlxState function colorCallback(Name:String):Void { Reg.genColors(); - FlxG.switchState(new MenuState()); + FlxG.switchState(MenuState.new); } #end function playCallback(Name:String):Void { - FlxG.switchState(new PlayState()); + FlxG.switchState(PlayState.new); } function hfCallback(Name:String):Void diff --git a/Arcade/FlxPongApi/source/PlayState.hx b/Arcade/FlxPongApi/source/PlayState.hx index d712516d1..4b9703d54 100644 --- a/Arcade/FlxPongApi/source/PlayState.hx +++ b/Arcade/FlxPongApi/source/PlayState.hx @@ -93,7 +93,7 @@ class PlayState extends FlxState } if (FlxG.keys.justPressed.ESCAPE) { - FlxG.switchState(new MenuState()); + FlxG.switchState(MenuState.new); } #end @@ -150,6 +150,6 @@ class PlayState extends FlxState function endGame(f:FlxTimer):Void { - FlxG.switchState(new MenuState()); + FlxG.switchState(MenuState.new); } } diff --git a/Arcade/FlxTeroids/source/MenuState.hx b/Arcade/FlxTeroids/source/MenuState.hx index 44fcaa83b..a07097eee 100644 --- a/Arcade/FlxTeroids/source/MenuState.hx +++ b/Arcade/FlxTeroids/source/MenuState.hx @@ -23,7 +23,7 @@ class MenuState extends FlxState { if (FlxG.keys.justReleased.SPACE) { - FlxG.switchState(new PlayState()); + FlxG.switchState(PlayState.new); } } } diff --git a/Arcade/FlxTeroids/source/PlayState.hx b/Arcade/FlxTeroids/source/PlayState.hx index aa632d882..825c553b7 100644 --- a/Arcade/FlxTeroids/source/PlayState.hx +++ b/Arcade/FlxTeroids/source/PlayState.hx @@ -88,7 +88,7 @@ class PlayState extends FlxState // Escape to the menu if (FlxG.keys.pressed.ESCAPE) { - FlxG.switchState(new MenuState()); + FlxG.switchState(MenuState.new); } super.update(elapsed); diff --git a/Arcade/MinimalistTD/source/MenuState.hx b/Arcade/MinimalistTD/source/MenuState.hx index 0a3af8181..783592ba7 100644 --- a/Arcade/MinimalistTD/source/MenuState.hx +++ b/Arcade/MinimalistTD/source/MenuState.hx @@ -65,7 +65,7 @@ class MenuState extends FlxState */ function startGame():Void { - FlxG.switchState(new PlayState()); + FlxG.switchState(PlayState.new); } override public function update(elapsed:Float):Void diff --git a/Arcade/MinimalistTD/source/PlayState.hx b/Arcade/MinimalistTD/source/PlayState.hx index 20b2fa0e4..e1e28c01a 100644 --- a/Arcade/MinimalistTD/source/PlayState.hx +++ b/Arcade/MinimalistTD/source/PlayState.hx @@ -306,7 +306,7 @@ class PlayState extends FlxState if (FlxG.keys.justReleased.ESCAPE) { FlxG.sound.destroy(true); - FlxG.switchState(new MenuState()); + FlxG.switchState(MenuState.new); } if (FlxG.keys.justReleased.N) { diff --git a/Effects/BlendModeShaders/source/Main.hx b/Effects/BlendModeShaders/source/Main.hx index 354843e36..efa0e2d46 100644 --- a/Effects/BlendModeShaders/source/Main.hx +++ b/Effects/BlendModeShaders/source/Main.hx @@ -1,7 +1,6 @@ package; import flixel.FlxGame; -import openfl.Lib; import openfl.display.Sprite; class Main extends Sprite diff --git a/Effects/BlendModeShaders/source/PlayState.hx b/Effects/BlendModeShaders/source/PlayState.hx index 9c6b7864a..db5e97b49 100644 --- a/Effects/BlendModeShaders/source/PlayState.hx +++ b/Effects/BlendModeShaders/source/PlayState.hx @@ -5,17 +5,10 @@ import flixel.FlxSprite; import flixel.FlxState; import flixel.util.FlxColor; #if shaders_supported -#if (openfl >= "8.0.0") -import openfl8.blends.*; -import openfl8.effects.*; -import openfl8.effects.WiggleEffect.WiggleEffectType; -import openfl8.effects.BlendModeEffect.BlendModeShader; -#else -import openfl3.blends.*; -import openfl3.effects.*; -import openfl3.effects.WiggleEffect.WiggleEffectType; -import openfl3.effects.BlendModeEffect.BlendModeShader; -#end +import blends.*; +import effects.*; +import effects.WiggleEffect.WiggleEffectType; +import effects.BlendModeEffect.BlendModeShader; import flixel.util.FlxTimer; import flixel.tweens.FlxEase; import flixel.tweens.FlxTween; @@ -26,7 +19,7 @@ import openfl.filters.ShaderFilter; import flixel.text.FlxText; #end -@:enum abstract LogoColor(FlxColor) to FlxColor +enum abstract LogoColor(FlxColor) to FlxColor { static var LIST(default, null) = [RED, BLUE, YELLOW, CYAN, GREEN]; var RED = 0xff3366; @@ -126,7 +119,7 @@ class PlayState extends FlxState color.alphaFloat = 0.5; var effect = new BlendModeEffect(effects[blendEffect], color); - FlxG.camera.setFilters([new ShaderFilter(cast effect.shader)]); + FlxG.camera.filters = [new ShaderFilter(cast effect.shader)]; } function createShutterEffect():Void diff --git a/Effects/BlendModeShaders/source/openfl8/blends/ColorBurnShader.hx b/Effects/BlendModeShaders/source/blends/ColorBurnShader.hx similarity index 97% rename from Effects/BlendModeShaders/source/openfl8/blends/ColorBurnShader.hx rename to Effects/BlendModeShaders/source/blends/ColorBurnShader.hx index 41906b851..783a3c03d 100644 --- a/Effects/BlendModeShaders/source/openfl8/blends/ColorBurnShader.hx +++ b/Effects/BlendModeShaders/source/blends/ColorBurnShader.hx @@ -1,4 +1,4 @@ -package openfl8.blends; +package blends; import flixel.system.FlxAssets.FlxShader; diff --git a/Effects/BlendModeShaders/source/openfl8/blends/HardMixShader.hx b/Effects/BlendModeShaders/source/blends/HardMixShader.hx similarity index 98% rename from Effects/BlendModeShaders/source/openfl8/blends/HardMixShader.hx rename to Effects/BlendModeShaders/source/blends/HardMixShader.hx index 3d93a31e8..060c09040 100644 --- a/Effects/BlendModeShaders/source/openfl8/blends/HardMixShader.hx +++ b/Effects/BlendModeShaders/source/blends/HardMixShader.hx @@ -1,4 +1,4 @@ -package openfl8.blends; +package blends; import flixel.system.FlxAssets.FlxShader; diff --git a/Effects/BlendModeShaders/source/openfl8/blends/LightenShader.hx b/Effects/BlendModeShaders/source/blends/LightenShader.hx similarity index 95% rename from Effects/BlendModeShaders/source/openfl8/blends/LightenShader.hx rename to Effects/BlendModeShaders/source/blends/LightenShader.hx index 09a4fc52f..8fb15c170 100644 --- a/Effects/BlendModeShaders/source/openfl8/blends/LightenShader.hx +++ b/Effects/BlendModeShaders/source/blends/LightenShader.hx @@ -1,4 +1,4 @@ -package openfl8.blends; +package blends; import flixel.system.FlxAssets.FlxShader; diff --git a/Effects/BlendModeShaders/source/openfl8/blends/LinearDodgeShader.hx b/Effects/BlendModeShaders/source/blends/LinearDodgeShader.hx similarity index 97% rename from Effects/BlendModeShaders/source/openfl8/blends/LinearDodgeShader.hx rename to Effects/BlendModeShaders/source/blends/LinearDodgeShader.hx index 4ba901b3e..b76a494a8 100644 --- a/Effects/BlendModeShaders/source/openfl8/blends/LinearDodgeShader.hx +++ b/Effects/BlendModeShaders/source/blends/LinearDodgeShader.hx @@ -1,4 +1,4 @@ -package openfl8.blends; +package blends; import flixel.system.FlxAssets.FlxShader; diff --git a/Effects/BlendModeShaders/source/openfl8/blends/MultiplyShader.hx b/Effects/BlendModeShaders/source/blends/MultiplyShader.hx similarity index 95% rename from Effects/BlendModeShaders/source/openfl8/blends/MultiplyShader.hx rename to Effects/BlendModeShaders/source/blends/MultiplyShader.hx index 3e4fe0d42..b2bc8299a 100644 --- a/Effects/BlendModeShaders/source/openfl8/blends/MultiplyShader.hx +++ b/Effects/BlendModeShaders/source/blends/MultiplyShader.hx @@ -1,4 +1,4 @@ -package openfl8.blends; +package blends; import flixel.system.FlxAssets.FlxShader; diff --git a/Effects/BlendModeShaders/source/openfl8/blends/VividLightShader.hx b/Effects/BlendModeShaders/source/blends/VividLightShader.hx similarity index 97% rename from Effects/BlendModeShaders/source/openfl8/blends/VividLightShader.hx rename to Effects/BlendModeShaders/source/blends/VividLightShader.hx index 06e9d5ddc..cac0d3368 100644 --- a/Effects/BlendModeShaders/source/openfl8/blends/VividLightShader.hx +++ b/Effects/BlendModeShaders/source/blends/VividLightShader.hx @@ -1,4 +1,4 @@ -package openfl8.blends; +package blends; import flixel.system.FlxAssets.FlxShader; diff --git a/Effects/BlendModeShaders/source/openfl8/effects/BlendModeEffect.hx b/Effects/BlendModeShaders/source/effects/BlendModeEffect.hx similarity index 96% rename from Effects/BlendModeShaders/source/openfl8/effects/BlendModeEffect.hx rename to Effects/BlendModeShaders/source/effects/BlendModeEffect.hx index b438a6e39..9c6f8a0aa 100644 --- a/Effects/BlendModeShaders/source/openfl8/effects/BlendModeEffect.hx +++ b/Effects/BlendModeShaders/source/effects/BlendModeEffect.hx @@ -1,4 +1,4 @@ -package openfl8.effects; +package effects; import flixel.util.FlxColor; import openfl.display.ShaderParameter; @@ -11,24 +11,24 @@ typedef BlendModeShader = class BlendModeEffect { public var shader(default, null):BlendModeShader; - + @:isVar public var color(default, set):FlxColor; - + public function new(shader:BlendModeShader, color:FlxColor):Void { shader.uBlendColor.value = []; this.shader = shader; this.color = color; } - + function set_color(color:FlxColor):FlxColor { shader.uBlendColor.value[0] = color.redFloat; shader.uBlendColor.value[1] = color.greenFloat; shader.uBlendColor.value[2] = color.blueFloat; shader.uBlendColor.value[3] = color.alphaFloat; - + return this.color = color; } } diff --git a/Effects/BlendModeShaders/source/openfl8/effects/ColorSwapEffect.hx b/Effects/BlendModeShaders/source/effects/ColorSwapEffect.hx similarity index 98% rename from Effects/BlendModeShaders/source/openfl8/effects/ColorSwapEffect.hx rename to Effects/BlendModeShaders/source/effects/ColorSwapEffect.hx index b521f8635..85acabd2d 100644 --- a/Effects/BlendModeShaders/source/openfl8/effects/ColorSwapEffect.hx +++ b/Effects/BlendModeShaders/source/effects/ColorSwapEffect.hx @@ -1,4 +1,4 @@ -package openfl8.effects; +package effects; import flixel.util.FlxColor; import flixel.system.FlxAssets.FlxShader; @@ -9,22 +9,22 @@ class ColorSwapEffect * The instance of the actual shader class */ public var shader(default, null):ColorSwapShader; - + /** * The color to replace with another */ public var colorToReplace(default, set):FlxColor; - + /** * The desired new color */ public var newColor(default, set):FlxColor; - + /** * Activates/Deactivates the shader */ public var isShaderActive(default, set):Bool; - + public function new():Void { shader = new ColorSwapShader(); @@ -32,33 +32,33 @@ class ColorSwapEffect shader.colorOld.value = []; shader.colorNew.value = []; } - + function set_isShaderActive(value:Bool):Bool { isShaderActive = value; shader.shaderIsActive.value[0] = value; return value; } - + function set_colorToReplace(color:FlxColor):FlxColor { colorToReplace = color; - + shader.colorOld.value[0] = color.red; shader.colorOld.value[1] = color.green; shader.colorOld.value[2] = color.blue; - + return color; } - + function set_newColor(color:FlxColor):FlxColor { newColor = color; - + shader.colorNew.value[0] = color.red; shader.colorNew.value[1] = color.green; shader.colorNew.value[2] = color.blue; - + return color; } } diff --git a/Effects/BlendModeShaders/source/openfl8/effects/ShutterEffect.hx b/Effects/BlendModeShaders/source/effects/ShutterEffect.hx similarity index 98% rename from Effects/BlendModeShaders/source/openfl8/effects/ShutterEffect.hx rename to Effects/BlendModeShaders/source/effects/ShutterEffect.hx index 100e8d921..53297ee52 100644 --- a/Effects/BlendModeShaders/source/openfl8/effects/ShutterEffect.hx +++ b/Effects/BlendModeShaders/source/effects/ShutterEffect.hx @@ -1,4 +1,4 @@ -package openfl8.effects; +package effects; import flixel.FlxG; import flixel.system.FlxAssets.FlxShader; @@ -7,28 +7,28 @@ class ShutterEffect { public static inline var SHUTTER_TARGET_FLXSPRITE:Int = 0; public static inline var SHUTTER_TARGET_FLXCAMERA:Int = 1; - + public var shutterTargetMode(default, set):Int = 0; - + /** * The instance of the actual shader class */ public var shader(default, null):ShutterShader; - + /** * Size of the circle or "shutter" */ public var radius(default, set):Float; - + /** * Center point of the "shutter" */ public var shutterCenterX(default, set):Float; - + public var shutterCenterY(default, set):Float; - + public var isActive(default, set):Bool; - + public function new():Void { shader = new ShutterShader(); @@ -39,40 +39,40 @@ class ShutterEffect shutterTargetMode = SHUTTER_TARGET_FLXSPRITE; radius = 0; } - + function setResolution():Void { shader.uResolution.value = [FlxG.width, FlxG.height]; } - + function set_shutterTargetMode(v:Int):Int { shutterTargetMode = v; shader.shutterTargetMode.value = [shutterTargetMode]; return v; } - + function set_isActive(v:Bool):Bool { isActive = v; shader.shaderIsActive.value = [isActive]; return v; } - + function set_radius(v:Float):Float { radius = (v <= 0.0 ? 0.0 : v); shader.uCircleRadius.value = [radius]; return v; } - + function set_shutterCenterX(v:Float):Float { shutterCenterX = v; shader.centerPtX.value = [v]; return v; } - + function set_shutterCenterY(v:Float):Float { shutterCenterY = v; diff --git a/Effects/BlendModeShaders/source/openfl8/effects/WiggleEffect.hx b/Effects/BlendModeShaders/source/effects/WiggleEffect.hx similarity index 98% rename from Effects/BlendModeShaders/source/openfl8/effects/WiggleEffect.hx rename to Effects/BlendModeShaders/source/effects/WiggleEffect.hx index f53894aba..23e730c2d 100644 --- a/Effects/BlendModeShaders/source/openfl8/effects/WiggleEffect.hx +++ b/Effects/BlendModeShaders/source/effects/WiggleEffect.hx @@ -1,4 +1,4 @@ -package openfl8.effects; +package effects; import flixel.system.FlxAssets.FlxShader; @@ -18,38 +18,38 @@ class WiggleEffect public var waveSpeed(default, set):Float = 0; public var waveFrequency(default, set):Float = 0; public var waveAmplitude(default, set):Float = 0; - + public function new():Void { shader.uTime.value = [0]; } - + public function update(elapsed:Float):Void { shader.uTime.value[0] += elapsed; } - + function set_effectType(v:WiggleEffectType):WiggleEffectType { effectType = v; shader.effectType.value = [WiggleEffectType.getConstructors().indexOf(Std.string(v))]; return v; } - + function set_waveSpeed(v:Float):Float { waveSpeed = v; shader.uSpeed.value = [waveSpeed]; return v; } - + function set_waveFrequency(v:Float):Float { waveFrequency = v; shader.uFrequency.value = [waveFrequency]; return v; } - + function set_waveAmplitude(v:Float):Float { waveAmplitude = v; diff --git a/Effects/BlendModeShaders/source/openfl3/blends/ColorBurnShader.hx b/Effects/BlendModeShaders/source/openfl3/blends/ColorBurnShader.hx deleted file mode 100644 index fa152e535..000000000 --- a/Effects/BlendModeShaders/source/openfl3/blends/ColorBurnShader.hx +++ /dev/null @@ -1,40 +0,0 @@ -package openfl3.blends; - -import openfl.display.Shader; - -class ColorBurnShader extends Shader -{ - @fragment var code = ' - uniform vec4 uBlendColor; - - float applyColorBurnToChannel(float base, float blend) - { - return ((blend == 0.0) ? blend : max((1.0 - ((1.0 - base) / blend)), 0.0)); - } - - vec4 blendColorBurn(vec4 base, vec4 blend) - { - return vec4( - applyColorBurnToChannel(base.r, blend.r), - applyColorBurnToChannel(base.g, blend.g), - applyColorBurnToChannel(base.b, blend.b), - applyColorBurnToChannel(base.a, blend.a) - ); - } - - vec4 blendColorBurn(vec4 base, vec4 blend, float opacity) - { - return (blendColorBurn(base, blend) * opacity + base * (1.0 - opacity)); - } - - void main() - { - vec4 base = texture2D(${Shader.uSampler}, ${Shader.vTexCoord}); - gl_FragColor = blendColorBurn(base, uBlendColor, uBlendColor[3]); - }'; - - public function new() - { - super(); - } -} diff --git a/Effects/BlendModeShaders/source/openfl3/blends/HardMixShader.hx b/Effects/BlendModeShaders/source/openfl3/blends/HardMixShader.hx deleted file mode 100644 index 19dd72725..000000000 --- a/Effects/BlendModeShaders/source/openfl3/blends/HardMixShader.hx +++ /dev/null @@ -1,59 +0,0 @@ -package openfl3.blends; - -import openfl.display.Shader; - -class HardMixShader extends Shader -{ - @fragment var code = ' - uniform vec4 uBlendColor; - - float blendColorDodge(float base, float blend) { - return (blend == 1.0) - ? blend - : min(base / (1.0 - blend), 1.0); - } - - float blendColorBurn(float base, float blend) { - return (blend == 0.0) - ? blend - : max((1.0 - ((1.0 - base) / blend)), 0.0); - } - - float blendVividLight(float base, float blend) { - return (blend < 0.5) - ? blendColorBurn(base, (2.0 * blend)) - : blendColorDodge(base, (2.0 * (blend - 0.5))); - } - - float blendHardMix(float base, float blend) { - return (blendVividLight(base, blend) < 0.5) - ? 0.0 - : 1.0; - } - - vec4 blendHardMix(vec4 base, vec4 blend) { - return vec4( - blendHardMix(base.r, blend.r), - blendHardMix(base.g, blend.g), - blendHardMix(base.b, blend.b), - blendHardMix(base.a, blend.a) - ); - } - - vec4 blendHardMix(vec4 base, vec4 blend, float opacity) { - return (blendHardMix(base, blend) * opacity + base * (1.0 - opacity)); - } - - void main() - { - vec4 blend = texture2D(${Shader.uSampler}, ${Shader.vTexCoord}); - vec4 res = blendHardMix(uBlendColor, blend); - - gl_FragColor = blendHardMix(blend, res, uBlendColor[3]); - }'; - - public function new() - { - super(); - } -} diff --git a/Effects/BlendModeShaders/source/openfl3/blends/LightenShader.hx b/Effects/BlendModeShaders/source/openfl3/blends/LightenShader.hx deleted file mode 100644 index 3285fd786..000000000 --- a/Effects/BlendModeShaders/source/openfl3/blends/LightenShader.hx +++ /dev/null @@ -1,30 +0,0 @@ -package openfl3.blends; - -import openfl.display.Shader; - -class LightenShader extends Shader -{ - @fragment var code = ' - uniform vec4 uBlendColor; - - vec4 blendLighten(vec4 base, vec4 blend) - { - return max(blend, base); - } - - vec4 blendLighten(vec4 base, vec4 blend, float opacity) - { - return (blendLighten(base, blend) * opacity + base * (1.0 - opacity)); - } - - void main() - { - vec4 base = texture2D(${Shader.uSampler}, ${Shader.vTexCoord}); - gl_FragColor = blendLighten(base, uBlendColor, uBlendColor.a); - }'; - - public function new() - { - super(); - } -} diff --git a/Effects/BlendModeShaders/source/openfl3/blends/LinearDodgeShader.hx b/Effects/BlendModeShaders/source/openfl3/blends/LinearDodgeShader.hx deleted file mode 100644 index f84cb6951..000000000 --- a/Effects/BlendModeShaders/source/openfl3/blends/LinearDodgeShader.hx +++ /dev/null @@ -1,38 +0,0 @@ -package openfl3.blends; - -import openfl.display.Shader; - -class LinearDodgeShader extends Shader -{ - @fragment var code = ' - uniform vec4 uBlendColor; - - // Note : Same implementation as BlendAddf - float blendLinearDodge(float base, float blend) { - return min(base + blend, 1.0); - } - - vec4 blendLinearDodge(vec4 base, vec4 blend) { - return vec4( - blendLinearDodge(base.r, blend.r), - blendLinearDodge(base.g, blend.g), - blendLinearDodge(base.b, blend.b), - blendLinearDodge(base.a, blend.a) - ); - } - - vec4 blendLinearDodge(vec4 base, vec4 blend, float opacity) { - return (blendLinearDodge(base, blend) * opacity + base * (1.0 - opacity)); - } - - void main() - { - vec4 base = texture2D(${Shader.uSampler}, ${Shader.vTexCoord}); - gl_FragColor = blendLinearDodge(base, uBlendColor, uBlendColor[3]); - }'; - - public function new() - { - super(); - } -} diff --git a/Effects/BlendModeShaders/source/openfl3/blends/MultiplyShader.hx b/Effects/BlendModeShaders/source/openfl3/blends/MultiplyShader.hx deleted file mode 100644 index f35655e6d..000000000 --- a/Effects/BlendModeShaders/source/openfl3/blends/MultiplyShader.hx +++ /dev/null @@ -1,30 +0,0 @@ -package openfl3.blends; - -import openfl.display.Shader; - -class MultiplyShader extends Shader -{ - @fragment var code = ' - uniform vec4 uBlendColor; - - vec4 blendMultiply(vec4 base, vec4 blend) - { - return base * blend; - } - - vec4 blendMultiply(vec4 base, vec4 blend, float opacity) - { - return (blendMultiply(base, blend) * opacity + base * (1.0 - opacity)); - } - - void main() - { - vec4 base = texture2D(${Shader.uSampler}, ${Shader.vTexCoord}); - gl_FragColor = blendMultiply(base, uBlendColor, uBlendColor.a); - }'; - - public function new() - { - super(); - } -} diff --git a/Effects/BlendModeShaders/source/openfl3/blends/VividLightShader.hx b/Effects/BlendModeShaders/source/openfl3/blends/VividLightShader.hx deleted file mode 100644 index f98665eb3..000000000 --- a/Effects/BlendModeShaders/source/openfl3/blends/VividLightShader.hx +++ /dev/null @@ -1,50 +0,0 @@ -package openfl3.blends; - -import openfl.display.Shader; - -class VividLightShader extends Shader -{ - @fragment var code = ' - uniform vec4 uBlendColor; - - float colorDodge(float base, float blend) - { - return (blend == 1.0) ? blend : min(base / (1.0 - blend), 1.0); - } - - float colorBurn(float base, float blend) - { - return (blend == 0.0) ? blend : max((1.0 - ((1.0 - base) / blend)), 0.0); - } - - float vividLight( float base, float blend ) - { - return ((blend < 0.5) ? colorBurn(base, (2.0 * blend)) : colorDodge(base, (2.0 * (blend - 0.5)))); - } - - vec4 vividLight(vec4 base, vec4 blend) - { - return vec4( - vividLight(base.r, blend.r), - vividLight(base.g, blend.g), - vividLight(base.b, blend.b), - vividLight(base.a, blend.a) - ); - } - - vec4 vividLight(vec4 base, vec4 blend, float opacity) - { - return (vividLight(base, blend) * opacity + base * (1.0 - opacity)); - } - - void main() - { - vec4 base = texture2D(${Shader.uSampler}, ${Shader.vTexCoord}); - gl_FragColor = vividLight(base, uBlendColor, uBlendColor[3]); - }'; - - public function new() - { - super(); - } -} diff --git a/Effects/BlendModeShaders/source/openfl3/effects/BlendModeEffect.hx b/Effects/BlendModeShaders/source/openfl3/effects/BlendModeEffect.hx deleted file mode 100644 index 32fcf5b2b..000000000 --- a/Effects/BlendModeShaders/source/openfl3/effects/BlendModeEffect.hx +++ /dev/null @@ -1,32 +0,0 @@ -package openfl3.effects; - -import flixel.util.FlxColor; - -typedef BlendModeShader = -{ - var uBlendColor(get, set):Array; -} - -class BlendModeEffect -{ - public var shader(default, null):BlendModeShader; - - @:isVar - public var color(default, set):FlxColor; - - public function new(shader:BlendModeShader, color:FlxColor):Void - { - this.shader = shader; - this.color = color; - } - - function set_color(color:FlxColor):FlxColor - { - shader.uBlendColor[0] = color.redFloat; - shader.uBlendColor[1] = color.greenFloat; - shader.uBlendColor[2] = color.blueFloat; - shader.uBlendColor[3] = color.alphaFloat; - - return this.color = color; - } -} diff --git a/Effects/BlendModeShaders/source/openfl3/effects/ColorSwapEffect.hx b/Effects/BlendModeShaders/source/openfl3/effects/ColorSwapEffect.hx deleted file mode 100644 index f70557aa7..000000000 --- a/Effects/BlendModeShaders/source/openfl3/effects/ColorSwapEffect.hx +++ /dev/null @@ -1,116 +0,0 @@ -package openfl3.effects; - -import flixel.util.FlxColor; -import openfl.display.Shader; - -class ColorSwapEffect -{ - /** - * The instance of the actual shader class - */ - public var shader(default, null):ColorSwapShader; - - /** - * The color to replace with another - */ - public var colorToReplace(default, set):FlxColor; - - /** - * The desired new color - */ - public var newColor(default, set):FlxColor; - - /** - * Activates/Deactivates the shader - */ - public var isShaderActive(default, set):Bool; - - public function new():Void - { - shader = new ColorSwapShader(); - shader.shaderIsActive = true; - } - - function set_isShaderActive(value:Bool):Bool - { - isShaderActive = value; - shader.shaderIsActive = value; - return value; - } - - function set_colorToReplace(color:FlxColor):FlxColor - { - colorToReplace = color; - - shader.colorOld[0] = color.red; - shader.colorOld[1] = color.green; - shader.colorOld[2] = color.blue; - - return color; - } - - function set_newColor(color:FlxColor):FlxColor - { - newColor = color; - - shader.colorNew[0] = color.red; - shader.colorNew[1] = color.green; - shader.colorNew[2] = color.blue; - - return color; - } -} - -class ColorSwapShader extends Shader -{ - @fragment var code = ' - uniform vec3 colorOld; - uniform vec3 colorNew; - uniform bool shaderIsActive; - - /** - * Helper method that normalizes an RGB value (in the 0-255 range) to a value between 0-1. - */ - vec3 normalizeColor(vec3 color) - { - return vec3( - color[0] / 255.0, - color[1] / 255.0, - color[2] / 255.0 - ); - } - - void main() - { - vec4 pixel = texture2D(${Shader.uSampler}, ${Shader.vTexCoord}); - - if (!shaderIsActive) - { - gl_FragColor = pixel; - return; - } - - /** - * Used to create some leeway when comparing the colors. - * Smaller values = smaller leeway. - */ - vec3 eps = vec3(0.009, 0.009, 0.009); - - vec3 colorOldNormalized = normalizeColor(colorOld); - vec3 colorNewNormalized = normalizeColor(colorNew); - - if (all(greaterThanEqual(pixel, vec4(colorOldNormalized - eps, 1.0)) ) && - all(lessThanEqual(pixel, vec4(colorOldNormalized + eps, 1.0)) ) - ) - { - pixel = vec4(colorNewNormalized, 1.0); - } - - gl_FragColor = pixel; - }'; - - public function new() - { - super(); - } -} diff --git a/Effects/BlendModeShaders/source/openfl3/effects/ShutterEffect.hx b/Effects/BlendModeShaders/source/openfl3/effects/ShutterEffect.hx deleted file mode 100644 index 324abe578..000000000 --- a/Effects/BlendModeShaders/source/openfl3/effects/ShutterEffect.hx +++ /dev/null @@ -1,154 +0,0 @@ -package openfl3.effects; - -import flixel.FlxG; -import openfl.display.Shader; - -class ShutterEffect -{ - public static inline var SHUTTER_TARGET_FLXSPRITE:Int = 0; - public static inline var SHUTTER_TARGET_FLXCAMERA:Int = 1; - - public var shutterTargetMode(default, set):Int = 0; - - /** - * The instance of the actual shader class - */ - public var shader(default, null):ShutterShader; - - /** - * Size of the circle or "shutter" - */ - public var radius(default, set):Float; - - /** - * Center point of the "shutter" - */ - public var shutterCenterX(default, set):Float; - - public var shutterCenterY(default, set):Float; - - public var isActive(default, set):Bool; - - public function new():Void - { - shader = new ShutterShader(); - setResolution(); - isActive = true; - shutterCenterX = FlxG.width * .5; - shutterCenterY = FlxG.height * .5; - shutterTargetMode = SHUTTER_TARGET_FLXSPRITE; - radius = 0; - } - - function setResolution():Void - { - shader.uResolution[0] = FlxG.width; - shader.uResolution[1] = FlxG.height; - } - - function set_shutterTargetMode(v:Int):Int - { - shutterTargetMode = v; - shader.shutterTargetMode = shutterTargetMode; - return v; - } - - function set_isActive(v:Bool):Bool - { - isActive = v; - shader.shaderIsActive = isActive; - return v; - } - - function set_radius(v:Float):Float - { - radius = (v <= 0.0 ? 0.0 : v); - shader.uCircleRadius = radius; - return v; - } - - function set_shutterCenterX(v:Float):Float - { - shutterCenterX = v; - shader.centerPtX = v; - return v; - } - - function set_shutterCenterY(v:Float):Float - { - shutterCenterY = v; - shader.centerPtY = v; - return v; - } -} - -class ShutterShader extends Shader -{ - @fragment var code = ' - #ifdef GL_ES - precision mediump float; - #endif - - const int SHUTTER_TARGET_FLXSPRITE = 0; - const int SHUTTER_TARGET_FLXCAMERA = 1; - const float scale = 1.0; - - uniform vec2 uResolution; - uniform float centerPtX; - uniform float centerPtY; - uniform float uCircleRadius; - uniform int shutterTargetMode; - uniform bool shaderIsActive; - - vec2 getCoordinates() - { - return vec2( - (${Shader.vTexCoord}.x * uResolution.x) / scale, - (${Shader.vTexCoord}.y * uResolution.y) / scale - ); - } - - float getDist(vec2 pt1, vec2 pt2) - { - float dx = pt1.x - pt2.x; - float dy = pt1.y - pt2.y; - - return sqrt( - (dx*dx) + (dy*dy) - ); - } - - void main() - { - if (!shaderIsActive) - { - gl_FragColor = texture2D(${Shader.uSampler}, ${Shader.vTexCoord}); - return; - } - - vec2 centerPt = vec2(centerPtX, centerPtY); - - if (uCircleRadius <= 0.0 || getDist(getCoordinates(), centerPt) > uCircleRadius) - { - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - } - else - { - /* If this shader is used on a FlxCamera, uncomment the line below to - draw the underlying pixels inside the shutter (as they would look normally). - - If using this shader on a FlxSprite, keep the line below commented out, to - draw transparency inside the shutter */ - - if (shutterTargetMode == SHUTTER_TARGET_FLXCAMERA) - { - gl_FragColor = texture2D(${Shader.uSampler}, ${Shader.vTexCoord}); - } - } - }'; - - public function new() - { - super(); - } -} diff --git a/Effects/BlendModeShaders/source/openfl3/effects/WiggleEffect.hx b/Effects/BlendModeShaders/source/openfl3/effects/WiggleEffect.hx deleted file mode 100644 index 3f2809aaa..000000000 --- a/Effects/BlendModeShaders/source/openfl3/effects/WiggleEffect.hx +++ /dev/null @@ -1,129 +0,0 @@ -package openfl3.effects; - -import openfl.display.Shader; - -enum WiggleEffectType -{ - DREAMY; - WAVY; - HEAT_WAVE_HORIZONTAL; - HEAT_WAVE_VERTICAL; - FLAG; -} - -class WiggleEffect -{ - public var effectType(default, set):WiggleEffectType = DREAMY; - public var shader(default, null):WiggleShader = new WiggleShader(); - public var waveSpeed(default, set):Float = 0; - public var waveFrequency(default, set):Float = 0; - public var waveAmplitude(default, set):Float = 0; - - public function new():Void {} - - public function update(elapsed:Float):Void - { - shader.uTime += elapsed; - } - - function set_effectType(v:WiggleEffectType):WiggleEffectType - { - effectType = v; - shader.effectType = WiggleEffectType.getConstructors().indexOf(Std.string(v)); - return v; - } - - function set_waveSpeed(v:Float):Float - { - waveSpeed = v; - shader.uSpeed = waveSpeed; - return v; - } - - function set_waveFrequency(v:Float):Float - { - waveFrequency = v; - shader.uFrequency = waveFrequency; - return v; - } - - function set_waveAmplitude(v:Float):Float - { - waveAmplitude = v; - shader.uWaveAmplitude = waveAmplitude; - return v; - } -} - -class WiggleShader extends Shader -{ - @fragment var code = ' - //uniform float tx, ty; // x,y waves phase - uniform float uTime; - - const int EFFECT_TYPE_DREAMY = 0; - const int EFFECT_TYPE_WAVY = 1; - const int EFFECT_TYPE_HEAT_WAVE_HORIZONTAL = 2; - const int EFFECT_TYPE_HEAT_WAVE_VERTICAL = 3; - const int EFFECT_TYPE_FLAG = 4; - - uniform int effectType; - - /** - * How fast the waves move over time - */ - uniform float uSpeed; - - /** - * Number of waves over time - */ - uniform float uFrequency; - - /** - * How much the pixels are going to stretch over the waves - */ - uniform float uWaveAmplitude; - - vec2 sineWave(vec2 pt) - { - float x = 0.0; - float y = 0.0; - - if (effectType == EFFECT_TYPE_DREAMY) - { - float offsetX = sin(pt.y * uFrequency + uTime * uSpeed) * uWaveAmplitude; - pt.x += offsetX; // * (pt.y - 1.0); // <- Uncomment to stop bottom part of the screen from moving - } - else if (effectType == EFFECT_TYPE_WAVY) - { - float offsetY = sin(pt.x * uFrequency + uTime * uSpeed) * uWaveAmplitude; - pt.y += offsetY; // * (pt.y - 1.0); // <- Uncomment to stop bottom part of the screen from moving - } - else if (effectType == EFFECT_TYPE_HEAT_WAVE_HORIZONTAL) - { - x = sin(pt.x * uFrequency + uTime * uSpeed) * uWaveAmplitude; - } - else if (effectType == EFFECT_TYPE_HEAT_WAVE_VERTICAL) - { - y = sin(pt.y * uFrequency + uTime * uSpeed) * uWaveAmplitude; - } - else if (effectType == EFFECT_TYPE_FLAG) - { - y = sin(pt.y * uFrequency + 10.0 * pt.x + uTime * uSpeed) * uWaveAmplitude; - x = sin(pt.x * uFrequency + 5.0 * pt.y + uTime * uSpeed) * uWaveAmplitude; - } - - return vec2(pt.x + x, pt.y + y); - } - - void main() - { - vec2 uv = sineWave(${Shader.vTexCoord}); - gl_FragColor = texture2D(${Shader.uSampler}, uv); - }'; - - public function new() - { - super(); - } -} diff --git a/Effects/DynamicShadows/source/PlayStateShader.hx b/Effects/DynamicShadows/source/PlayStateShader.hx index ea05e9bc0..245c0f42c 100644 --- a/Effects/DynamicShadows/source/PlayStateShader.hx +++ b/Effects/DynamicShadows/source/PlayStateShader.hx @@ -1,6 +1,7 @@ import openfl.display.BitmapData; import flixel.FlxCamera; import flixel.FlxG; + class PlayStateShader extends PlayState { var shaderCam:FlxCamera; @@ -34,7 +35,7 @@ class PlayStateShader extends PlayState // add the bg camera as an image to the shader so we can add color effects to it bgCam.buffer = new BitmapData(bgCam.width, bgCam.height); shader.bgImage.input = bgCam.buffer; - shaderCam.setFilters([new openfl.filters.ShaderFilter(shader)]); + shaderCam.filters = [new openfl.filters.ShaderFilter(shader)]; // draws anything above the shadows, in this case infoText uiCam = new FlxCamera(0, 0, FlxG.width, FlxG.height); @@ -47,7 +48,8 @@ class PlayStateShader extends PlayState { super.update(elapsed); - inline function random(mean:Float) return FlxG.random.floatNormal(mean, mean / 8); + inline function random(mean:Float) + return FlxG.random.floatNormal(mean, mean / 8); shader.setOrigin((gem.x + random(gem.origin.x)) / FlxG.width, (gem.y + random(gem.origin.y)) / FlxG.height); } @@ -72,4 +74,4 @@ class PlayStateShader extends PlayState } return buffer; } -} \ No newline at end of file +} diff --git a/Effects/Filters/source/PlayState.hx b/Effects/Filters/source/PlayState.hx index 420083f2d..931a8f3e7 100644 --- a/Effects/Filters/source/PlayState.hx +++ b/Effects/Filters/source/PlayState.hx @@ -1,22 +1,18 @@ package; -import flixel.addons.display.FlxBackdrop; -import flixel.addons.ui.FlxUIAssets; -import flixel.addons.ui.FlxUICheckBox; import flixel.FlxCamera; import flixel.FlxG; import flixel.FlxState; +import flixel.addons.display.FlxBackdrop; +import flixel.addons.ui.FlxUIAssets; +import flixel.addons.ui.FlxUICheckBox; import openfl.filters.BitmapFilter; import openfl.filters.BlurFilter; import openfl.filters.ColorMatrixFilter; #if shaders_supported -#if (openfl >= "8.0.0") -import openfl8.*; -#else -import openfl3.*; -#end -import openfl.filters.ShaderFilter; +import filters.*; import openfl.Lib; +import openfl.filters.ShaderFilter; #end class PlayState extends FlxState @@ -24,7 +20,7 @@ class PlayState extends FlxState var filters:Array = []; var uiCamera:flixel.FlxCamera; var filterMap:MapVoid}>; - + override public function create():Void { filterMap = [ @@ -60,7 +56,7 @@ class PlayState extends FlxState 0.5, 0.5, 0.5, 0, 0, 0, 0, 0, 1, 0, ]; - + {filter: new ColorMatrixFilter(matrix)} }, "Invert" => { @@ -70,7 +66,7 @@ class PlayState extends FlxState 0, 0, -1, 0, 255, 0, 0, 0, 1, 0, ]; - + {filter: new ColorMatrixFilter(matrix)} }, "Deuteranopia" => { @@ -80,7 +76,7 @@ class PlayState extends FlxState -.02, 0.03, 1, 0, 0, 0, 0, 0, 1, 0, ]; - + {filter: new ColorMatrixFilter(matrix)} }, "Protanopia" => { @@ -90,7 +86,7 @@ class PlayState extends FlxState 0.01, -.01, 1, 0, 0, 0, 0, 0, 1, 0, ]; - + {filter: new ColorMatrixFilter(matrix)} }, "Tritanopia" => { @@ -100,51 +96,51 @@ class PlayState extends FlxState 0.06, 0.88, 0.18, 0, 0, 0, 0, 0, 1, 0, ]; - + {filter: new ColorMatrixFilter(matrix)} } ]; - + uiCamera = new FlxCamera(0, 0, 130, 300); FlxG.cameras.add(uiCamera); - + var backdrop = new FlxBackdrop("assets/logo.png"); backdrop.cameras = [FlxG.camera]; backdrop.velocity.set(150, 150); add(backdrop); - - FlxG.camera.setFilters(filters); - FlxG.game.setFilters(filters); - + + FlxG.camera.filters = filters; + FlxG.game.filters = filters; + FlxG.game.filtersEnabled = false; - + var x = 10; var y = 10; - + for (key in filterMap.keys()) { createCheckbox(x, y, key, filterMap.get(key).filter); y += 25; } - + y += 10; var checkbox = new FlxUICheckBox(x, y, FlxUIAssets.IMG_CHECK_BOX, FlxUIAssets.IMG_CHECK_MARK, "Apply to full game"); checkbox.cameras = [uiCamera]; add(checkbox); - + checkbox.callback = function() { FlxG.camera.filtersEnabled = !checkbox.checked; FlxG.game.filtersEnabled = checkbox.checked; } } - + function createCheckbox(x:Float, y:Float, name:String, filter:BitmapFilter) { var checkbox = new FlxUICheckBox(x, y, FlxUIAssets.IMG_CHECK_BOX, FlxUIAssets.IMG_CHECK_MARK, name); checkbox.cameras = [uiCamera]; add(checkbox); - + checkbox.callback = function() { if (checkbox.checked) @@ -153,11 +149,11 @@ class PlayState extends FlxState filters.remove(filter); } } - + override public function update(elapsed:Float):Void { super.update(elapsed); - + for (filter in filterMap) { if (filter.onUpdate != null) diff --git a/Effects/Filters/source/openfl8/Grain.hx b/Effects/Filters/source/filters/Grain.hx similarity index 99% rename from Effects/Filters/source/openfl8/Grain.hx rename to Effects/Filters/source/filters/Grain.hx index 96a87defc..2aabbca9f 100644 --- a/Effects/Filters/source/openfl8/Grain.hx +++ b/Effects/Filters/source/filters/Grain.hx @@ -1,4 +1,4 @@ -package openfl8; +package filters; import flixel.system.FlxAssets.FlxShader; diff --git a/Effects/Filters/source/openfl8/Hq2x.hx b/Effects/Filters/source/filters/Hq2x.hx similarity index 98% rename from Effects/Filters/source/openfl8/Hq2x.hx rename to Effects/Filters/source/filters/Hq2x.hx index 4a762472e..6c576ff50 100644 --- a/Effects/Filters/source/openfl8/Hq2x.hx +++ b/Effects/Filters/source/filters/Hq2x.hx @@ -1,4 +1,4 @@ -package openfl8; +package filters; import flixel.system.FlxAssets.FlxShader; diff --git a/Effects/Filters/source/openfl8/Scanline.hx b/Effects/Filters/source/filters/Scanline.hx similarity index 96% rename from Effects/Filters/source/openfl8/Scanline.hx rename to Effects/Filters/source/filters/Scanline.hx index 535dfae7a..00f4463f5 100644 --- a/Effects/Filters/source/openfl8/Scanline.hx +++ b/Effects/Filters/source/filters/Scanline.hx @@ -1,4 +1,4 @@ -package openfl8; +package filters; import flixel.system.FlxAssets.FlxShader; diff --git a/Effects/Filters/source/openfl8/Tiltshift.hx b/Effects/Filters/source/filters/Tiltshift.hx similarity index 99% rename from Effects/Filters/source/openfl8/Tiltshift.hx rename to Effects/Filters/source/filters/Tiltshift.hx index 85aa02455..0613d9fab 100644 --- a/Effects/Filters/source/openfl8/Tiltshift.hx +++ b/Effects/Filters/source/filters/Tiltshift.hx @@ -1,4 +1,4 @@ -package openfl8; +package filters; import flixel.system.FlxAssets.FlxShader; diff --git a/Effects/Filters/source/openfl3/Grain.hx b/Effects/Filters/source/openfl3/Grain.hx deleted file mode 100644 index 974c63336..000000000 --- a/Effects/Filters/source/openfl3/Grain.hx +++ /dev/null @@ -1,149 +0,0 @@ -package openfl3; - -import openfl.display.Shader; - -class Grain extends Shader -{ - @fragment var code = ' - /* - Film Grain post-process shader v1.1 - Martins Upitis (martinsh) devlog-martinsh.blogspot.com - 2013 - - -------------------------- - This work is licensed under a Creative Commons Attribution 3.0 Unported License. - So you are free to share, modify and adapt it for your needs, and even use it for commercial use. - I would also love to hear about a project you are using it. - - Have fun, - Martins - -------------------------- - - Perlin noise shader by toneburst: - http://machinesdontcare.wordpress.com/2009/06/25/3d-perlin-noise-sphere-vertex-shader-sourcecode/ - */ - uniform float uTime; - - const float permTexUnit = 1.0/256.0; // Perm texture texel-size - const float permTexUnitHalf = 0.5/256.0; // Half perm texture texel-size - - float width = ${Shader.uTextureSize}.x; - float height = ${Shader.uTextureSize}.y; - - const float grainamount = 0.05; //grain amount - bool colored = false; //colored noise? - float coloramount = 0.6; - float grainsize = 1.6; //grain particle size (1.5 - 2.5) - float lumamount = 1.0; // - - //a random texture generator, but you can also use a pre-computed perturbation texture - vec4 rnm(in vec2 tc) - { - float noise = sin(dot(tc + vec2(uTime,uTime),vec2(12.9898,78.233))) * 43758.5453; - - float noiseR = fract(noise)*2.0-1.0; - float noiseG = fract(noise*1.2154)*2.0-1.0; - float noiseB = fract(noise*1.3453)*2.0-1.0; - float noiseA = fract(noise*1.3647)*2.0-1.0; - - return vec4(noiseR,noiseG,noiseB,noiseA); - } - - float fade(in float t) { - return t*t*t*(t*(t*6.0-15.0)+10.0); - } - - float pnoise3D(in vec3 p) - { - vec3 pi = permTexUnit*floor(p)+permTexUnitHalf; // Integer part, scaled so +1 moves permTexUnit texel - // and offset 1/2 texel to sample texel centers - vec3 pf = fract(p); // Fractional part for interpolation - - // Noise contributions from (x=0, y=0), z=0 and z=1 - float perm00 = rnm(pi.xy).a ; - vec3 grad000 = rnm(vec2(perm00, pi.z)).rgb * 4.0 - 1.0; - float n000 = dot(grad000, pf); - vec3 grad001 = rnm(vec2(perm00, pi.z + permTexUnit)).rgb * 4.0 - 1.0; - float n001 = dot(grad001, pf - vec3(0.0, 0.0, 1.0)); - - // Noise contributions from (x=0, y=1), z=0 and z=1 - float perm01 = rnm(pi.xy + vec2(0.0, permTexUnit)).a ; - vec3 grad010 = rnm(vec2(perm01, pi.z)).rgb * 4.0 - 1.0; - float n010 = dot(grad010, pf - vec3(0.0, 1.0, 0.0)); - vec3 grad011 = rnm(vec2(perm01, pi.z + permTexUnit)).rgb * 4.0 - 1.0; - float n011 = dot(grad011, pf - vec3(0.0, 1.0, 1.0)); - - // Noise contributions from (x=1, y=0), z=0 and z=1 - float perm10 = rnm(pi.xy + vec2(permTexUnit, 0.0)).a ; - vec3 grad100 = rnm(vec2(perm10, pi.z)).rgb * 4.0 - 1.0; - float n100 = dot(grad100, pf - vec3(1.0, 0.0, 0.0)); - vec3 grad101 = rnm(vec2(perm10, pi.z + permTexUnit)).rgb * 4.0 - 1.0; - float n101 = dot(grad101, pf - vec3(1.0, 0.0, 1.0)); - - // Noise contributions from (x=1, y=1), z=0 and z=1 - float perm11 = rnm(pi.xy + vec2(permTexUnit, permTexUnit)).a ; - vec3 grad110 = rnm(vec2(perm11, pi.z)).rgb * 4.0 - 1.0; - float n110 = dot(grad110, pf - vec3(1.0, 1.0, 0.0)); - vec3 grad111 = rnm(vec2(perm11, pi.z + permTexUnit)).rgb * 4.0 - 1.0; - float n111 = dot(grad111, pf - vec3(1.0, 1.0, 1.0)); - - // Blend contributions along x - vec4 n_x = mix(vec4(n000, n001, n010, n011), vec4(n100, n101, n110, n111), fade(pf.x)); - - // Blend contributions along y - vec2 n_xy = mix(n_x.xy, n_x.zw, fade(pf.y)); - - // Blend contributions along z - float n_xyz = mix(n_xy.x, n_xy.y, fade(pf.z)); - - // We are done, return the final noise value. - return n_xyz; - } - - //2d coordinate orientation thing - vec2 coordRot(in vec2 tc, in float angle) - { - float aspect = width/height; - float rotX = ((tc.x*2.0-1.0)*aspect*cos(angle)) - ((tc.y*2.0-1.0)*sin(angle)); - float rotY = ((tc.y*2.0-1.0)*cos(angle)) + ((tc.x*2.0-1.0)*aspect*sin(angle)); - rotX = ((rotX/aspect)*0.5+0.5); - rotY = rotY*0.5+0.5; - return vec2(rotX,rotY); - } - - void main() - { - vec2 texCoord = ${Shader.vTexCoord}.st; - - vec3 rotOffset = vec3(1.425,3.892,5.835); //rotation offset values - vec2 rotCoordsR = coordRot(texCoord, uTime + rotOffset.x); - vec3 noise = vec3(pnoise3D(vec3(rotCoordsR*vec2(width/grainsize,height/grainsize),0.0))); - - if (colored) - { - vec2 rotCoordsG = coordRot(texCoord, uTime + rotOffset.y); - vec2 rotCoordsB = coordRot(texCoord, uTime + rotOffset.z); - noise.g = mix(noise.r,pnoise3D(vec3(rotCoordsG*vec2(width/grainsize,height/grainsize),1.0)),coloramount); - noise.b = mix(noise.r,pnoise3D(vec3(rotCoordsB*vec2(width/grainsize,height/grainsize),2.0)),coloramount); - } - - vec3 col = texture2D(${Shader.uSampler}, ${Shader.vTexCoord}).rgb; - - //noisiness response curve based on scene luminance - vec3 lumcoeff = vec3(0.299,0.587,0.114); - float luminance = mix(0.0,dot(col, lumcoeff),lumamount); - float lum = smoothstep(0.2,0.0,luminance); - lum += luminance; - - - noise = mix(noise,vec3(0.0),pow(lum,4.0)); - col = col+noise*grainamount; - - gl_FragColor = vec4(col,1.0); - }'; - - public function new() - { - super(); - } -} diff --git a/Effects/Filters/source/openfl3/Hq2x.hx b/Effects/Filters/source/openfl3/Hq2x.hx deleted file mode 100644 index 72ff8558c..000000000 --- a/Effects/Filters/source/openfl3/Hq2x.hx +++ /dev/null @@ -1,33 +0,0 @@ -package openfl3; - -import openfl.display.Shader; - -class Hq2x extends Shader -{ - @fragment var code = ' - void main() - { - float x = 1.0 / ${Shader.uTextureSize}.x; - float y = 1.0 / ${Shader.uTextureSize}.y; - - vec4 color1 = texture2D(${Shader.uSampler}, ${Shader.vTexCoord}.st + vec2(-x, -y)); - vec4 color2 = texture2D(${Shader.uSampler}, ${Shader.vTexCoord}.st + vec2(0.0, -y)); - vec4 color3 = texture2D(${Shader.uSampler}, ${Shader.vTexCoord}.st + vec2(x, -y)); - - vec4 color4 = texture2D(${Shader.uSampler}, ${Shader.vTexCoord}.st + vec2(-x, 0.0)); - vec4 color5 = texture2D(${Shader.uSampler}, ${Shader.vTexCoord}.st + vec2(0.0, 0.0)); - vec4 color6 = texture2D(${Shader.uSampler}, ${Shader.vTexCoord}.st + vec2(x, 0.0)); - - vec4 color7 = texture2D(${Shader.uSampler}, ${Shader.vTexCoord}.st + vec2(-x, y)); - vec4 color8 = texture2D(${Shader.uSampler}, ${Shader.vTexCoord}.st + vec2(0.0, y)); - vec4 color9 = texture2D(${Shader.uSampler}, ${Shader.vTexCoord}.st + vec2(x, y)); - vec4 avg = color1 + color2 + color3 + color4 + color5 + color6 + color7 + color8 + color9; - - gl_FragColor = avg / 9.0; - }'; - - public function new() - { - super(); - } -} diff --git a/Effects/Filters/source/openfl3/Scanline.hx b/Effects/Filters/source/openfl3/Scanline.hx deleted file mode 100644 index 6e1ab853b..000000000 --- a/Effects/Filters/source/openfl3/Scanline.hx +++ /dev/null @@ -1,22 +0,0 @@ -package openfl3; - -import openfl.display.Shader; - -class Scanline extends Shader -{ - @fragment var fragment = ' - const float scale = 1.0; - - void main() - { - if (mod(floor(${Shader.vTexCoord}.y * ${Shader.uTextureSize}.y / scale), 2.0) == 0.0) - gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); - else - gl_FragColor = texture2D(${Shader.uSampler}, ${Shader.vTexCoord}); - }'; - - public function new() - { - super(); - } -} diff --git a/Effects/Filters/source/openfl3/Tiltshift.hx b/Effects/Filters/source/openfl3/Tiltshift.hx deleted file mode 100644 index 9bffd2cdd..000000000 --- a/Effects/Filters/source/openfl3/Tiltshift.hx +++ /dev/null @@ -1,89 +0,0 @@ -package openfl3; - -import openfl.display.Shader; - -class Tiltshift extends Shader -{ - @fragment var code = ' - // Modified version of a tilt shift shader from Martin Jonasson (http://grapefrukt.com/) - // Read http://notes.underscorediscovery.com/ for context on shaders and this file - // License : MIT - - /* - Take note that blurring in a single pass (the two for loops below) is more expensive than separating - the x and the y blur into different passes. This was used where bleeding edge performance - was not crucial and is to illustrate a point. - - The reason two passes is cheaper? - texture2D is a fairly high cost call, sampling a texture. - - So, in a single pass, like below, there are 3 steps, per x and y. - - That means a total of 9 "taps", it touches the texture to sample 9 times. - - Now imagine we apply this to some geometry, that is equal to 16 pixels on screen (tiny) - (16 * 16) * 9 = 2304 samples taken, for width * height number of pixels, * 9 taps - Now, if you split them up, it becomes 3 for x, and 3 for y, a total of 6 taps - (16 * 16) * 6 = 1536 samples - - That\'s on a *tiny* sprite, let\'s scale that up to 128x128 sprite... - (128 * 128) * 9 = 147,456 - (128 * 128) * 6 = 98,304 - - That\'s 33.33..% cheaper for splitting them up. - That\'s with 3 steps, with higher steps (more taps per pass...) - - A really smooth, 6 steps, 6*6 = 36 taps for one pass, 12 taps for two pass - You will notice, the curve is not linear, at 12 steps it\'s 144 vs 24 taps - It becomes orders of magnitude slower to do single pass! - Therefore, you split them up into two passes, one for x, one for y. - */ - - // I am hardcoding the constants like a jerk - - const float bluramount = 1.0; - const float center = 1.0; - const float stepSize = 0.004; - const float steps = 3.0; - - const float minOffs = (float(steps-1.0)) / -2.0; - const float maxOffs = (float(steps-1.0)) / +2.0; - - void main() { - float amount; - vec4 blurred; - - // Work out how much to blur based on the mid point - amount = pow((${Shader.vTexCoord}.y * center) * 2.0 - 1.0, 2.0) * bluramount; - - // This is the accumulation of color from the surrounding pixels in the texture - blurred = vec4(0.0, 0.0, 0.0, 1.0); - - // From minimum offset to maximum offset - for (float offsX = minOffs; offsX <= maxOffs; ++offsX) { - for (float offsY = minOffs; offsY <= maxOffs; ++offsY) { - - // copy the coord so we can mess with it - vec2 temp_tcoord = ${Shader.vTexCoord}.xy; - - //work out which uv we want to sample now - temp_tcoord.x += offsX * amount * stepSize; - temp_tcoord.y += offsY * amount * stepSize; - - // accumulate the sample - blurred += texture2D(${Shader.uSampler}, temp_tcoord); - } - } - - // because we are doing an average, we divide by the amount (x AND y, hence steps * steps) - blurred /= float(steps * steps); - - // return the final blurred color - gl_FragColor = blurred; - }'; - - public function new() - { - super(); - } -} diff --git a/Effects/FlxTrailArea/source/BlurState.hx b/Effects/FlxTrailArea/source/BlurState.hx index 35cc4bada..15fe58b72 100644 --- a/Effects/FlxTrailArea/source/BlurState.hx +++ b/Effects/FlxTrailArea/source/BlurState.hx @@ -66,7 +66,7 @@ class BlurState extends FlxState // Toggle states if (FlxG.keys.justReleased.SPACE) { - FlxG.switchState(new ParticleState()); + FlxG.switchState(ParticleState.new); } } } diff --git a/Effects/FlxTrailArea/source/ParticleState.hx b/Effects/FlxTrailArea/source/ParticleState.hx index 0249258eb..9b586e74e 100644 --- a/Effects/FlxTrailArea/source/ParticleState.hx +++ b/Effects/FlxTrailArea/source/ParticleState.hx @@ -77,7 +77,7 @@ class ParticleState extends FlxState // Toggle states if (FlxG.keys.justReleased.SPACE) - FlxG.switchState(new BlurState()); + FlxG.switchState(BlurState.new); } /** diff --git a/Effects/Transitions/source/MenuState.hx b/Effects/Transitions/source/MenuState.hx index 904718cf5..da43258ce 100644 --- a/Effects/Transitions/source/MenuState.hx +++ b/Effects/Transitions/source/MenuState.hx @@ -19,43 +19,48 @@ import flixel.util.FlxColor; class MenuState extends FlxUIState { static var initialized:Bool = false; - + + public function new() + { + super(); + } + override public function create():Void { _xml_id = "ui"; super.create(); init(); } - + function init():Void { if (!initialized) { initialized = true; - + // If this is the first time we've run the program, we initialize the TransitionData - + // When we set the default static transIn/transOut values, on construction all // FlxTransitionableStates will use those values if their own transIn/transOut states are null FlxTransitionableState.defaultTransIn = new TransitionData(); FlxTransitionableState.defaultTransOut = new TransitionData(); - + var diamond:FlxGraphic = FlxGraphic.fromClass(GraphicTransTileDiamond); diamond.persist = true; diamond.destroyOnNoUse = false; - + FlxTransitionableState.defaultTransIn.tileData = {asset: diamond, width: 32, height: 32}; FlxTransitionableState.defaultTransOut.tileData = {asset: diamond, width: 32, height: 32}; - + // Of course, this state has already been constructed, so we need to set a transOut value for it right now: transOut = FlxTransitionableState.defaultTransOut; } - + // Now we just have the UI synchronize with the starting values: matchTransitionData(); matchUI(false); } - + function matchUI(matchData:Bool = true):Void { var in_duration:FlxUINumericStepper = cast _ui.getAsset("in_duration"); @@ -63,34 +68,34 @@ class MenuState extends FlxUIState var in_tile:FlxUIRadioGroup = cast _ui.getAsset("in_tile"); var in_color:FlxUIRadioGroup = cast _ui.getAsset("in_color"); var in_dir:FlxUIRadioGroup = cast _ui.getAsset("in_dir"); - + var out_duration:FlxUINumericStepper = cast _ui.getAsset("out_duration"); var out_type:FlxUIRadioGroup = cast _ui.getAsset("out_type"); var out_tile:FlxUIRadioGroup = cast _ui.getAsset("out_tile"); var out_color:FlxUIRadioGroup = cast _ui.getAsset("out_color"); var out_dir:FlxUIRadioGroup = cast _ui.getAsset("out_dir"); - + FlxTransitionableState.defaultTransIn.color = FlxColor.fromString(in_color.selectedId); FlxTransitionableState.defaultTransIn.type = cast in_type.selectedId; setDirectionFromStr(in_dir.selectedId, FlxTransitionableState.defaultTransIn.direction); FlxTransitionableState.defaultTransIn.duration = in_duration.value; FlxTransitionableState.defaultTransIn.tileData.asset = getDefaultAsset(in_tile.selectedId); - + FlxTransitionableState.defaultTransOut.color = FlxColor.fromString(out_color.selectedId); FlxTransitionableState.defaultTransOut.type = cast out_type.selectedId; setDirectionFromStr(out_dir.selectedId, FlxTransitionableState.defaultTransOut.direction); FlxTransitionableState.defaultTransOut.duration = out_duration.value; FlxTransitionableState.defaultTransOut.tileData.asset = getDefaultAsset(out_tile.selectedId); - + transIn = FlxTransitionableState.defaultTransIn; transOut = FlxTransitionableState.defaultTransOut; - + if (matchData) { matchTransitionData(); } } - + function matchTransitionData():Void { var in_duration:FlxUINumericStepper = cast _ui.getAsset("in_duration"); @@ -99,14 +104,14 @@ class MenuState extends FlxUIState var in_tile_text:FlxUIText = cast _ui.getAsset("in_tile_text"); var in_color:FlxUIRadioGroup = cast _ui.getAsset("in_color"); var in_dir:FlxUIRadioGroup = cast _ui.getAsset("in_dir"); - + var out_duration:FlxUINumericStepper = cast _ui.getAsset("out_duration"); var out_type:FlxUIRadioGroup = cast _ui.getAsset("out_type"); var out_tile:FlxUIRadioGroup = cast _ui.getAsset("out_tile"); var out_tile_text:FlxUIText = cast _ui.getAsset("out_tile_text"); var out_color:FlxUIRadioGroup = cast _ui.getAsset("out_color"); var out_dir:FlxUIRadioGroup = cast _ui.getAsset("out_dir"); - + in_duration.value = FlxTransitionableState.defaultTransIn.duration; in_type.selectedId = cast FlxTransitionableState.defaultTransIn.type; if (FlxTransitionableState.defaultTransIn.type == TILES) @@ -129,7 +134,7 @@ class MenuState extends FlxUIState case _: "black"; } in_dir.selectedId = getDirection(cast FlxTransitionableState.defaultTransIn.direction.x, cast FlxTransitionableState.defaultTransIn.direction.y); - + out_duration.value = FlxTransitionableState.defaultTransOut.duration; out_type.selectedId = cast FlxTransitionableState.defaultTransOut.type; if (FlxTransitionableState.defaultTransOut.type == TILES) @@ -142,7 +147,7 @@ class MenuState extends FlxUIState { out_tile_text.visible = out_tile.visible = false; } - + out_color.selectedId = switch (FlxTransitionableState.defaultTransOut.color) { case FlxColor.RED: "red"; @@ -152,10 +157,10 @@ class MenuState extends FlxUIState case FlxColor.GREEN: "green"; case _: "black"; } - + out_dir.selectedId = getDirection(cast FlxTransitionableState.defaultTransOut.direction.x, cast FlxTransitionableState.defaultTransOut.direction.y); } - + function getDefaultAssetStr(c:FlxGraphic):String { return switch (c.assetsClass) @@ -165,7 +170,7 @@ class MenuState extends FlxUIState case GraphicTransTileDiamond, _: "diamond"; } } - + function getDefaultAsset(str):FlxGraphic { var graphicClass:Class = switch (str) @@ -174,13 +179,13 @@ class MenuState extends FlxUIState case "square": GraphicTransTileSquare; case "diamond", _: GraphicTransTileDiamond; } - + var graphic = FlxGraphic.fromClass(cast graphicClass); graphic.persist = true; graphic.destroyOnNoUse = false; return graphic; } - + function getDirection(ix:Int, iy:Int):String { if (ix < 0) @@ -210,12 +215,12 @@ class MenuState extends FlxUIState } return "center"; } - + function setDirectionFromStr(str:String, ?p:FlxPoint):FlxPoint { if (p == null) p = new FlxPoint(); - + switch (str) { case "n": @@ -239,12 +244,12 @@ class MenuState extends FlxUIState } return p; } - + function transition():Void { - FlxG.switchState(new MenuStateB()); + FlxG.switchState(MenuStateB.new); } - + override public function getEvent(id:String, sender:Dynamic, data:Dynamic, ?params:Array):Void { switch (id) diff --git a/Effects/Transitions/source/MenuStateB.hx b/Effects/Transitions/source/MenuStateB.hx index 57fab0af4..56bf761e1 100644 --- a/Effects/Transitions/source/MenuStateB.hx +++ b/Effects/Transitions/source/MenuStateB.hx @@ -17,9 +17,9 @@ class MenuStateB extends MenuState var welcome:FlxUIText = cast _ui.getAsset("welcome"); welcome.text = "STATE B"; } - + override function transition():Void { - FlxG.switchState(new MenuState()); + FlxG.switchState(MenuState.new); } } diff --git a/Features/FlxNapeTilemap/source/Main.hx b/Features/FlxNapeTilemap/source/Main.hx index 755e813af..283f9709f 100644 --- a/Features/FlxNapeTilemap/source/Main.hx +++ b/Features/FlxNapeTilemap/source/Main.hx @@ -2,7 +2,6 @@ package; import flixel.FlxGame; import openfl.display.Sprite; -import states.PlayState; class Main extends Sprite { diff --git a/Features/FlxNapeTilemap/source/states/PlayState.hx b/Features/FlxNapeTilemap/source/PlayState.hx similarity index 97% rename from Features/FlxNapeTilemap/source/states/PlayState.hx rename to Features/FlxNapeTilemap/source/PlayState.hx index abfbcd444..7b01e2acb 100644 --- a/Features/FlxNapeTilemap/source/states/PlayState.hx +++ b/Features/FlxNapeTilemap/source/PlayState.hx @@ -1,5 +1,3 @@ -package states; - import flixel.addons.nape.*; import flixel.FlxG; import flixel.FlxState; @@ -91,7 +89,7 @@ class PlayState extends FlxState } } -@:enum abstract Level(String) to String +enum abstract Level(String) to String { var FIRST = "assets/testmap.csv"; var SECOND = "assets/testmap2.csv"; diff --git a/Features/Replay/source/PlayState.hx b/Features/Replay/source/PlayState.hx index 143ecc15d..ea5aee9ef 100644 --- a/Features/Replay/source/PlayState.hx +++ b/Features/Replay/source/PlayState.hx @@ -165,6 +165,6 @@ class PlayState extends FlxState */ var save:String = FlxG.vcr.stopRecording(false); - FlxG.vcr.loadReplay(save, new PlayState(), ["ANY", "MOUSE"], 0, startRecording); + FlxG.vcr.loadReplay(save, PlayState.new, ["ANY", "MOUSE"], 0, startRecording); } } diff --git a/Features/ScaleModes/source/PlayState.hx b/Features/ScaleModes/source/PlayState.hx index 7a0b9ed2e..dd4340118 100644 --- a/Features/ScaleModes/source/PlayState.hx +++ b/Features/ScaleModes/source/PlayState.hx @@ -72,8 +72,7 @@ class PlayState extends FlxState } } -@:enum -abstract ScaleMode(String) to String +enum abstract ScaleMode(String) to String { var RATIO_DEFAULT = "ratio"; var RATIO_FILL_SCREEN = "ratio (screenfill)"; diff --git a/Other/BSPMapGen/source/generate/GenerateState.hx b/Other/BSPMapGen/source/generate/GenerateState.hx index 379637477..e6d10ddfa 100644 --- a/Other/BSPMapGen/source/generate/GenerateState.hx +++ b/Other/BSPMapGen/source/generate/GenerateState.hx @@ -148,6 +148,6 @@ class GenerateState extends FlxState function play():Void { - FlxG.switchState(new PlayState()); + FlxG.switchState(PlayState.new); } } diff --git a/Other/BSPMapGen/source/play/PlayState.hx b/Other/BSPMapGen/source/play/PlayState.hx index cea5a65b9..2fd072ce3 100644 --- a/Other/BSPMapGen/source/play/PlayState.hx +++ b/Other/BSPMapGen/source/play/PlayState.hx @@ -45,6 +45,6 @@ class PlayState extends FlxState function back():Void { - FlxG.switchState(new GenerateState()); + FlxG.switchState(GenerateState.new); } } diff --git a/Other/Calculator/source/State.hx b/Other/Calculator/source/State.hx index 5e8373a04..a0e35d75e 100644 --- a/Other/Calculator/source/State.hx +++ b/Other/Calculator/source/State.hx @@ -13,7 +13,6 @@ import flixel.math.FlxMath; import flixel.math.FlxPoint; import flixel.math.FlxRandom; import flixel.math.FlxRect; -import flixel.math.FlxVector; import flixel.math.FlxVelocity; import flixel.system.scaleModes.PixelPerfectScaleMode; import flixel.text.FlxText; diff --git a/Other/FlxCollisions/source/PlayState.hx b/Other/FlxCollisions/source/PlayState.hx index 759feb048..ae434b2b2 100644 --- a/Other/FlxCollisions/source/PlayState.hx +++ b/Other/FlxCollisions/source/PlayState.hx @@ -105,7 +105,7 @@ class PlayState extends FlxState if (FlxG.keys.justReleased.ENTER) { - FlxG.switchState(new PlayState2()); + FlxG.switchState(PlayState2.new); } super.update(elapsed); diff --git a/Other/FlxCollisions/source/PlayState2.hx b/Other/FlxCollisions/source/PlayState2.hx index 6c9626921..a9ed868f6 100644 --- a/Other/FlxCollisions/source/PlayState2.hx +++ b/Other/FlxCollisions/source/PlayState2.hx @@ -96,7 +96,7 @@ class PlayState2 extends FlxState if (FlxG.keys.justReleased.ENTER) { - FlxG.switchState(new PlayState3()); + FlxG.switchState(PlayState3.new); } } } diff --git a/Other/FlxCollisions/source/PlayState3.hx b/Other/FlxCollisions/source/PlayState3.hx index ab14418df..d09bc56c7 100644 --- a/Other/FlxCollisions/source/PlayState3.hx +++ b/Other/FlxCollisions/source/PlayState3.hx @@ -75,7 +75,7 @@ class PlayState3 extends FlxState if (FlxG.keys.justReleased.ENTER) { - FlxG.switchState(new PlayState()); + FlxG.switchState(PlayState.new); } } } diff --git a/Other/FrameCollections/source/PlayState.hx b/Other/FrameCollections/source/PlayState.hx index 2cb2388dc..839c67161 100644 --- a/Other/FrameCollections/source/PlayState.hx +++ b/Other/FrameCollections/source/PlayState.hx @@ -86,7 +86,7 @@ class PlayState extends FlxState bitmapText.autoSize = true; bitmapText.multiLine = true; - bitmapText.wrapByWord = true; + bitmapText.wrap = WORD(NEVER); bitmapText.text = "Math \n for game developers"; bitmapText.y = 40; bitmapText.alignment = CENTER; diff --git a/Performance/PixelPerfectCollision/source/PlayState.hx b/Performance/PixelPerfectCollision/source/PlayState.hx index 2b2ab1d46..e73976d8d 100644 --- a/Performance/PixelPerfectCollision/source/PlayState.hx +++ b/Performance/PixelPerfectCollision/source/PlayState.hx @@ -7,7 +7,6 @@ import flixel.text.FlxText; import flixel.tweens.FlxEase; import flixel.tweens.FlxTween; import flixel.math.FlxPoint; -import flixel.math.FlxVector; import flixel.math.FlxAngle; import flixel.util.FlxColor; import flixel.util.FlxCollision; diff --git a/Platformers/FlipRotationAnimationTiles/source/entities/Character.hx b/Platformers/FlipRotationAnimationTiles/source/entities/Character.hx index 36c4226bd..ea869566e 100644 --- a/Platformers/FlipRotationAnimationTiles/source/entities/Character.hx +++ b/Platformers/FlipRotationAnimationTiles/source/entities/Character.hx @@ -1,7 +1,7 @@ package entities; import flixel.FlxG; -import flixel.addons.display.FlxExtendedSprite; +import flixel.addons.display.FlxExtendedMouseSprite; import flixel.math.FlxRect; import haxe.Json; import haxe.io.Path; @@ -10,7 +10,7 @@ import openfl.Assets; /** * @author MrCdK */ -class Character extends FlxExtendedSprite +class Character extends FlxExtendedMouseSprite { public var collisionMap:FlxRect; public var maxBounds:FlxRect; diff --git a/Platformers/Mode/source/MenuState.hx b/Platformers/Mode/source/MenuState.hx index 3849e10b1..f407801c8 100644 --- a/Platformers/Mode/source/MenuState.hx +++ b/Platformers/Mode/source/MenuState.hx @@ -198,10 +198,10 @@ class MenuState extends FlxState { if (_demoMode) { - FlxG.vcr.loadReplay(Assets.getText('assets/data/demo${FlxG.random.int(1, 2)}.fgr'), new PlayState(), ["ANY"], 22, onDemoComplete); + FlxG.vcr.loadReplay(Assets.getText('assets/data/demo${FlxG.random.int(1, 2)}.fgr'), PlayState.new, ["ANY"], 22, onDemoComplete); } else - FlxG.switchState(new PlayState()); + FlxG.switchState(PlayState.new); } /** diff --git a/Platformers/Mode/source/PlayState.hx b/Platformers/Mode/source/PlayState.hx index 18a9b148b..82066eaff 100644 --- a/Platformers/Mode/source/PlayState.hx +++ b/Platformers/Mode/source/PlayState.hx @@ -341,7 +341,7 @@ class PlayState extends FlxState // Escape to the main menu #if FLX_KEYBOARD if (FlxG.keys.pressed.ESCAPE) - FlxG.switchState(new MenuState()); + FlxG.switchState(MenuState.new); #end } @@ -363,7 +363,7 @@ class PlayState extends FlxState { // Reset the sounds for going inbetween the menu etc FlxG.sound.destroy(true); - FlxG.switchState(new VictoryState()); + FlxG.switchState(VictoryState.new); } /** diff --git a/Platformers/Mode/source/Player.hx b/Platformers/Mode/source/Player.hx index f94fdacd6..122753247 100644 --- a/Platformers/Mode/source/Player.hx +++ b/Platformers/Mode/source/Player.hx @@ -297,7 +297,7 @@ class Player extends FlxSprite } } -@:enum abstract Animation(String) to String +enum abstract Animation(String) to String { var IDLE = "idle"; var IDLE_UP = "idle_up"; diff --git a/Platformers/Mode/source/VictoryState.hx b/Platformers/Mode/source/VictoryState.hx index 42ce3d7ea..b68ad0c67 100644 --- a/Platformers/Mode/source/VictoryState.hx +++ b/Platformers/Mode/source/VictoryState.hx @@ -54,7 +54,7 @@ class VictoryState extends FlxState FlxG.sound.play(FlxAssets.getSound("assets/sounds/menu_hit_2")); FlxG.cameras.fade(0xff131c1b, 2, false, function() { - FlxG.switchState(new PlayState()); + FlxG.switchState(PlayState.new); }); } } diff --git a/Platformers/ProjectJumper/source/MenuState.hx b/Platformers/ProjectJumper/source/MenuState.hx index 4280b6495..2cdd03957 100644 --- a/Platformers/ProjectJumper/source/MenuState.hx +++ b/Platformers/ProjectJumper/source/MenuState.hx @@ -126,7 +126,7 @@ class MenuState extends FlxState function startGame():Void { - FlxG.switchState(new PlayState()); + FlxG.switchState(PlayState.new); } } diff --git a/Platformers/ProjectJumper/source/PlayState.hx b/Platformers/ProjectJumper/source/PlayState.hx index 92565a78c..a2244c20d 100644 --- a/Platformers/ProjectJumper/source/PlayState.hx +++ b/Platformers/ProjectJumper/source/PlayState.hx @@ -143,7 +143,7 @@ class PlayState extends FlxState if (_restart) { - FlxG.switchState(new PlayState()); + FlxG.switchState(PlayState.new); } } diff --git a/Platformers/Revenge/source/EndState.hx b/Platformers/Revenge/source/EndState.hx index 6d80065c1..0265d7335 100644 --- a/Platformers/Revenge/source/EndState.hx +++ b/Platformers/Revenge/source/EndState.hx @@ -72,6 +72,6 @@ class EndState extends FlxState function onFade():Void { - FlxG.switchState(new MenuState()); + FlxG.switchState(MenuState.new); } } diff --git a/Platformers/Revenge/source/MenuState.hx b/Platformers/Revenge/source/MenuState.hx index c0ff55fe5..b129193c1 100644 --- a/Platformers/Revenge/source/MenuState.hx +++ b/Platformers/Revenge/source/MenuState.hx @@ -80,7 +80,7 @@ class MenuState extends FlxState function onFade():Void { - FlxG.switchState(new PlayState()); + FlxG.switchState(PlayState.new); } function onStartOver():Void diff --git a/Platformers/Revenge/source/PlayState.hx b/Platformers/Revenge/source/PlayState.hx index 2ba561754..172988e46 100644 --- a/Platformers/Revenge/source/PlayState.hx +++ b/Platformers/Revenge/source/PlayState.hx @@ -177,6 +177,6 @@ class PlayState extends FlxState function onFade():Void { // FlxG.fade.start also takes in a callback which is called after the fade ends!! - FlxG.switchState(new EndState()); + FlxG.switchState(EndState.new); } } diff --git a/Tutorials/TurnBasedRPG/source/CombatHUD.hx b/Tutorials/TurnBasedRPG/source/CombatHUD.hx index 28485e5e4..07eb8b5a2 100644 --- a/Tutorials/TurnBasedRPG/source/CombatHUD.hx +++ b/Tutorials/TurnBasedRPG/source/CombatHUD.hx @@ -8,7 +8,7 @@ import flixel.FlxSprite; import flixel.addons.effects.chainable.FlxEffectSprite; import flixel.addons.effects.chainable.FlxWaveEffect; import flixel.group.FlxGroup.FlxTypedGroup; -import flixel.system.FlxSound; +import flixel.sound.FlxSound; import flixel.text.FlxText; import flixel.tweens.FlxEase; import flixel.tweens.FlxTween; diff --git a/Tutorials/TurnBasedRPG/source/Enemy.hx b/Tutorials/TurnBasedRPG/source/Enemy.hx index 39c79daed..db26ef240 100644 --- a/Tutorials/TurnBasedRPG/source/Enemy.hx +++ b/Tutorials/TurnBasedRPG/source/Enemy.hx @@ -4,7 +4,7 @@ import flixel.FlxG; import flixel.FlxSprite; import flixel.math.FlxPoint; import flixel.math.FlxVelocity; -import flixel.system.FlxSound; +import flixel.sound.FlxSound; using flixel.util.FlxSpriteUtil; @@ -22,7 +22,7 @@ class Enemy extends FlxSprite var brain:FSM; var idleTimer:Float; var moveDirection:Float; - var stepSound:FlxSound; + var stepSound:FlxSound; public var type(default, null):EnemyType; public var seesPlayer:Bool; diff --git a/Tutorials/TurnBasedRPG/source/GameOverState.hx b/Tutorials/TurnBasedRPG/source/GameOverState.hx index fe825ed6e..f824af731 100644 --- a/Tutorials/TurnBasedRPG/source/GameOverState.hx +++ b/Tutorials/TurnBasedRPG/source/GameOverState.hx @@ -10,8 +10,6 @@ import flixel.util.FlxColor; class GameOverState extends FlxState { - var score:Int = 0; // number of coins we've collected - var win:Bool; // if we won or lost var titleText:FlxText; // the title text var messageText:FlxText; // the final score message text var scoreIcon:FlxSprite; // sprite for a coin icon @@ -27,12 +25,7 @@ class GameOverState extends FlxState public function new(win:Bool, score:Int) { super(); - this.win = win; - this.score = score; - } - override public function create() - { #if FLX_MOUSE FlxG.mouse.visible = true; #end @@ -71,8 +64,6 @@ class GameOverState extends FlxState add(mainMenuButton); FlxG.camera.fade(FlxColor.BLACK, 0.33, true); - - super.create(); } /** @@ -103,7 +94,7 @@ class GameOverState extends FlxState { FlxG.camera.fade(FlxColor.BLACK, 0.33, false, function() { - FlxG.switchState(new MenuState()); + FlxG.switchState(MenuState.new); }); } } diff --git a/Tutorials/TurnBasedRPG/source/HUD.hx b/Tutorials/TurnBasedRPG/source/HUD.hx index 8db8bfc9a..09db963d2 100644 --- a/Tutorials/TurnBasedRPG/source/HUD.hx +++ b/Tutorials/TurnBasedRPG/source/HUD.hx @@ -2,7 +2,7 @@ package; import flixel.FlxG; import flixel.FlxSprite; -import flixel.group.FlxGroup.FlxTypedGroup; +import flixel.group.FlxGroup; import flixel.text.FlxText; import flixel.util.FlxColor; diff --git a/Tutorials/TurnBasedRPG/source/MenuState.hx b/Tutorials/TurnBasedRPG/source/MenuState.hx index 8a8f5578c..29a71272d 100644 --- a/Tutorials/TurnBasedRPG/source/MenuState.hx +++ b/Tutorials/TurnBasedRPG/source/MenuState.hx @@ -57,7 +57,7 @@ class MenuState extends FlxState { FlxG.camera.fade(FlxColor.BLACK, 0.33, false, function() { - FlxG.switchState(new PlayState()); + FlxG.switchState(PlayState.new); }); } @@ -65,7 +65,7 @@ class MenuState extends FlxState { FlxG.camera.fade(FlxColor.BLACK, 0.33, false, function() { - FlxG.switchState(new OptionsState()); + FlxG.switchState(OptionsState.new); }); } diff --git a/Tutorials/TurnBasedRPG/source/OptionsState.hx b/Tutorials/TurnBasedRPG/source/OptionsState.hx index 23eec3da5..4a567f211 100644 --- a/Tutorials/TurnBasedRPG/source/OptionsState.hx +++ b/Tutorials/TurnBasedRPG/source/OptionsState.hx @@ -37,7 +37,8 @@ class OptionsState extends FlxState add(volumeText); // the volume buttons will be smaller than 'default' buttons - volumeDownButton = new FlxButton(8, volumeText.y + volumeText.height + 2, "-", clickVolumeDown); + volumeDownButton = new FlxButton(8, volumeText.y + volumeText.height + 2, "-", + clickVolumeDown); volumeDownButton.loadGraphic(AssetPaths.button__png, true, 20, 20); volumeDownButton.onUp.sound = FlxG.sound.load(AssetPaths.select__wav); add(volumeDownButton); @@ -47,7 +48,8 @@ class OptionsState extends FlxState volumeUpButton.onUp.sound = FlxG.sound.load(AssetPaths.select__wav); add(volumeUpButton); - volumeBar = new FlxBar(volumeDownButton.x + volumeDownButton.width + 4, volumeDownButton.y, LEFT_TO_RIGHT, Std.int(FlxG.width - 64), + volumeBar = new FlxBar(volumeDownButton.x + volumeDownButton.width + 4, + volumeDownButton.y, LEFT_TO_RIGHT, Std.int(FlxG.width - 64), Std.int(volumeUpButton.height)); volumeBar.createFilledBar(0xff464646, FlxColor.WHITE, true, FlxColor.WHITE); add(volumeBar); @@ -61,12 +63,14 @@ class OptionsState extends FlxState add(volumeAmountText); #if desktop - fullscreenButton = new FlxButton(0, volumeBar.y + volumeBar.height + 8, FlxG.fullscreen ? "FULLSCREEN" : "WINDOWED", clickFullscreen); + fullscreenButton = new FlxButton(0, volumeBar.y + volumeBar.height + 8, + FlxG.fullscreen ? "FULLSCREEN" : "WINDOWED", clickFullscreen); fullscreenButton.screenCenter(FlxAxes.X); add(fullscreenButton); #end - clearDataButton = new FlxButton((FlxG.width / 2) - 90, FlxG.height - 28, "Clear Data", clickClearData); + clearDataButton = new FlxButton((FlxG.width / 2) - 90, FlxG.height - 28, "Clear Data", + clickClearData); clearDataButton.onUp.sound = FlxG.sound.load(AssetPaths.select__wav); add(clearDataButton); @@ -109,7 +113,7 @@ class OptionsState extends FlxState FlxG.save.flush(); FlxG.camera.fade(FlxColor.BLACK, .33, false, function() { - FlxG.switchState(new MenuState()); + FlxG.switchState(MenuState.new); }); } diff --git a/Tutorials/TurnBasedRPG/source/PlayState.hx b/Tutorials/TurnBasedRPG/source/PlayState.hx index 399501fc6..b2a51962b 100644 --- a/Tutorials/TurnBasedRPG/source/PlayState.hx +++ b/Tutorials/TurnBasedRPG/source/PlayState.hx @@ -4,7 +4,7 @@ import flixel.FlxG; import flixel.FlxState; import flixel.addons.editors.ogmo.FlxOgmo3Loader; import flixel.group.FlxGroup.FlxTypedGroup; -import flixel.system.FlxSound; +import flixel.sound.FlxSound; import flixel.tile.FlxTilemap; import flixel.util.FlxColor; #if mobile @@ -159,7 +159,7 @@ class PlayState extends FlxState function doneFadeOut() { - FlxG.switchState(new GameOverState(won, money)); + FlxG.switchState(() -> new GameOverState(won, money)); } function playerTouchCoin(player:Player, coin:Coin) diff --git a/Tutorials/TurnBasedRPG/source/Player.hx b/Tutorials/TurnBasedRPG/source/Player.hx index 92c319b57..32a3186e6 100644 --- a/Tutorials/TurnBasedRPG/source/Player.hx +++ b/Tutorials/TurnBasedRPG/source/Player.hx @@ -3,7 +3,7 @@ package; import flixel.FlxG; import flixel.FlxSprite; import flixel.math.FlxPoint; -import flixel.system.FlxSound; +import flixel.sound.FlxSound; class Player extends FlxSprite { diff --git a/UserInterface/FlxBitmapText/source/PlayState.hx b/UserInterface/FlxBitmapText/source/PlayState.hx index 75db9b4da..8a45bcc40 100644 --- a/UserInterface/FlxBitmapText/source/PlayState.hx +++ b/UserInterface/FlxBitmapText/source/PlayState.hx @@ -65,7 +65,7 @@ class PlayState extends FlxState tf2.letterSpacing = 25; tf2.autoUpperCase = true; tf2.multiLine = true; - tf2.wordWrap = false; + tf2.wrap = NONE; tf2.screenCenter(FlxAxes.X); add(tf2); @@ -80,7 +80,7 @@ class PlayState extends FlxState tf4.y = tf3.y + tf3.height + 50; tf4.alignment = FlxTextAlign.CENTER; tf4.text = "!\u20e4 You can e\u0332v\u0332e\u0332n\u0332 define and use\nUnicode Combining Diacritical Marks!"; - tf4.multiLine = true; + tf4.multiLine = true; tf4.screenCenter(FlxAxes.X); add(tf4); } diff --git a/UserInterface/RPGInterface/source/State_Battle.hx b/UserInterface/RPGInterface/source/State_Battle.hx index adafa1491..b87deaf1c 100644 --- a/UserInterface/RPGInterface/source/State_Battle.hx +++ b/UserInterface/RPGInterface/source/State_Battle.hx @@ -9,6 +9,11 @@ import openfl.events.Event; */ class State_Battle extends FlxUIState { + public function new() + { + super(); + } + override public function create() { _xml_id = "state_battle"; @@ -76,7 +81,7 @@ class State_Battle extends FlxUIState case FlxUITypedButton.CLICK_EVENT: switch (Std.string(params[0])) { - case "back": FlxG.switchState(new State_Title()); + case "back": FlxG.switchState(State_Title.new); } } } diff --git a/UserInterface/RPGInterface/source/State_CodeTest.hx b/UserInterface/RPGInterface/source/State_CodeTest.hx index 6c26d1582..797069933 100644 --- a/UserInterface/RPGInterface/source/State_CodeTest.hx +++ b/UserInterface/RPGInterface/source/State_CodeTest.hx @@ -15,6 +15,11 @@ import flixel.addons.ui.FlxUIState; */ class State_CodeTest extends FlxUIState { + public function new() + { + super(); + } + override public function create() { super.create(); @@ -36,7 +41,7 @@ class State_CodeTest extends FlxUIState case "click_button": switch (Std.string(params[0])) { - case "back": FlxG.switchState(new State_Title()); + case "back": FlxG.switchState(State_Title.new); } } } diff --git a/UserInterface/RPGInterface/source/State_DefaultTest.hx b/UserInterface/RPGInterface/source/State_DefaultTest.hx index 7ef6e5972..f1b98607c 100644 --- a/UserInterface/RPGInterface/source/State_DefaultTest.hx +++ b/UserInterface/RPGInterface/source/State_DefaultTest.hx @@ -7,6 +7,11 @@ import flixel.addons.ui.FlxUIState; */ class State_DefaultTest extends FlxUIState { + public function new() + { + super(); + } + override public function create() { _xml_id = "state_default"; @@ -27,7 +32,7 @@ class State_DefaultTest extends FlxUIState case "click_button": switch (Std.string(params[0])) { - case "back": FlxG.switchState(new State_Title()); + case "back": FlxG.switchState(State_Title.new); case "popup": var popup:FlxUIPopup = new FlxUIPopup(); // create the popup popup.quickSetup // set it up diff --git a/UserInterface/RPGInterface/source/State_SaveMenu.hx b/UserInterface/RPGInterface/source/State_SaveMenu.hx index 4580acdcd..2bdbd9881 100644 --- a/UserInterface/RPGInterface/source/State_SaveMenu.hx +++ b/UserInterface/RPGInterface/source/State_SaveMenu.hx @@ -10,6 +10,11 @@ import haxe.xml.Access; */ class State_SaveMenu extends FlxUIState { + public function new() + { + super(); + } + override public function create() { _xml_id = "state_save"; @@ -43,7 +48,7 @@ class State_SaveMenu extends FlxUIState case "click_button": switch (Std.string(params[0])) { - case "back": FlxG.switchState(new State_Title()); + case "back": FlxG.switchState(State_Title.new); } } } diff --git a/UserInterface/RPGInterface/source/State_TestMenu.hx b/UserInterface/RPGInterface/source/State_TestMenu.hx index c30de315d..b34b721f7 100644 --- a/UserInterface/RPGInterface/source/State_TestMenu.hx +++ b/UserInterface/RPGInterface/source/State_TestMenu.hx @@ -6,6 +6,11 @@ import flixel.addons.ui.FlxUIState; */ class State_TestMenu extends FlxUIState { + public function new() + { + super(); + } + override public function create() { _xml_id = "state_menu"; @@ -26,7 +31,7 @@ class State_TestMenu extends FlxUIState case "click_button": switch (Std.string(params[0])) { - case "back": FlxG.switchState(new State_Title()); + case "back": FlxG.switchState(State_Title.new); } } } diff --git a/UserInterface/RPGInterface/source/State_Title.hx b/UserInterface/RPGInterface/source/State_Title.hx index e524812c9..79d72338f 100644 --- a/UserInterface/RPGInterface/source/State_Title.hx +++ b/UserInterface/RPGInterface/source/State_Title.hx @@ -8,6 +8,11 @@ import flixel.addons.ui.FlxUIState; */ class State_Title extends FlxUIState { + public function new() + { + super(); + } + override public function create():Void { FlxG.cameras.bgColor = 0xff131c1b; @@ -39,11 +44,11 @@ class State_Title extends FlxUIState { switch (Std.string(params[0])) { - case "saves": FlxG.switchState(new State_SaveMenu()); - case "menu": FlxG.switchState(new State_TestMenu()); - case "battle": FlxG.switchState(new State_Battle()); - case "default_test": FlxG.switchState(new State_DefaultTest()); - case "code_test": FlxG.switchState(new State_CodeTest()); + case "saves": FlxG.switchState(State_SaveMenu.new); + case "menu": FlxG.switchState(State_TestMenu.new); + case "battle": FlxG.switchState(State_Battle.new); + case "default_test": FlxG.switchState(State_DefaultTest.new); + case "code_test": FlxG.switchState(State_CodeTest.new); case "popup": openSubState(new Popup_Demo()); } } @@ -58,6 +63,6 @@ class State_Title extends FlxUIState function reloadState():Void { - FlxG.switchState(new State_Title()); + FlxG.switchState(State_Title.new); } } diff --git a/UserInterface/Tooltips/source/State_Demo.hx b/UserInterface/Tooltips/source/State_Demo.hx index b0e8dd7b7..3f8df7927 100644 --- a/UserInterface/Tooltips/source/State_Demo.hx +++ b/UserInterface/Tooltips/source/State_Demo.hx @@ -7,6 +7,11 @@ import flixel.addons.ui.FlxUIState; */ class State_Demo extends FlxUIState { + public function new() + { + super(); + } + override public function create() { _xml_id = "state_menu"; @@ -22,11 +27,11 @@ class State_Demo extends FlxUIState var str:String = (params != null && params.length >= 1) ? cast params[0] : ""; if (str == "defaults") { - FlxG.switchState(new State_Demo2()); + FlxG.switchState(State_Demo2.new); } if (str == "hand_code") { - FlxG.switchState(new State_DemoCode()); + FlxG.switchState(State_DemoCode.new); } } } @@ -37,7 +42,7 @@ class State_Demo extends FlxUIState #if debug if (FlxG.keys.justPressed.R) { - FlxG.switchState(new State_Demo()); + FlxG.switchState(State_Demo.new); } #end } diff --git a/UserInterface/Tooltips/source/State_Demo2.hx b/UserInterface/Tooltips/source/State_Demo2.hx index 37cb2a704..4f4c31cd7 100644 --- a/UserInterface/Tooltips/source/State_Demo2.hx +++ b/UserInterface/Tooltips/source/State_Demo2.hx @@ -29,11 +29,11 @@ class State_Demo2 extends FlxUIState var str:String = (params != null && params.length >= 1) ? cast params[0] : ""; if (str == "no_defaults") { - FlxG.switchState(new State_Demo()); + FlxG.switchState(State_Demo.new); } if (str == "hand_code") { - FlxG.switchState(new State_DemoCode()); + FlxG.switchState(State_DemoCode.new); } } } diff --git a/UserInterface/Tooltips/source/State_DemoCode.hx b/UserInterface/Tooltips/source/State_DemoCode.hx index 1eacd0f7f..94c67ddc4 100644 --- a/UserInterface/Tooltips/source/State_DemoCode.hx +++ b/UserInterface/Tooltips/source/State_DemoCode.hx @@ -19,6 +19,11 @@ import openfl.text.TextFormatAlign; */ class State_DemoCode extends FlxUIState { + public function new() + { + super(); + } + override public function create() { super.create(); @@ -34,11 +39,11 @@ class State_DemoCode extends FlxUIState var str:String = (params != null && params.length >= 1) ? cast params[0] : ""; if (str == "defaults") { - FlxG.switchState(new State_Demo2()); + FlxG.switchState(State_Demo2.new); } if (str == "no_defaults") { - FlxG.switchState(new State_Demo()); + FlxG.switchState(State_Demo.new); } } } @@ -71,30 +76,33 @@ class State_DemoCode extends FlxUIState {bodyWidth: 100}); b = addBtn("even_fancier", new FlxUIButton(b.x, b.y + b.height + 10, "Even fancier"), "Even fancier tooltip!", - "This tooltip has a title and a body, as well as custom padding and offsets", null, - {titleWidth: 120, bodyWidth: 120, bodyOffset: new FlxPoint(5, 5)}); + "This tooltip has a title and a body, as well as custom padding and offsets", null, { + titleWidth: 120, + bodyWidth: 120, + bodyOffset: new FlxPoint(5, 5) + }); b = addBtn("fanciest", new FlxUIButton(b.x, b.y + b.height + 10, "Fanciest"), "Fanciest tooltip", "This tooltip has a title and a body, custom padding and offsets, as well as custom text formatting", null, { - titleWidth: 125, - bodyWidth: 120, - bodyOffset: new FlxPoint(5, 5), - titleFormat: sans12, - bodyFormat: sans10, - titleBorder: border, - bodyBorder: border, - leftPadding: 5, - rightPadding: 5, - topPadding: 5, - bottomPadding: 5, - background: FlxColor.RED, - borderSize: 1, - borderColor: FlxColor.WHITE - }); + titleWidth: 125, + bodyWidth: 120, + bodyOffset: new FlxPoint(5, 5), + titleFormat: sans12, + bodyFormat: sans10, + titleBorder: border, + bodyBorder: border, + leftPadding: 5, + rightPadding: 5, + topPadding: 5, + bottomPadding: 5, + background: FlxColor.RED, + borderSize: 1, + borderColor: FlxColor.WHITE + }); b = addBtn("goback", new FlxUIButton(b.x, b.y + b.height + 10, "Go Back", function() { - FlxG.switchState(new State_Demo()); + FlxG.switchState(State_Demo.new); }), "Go Back", "This button takes you back to the first screen"); }