Skip to content

Commit

Permalink
Flixel 6 compatibility (#331)
Browse files Browse the repository at this point in the history
* remove warnings (for flixel 6)

* fix demos for flixel 6
  • Loading branch information
Geokureli authored Feb 28, 2024
1 parent 275d4f6 commit 493fe25
Show file tree
Hide file tree
Showing 85 changed files with 343 additions and 1,202 deletions.
92 changes: 89 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
2 changes: 1 addition & 1 deletion Arcade/Breakout/source/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
3 changes: 1 addition & 2 deletions Arcade/FlxLightPuzzle/source/Color.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions Arcade/FlxPongApi/source/MenuState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Arcade/FlxPongApi/source/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class PlayState extends FlxState
}
if (FlxG.keys.justPressed.ESCAPE)
{
FlxG.switchState(new MenuState());
FlxG.switchState(MenuState.new);
}
#end

Expand Down Expand Up @@ -150,6 +150,6 @@ class PlayState extends FlxState

function endGame(f:FlxTimer):Void
{
FlxG.switchState(new MenuState());
FlxG.switchState(MenuState.new);
}
}
2 changes: 1 addition & 1 deletion Arcade/FlxTeroids/source/MenuState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class MenuState extends FlxState
{
if (FlxG.keys.justReleased.SPACE)
{
FlxG.switchState(new PlayState());
FlxG.switchState(PlayState.new);
}
}
}
2 changes: 1 addition & 1 deletion Arcade/FlxTeroids/source/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion Arcade/MinimalistTD/source/MenuState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Arcade/MinimalistTD/source/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
1 change: 0 additions & 1 deletion Effects/BlendModeShaders/source/Main.hx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package;

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

class Main extends Sprite
Expand Down
19 changes: 6 additions & 13 deletions Effects/BlendModeShaders/source/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package openfl8.blends;
package blends;

import flixel.system.FlxAssets.FlxShader;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package openfl8.blends;
package blends;

import flixel.system.FlxAssets.FlxShader;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package openfl8.blends;
package blends;

import flixel.system.FlxAssets.FlxShader;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package openfl8.blends;
package blends;

import flixel.system.FlxAssets.FlxShader;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package openfl8.blends;
package blends;

import flixel.system.FlxAssets.FlxShader;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package openfl8.blends;
package blends;

import flixel.system.FlxAssets.FlxShader;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package openfl8.effects;
package effects;

import flixel.util.FlxColor;
import openfl.display.ShaderParameter;
Expand All @@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package openfl8.effects;
package effects;

import flixel.util.FlxColor;
import flixel.system.FlxAssets.FlxShader;
Expand All @@ -9,56 +9,56 @@ 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.value = [true];
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;
}
}
Expand Down
Loading

0 comments on commit 493fe25

Please sign in to comment.