diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 850b5494..c1dcd0ff 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,7 +10,7 @@ jobs: build: strategy: matrix: - haxe-version: ["4.2.5", "4.3.3", latest] + haxe-version: ["4.2.5", "4.3.3"] target: [html5, hl, neko, flash, cpp] fail-fast: false runs-on: ubuntu-latest @@ -29,7 +29,7 @@ jobs: haxelib install haxelib 4.0.3 haxelib dev flixel-addons . - - uses: HaxeFlixel/setup-flixel@master + - uses: HaxeFlixel/setup-flixel@v1 with: haxe-version: current flixel-versions: dev diff --git a/.vscode/settings.json b/.vscode/settings.json index f1033154..b67c6dea 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,6 @@ { "[haxe]": { - "editor.formatOnSave": true + "editor.formatOnSave": true, + "editor.formatOnSaveMode": "modifications" } } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index fe72263b..7937aac6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,37 @@ -3.2.1 (September 26, 2023) +3.2.3 (May 15, 2024) +------------------------------ + +#### Changes and improvements: +- `FlxClickArea`: Compatibility with Flixel 5.7.0 ([425](https://github.com/HaxeFlixel/flixel-addons/pull/425)) + +#### Bugfixes: +- `FlxBackdrop`: fix matrix leaks ([426](https://github.com/HaxeFlixel/flixel-addons/pull/426)) +- `FlxRuntimeShader`: Fix errors with flixel-docs CI ([429](https://github.com/HaxeFlixel/flixel-addons/pull/429)) + +3.2.2 (March 10, 2024) ------------------------------ +#### Dependencies: +- Minimum versions allowed: + - Flixel: 5.3.0 + - OpenFl: 9.2.2 + - Lime: 8.0.2 + - Haxe: 4.2.5 +#### Changes and improvements: +- `FlxFSM`: Fix `FlxPool` deprecation warnings from Flixel 5.4.0 ([#409](https://github.com/HaxeFlixel/flixel-addons/pull/409)) +- `TransitionData`: add `cameraMode` field to help ensure the transition shows on top ([#410](https://github.com/HaxeFlixel/flixel-addons/pull/410)) +- `FlxRuntimeShader`: Throw incompatibility error on nme or flash ([#414](https://github.com/HaxeFlixel/flixel-addons/pull/414)) +- `FlxNestedSprite`: Prevent drawing default png ([#412](https://github.com/HaxeFlixel/flixel-addons/pull/412)) + +#### Bugfixes: +- `TransitionFade`: Fix bug with persistent images ([#415](https://github.com/HaxeFlixel/flixel-addons/pull/415)) + +3.2.1 (September 26, 2023) +------------------------------ #### Changes and improvements: - `FlxMouseSpring`: Now works with `FlxSprite` rather than just `FlxExtendedSprite` ([#405](https://github.com/HaxeFlixel/flixel-addons/pull/405)) - `FlxExtendedSprite`: Deprecated for `FlxExtendedMouseSprite`, no longer uses `FlxMouseControl` ([#405](https://github.com/HaxeFlixel/flixel-addons/pull/405)) - #### Bugfixes: - `FlxBackdrop`: Change spacing constructor args to floats ([#408](https://github.com/HaxeFlixel/flixel-addons/pull/408)) diff --git a/flixel/addons/display/FlxBackdrop.hx b/flixel/addons/display/FlxBackdrop.hx index 4927e3bd..fa12b5a9 100644 --- a/flixel/addons/display/FlxBackdrop.hx +++ b/flixel/addons/display/FlxBackdrop.hx @@ -51,6 +51,7 @@ class FlxBackdrop extends FlxSprite var _blitOffset:FlxPoint = FlxPoint.get(); var _blitGraphic:FlxGraphic = null; + var _tileMatrix:FlxMatrix = new FlxMatrix(); var _prevDrawParams:BackdropDrawParams = { graphicKey:null, @@ -82,9 +83,10 @@ class FlxBackdrop extends FlxSprite override function destroy():Void { - spacing = FlxDestroyUtil.destroy(spacing); - _blitOffset = FlxDestroyUtil.destroy(_blitOffset); + spacing = FlxDestroyUtil.put(spacing); + _blitOffset = FlxDestroyUtil.put(_blitOffset); _blitGraphic = FlxDestroyUtil.destroy(_blitGraphic); + _tileMatrix = null; super.destroy(); } @@ -113,6 +115,9 @@ class FlxBackdrop extends FlxSprite drawToLargestCamera(); } + #if (flixel >= "5.7.0") + final cameras = getCamerasLegacy(); + #end for (camera in cameras) { if (!camera.visible || !camera.exists || !isOnScreen(camera)) @@ -146,10 +151,8 @@ class FlxBackdrop extends FlxSprite camera = FlxG.camera; var bounds = getScreenBounds(_rect, camera); - var view = camera.getViewRect(); - if (repeatAxes.x) bounds.x = view.x; - if (repeatAxes.y) bounds.y = view.y; - view.put(); + if (repeatAxes.x) bounds.x = camera.viewMarginLeft; + if (repeatAxes.y) bounds.y = camera.viewMarginTop; return camera.containsRect(bounds); } @@ -158,20 +161,20 @@ class FlxBackdrop extends FlxSprite { var largest:FlxCamera = null; var largestArea = 0.0; - var view = FlxRect.get(); + #if (flixel >= "5.7.0") + final cameras = getCamerasLegacy(); // else use this.cameras + #end for (camera in cameras) { if (!camera.visible || !camera.exists || !isOnScreen(camera)) continue; - camera.getViewRect(view); - if (view.width * view.height > largestArea) + if (camera.viewWidth * camera.viewHeight > largestArea) { largest = camera; - largestArea = view.width * view.height; + largestArea = camera.viewWidth * camera.viewHeight; } } - view.put(); if (largest != null) regenGraphic(largest); @@ -199,7 +202,7 @@ class FlxBackdrop extends FlxSprite final frame = drawBlit ? _blitGraphic.imageFrame.frame : _frame; // The distance between repeated sprites, in screen space - var tileSize = FlxPoint.get(frame.frame.width, frame.frame.height); + final tileSize = FlxPoint.get(frame.frame.width, frame.frame.height); if (drawDirect) tileSize.addPoint(spacing); @@ -208,24 +211,25 @@ class FlxBackdrop extends FlxSprite var tilesY = 1; if (repeatAxes != NONE) { - var view = camera.getViewRect(); + final viewMargins = camera.getViewMarginRect(); if (repeatAxes.x) { - final left = modMin(_point.x + frameWidth, tileSize.x, view.left) - frameWidth; - final right = modMax(_point.x, tileSize.x, view.right) + tileSize.x; + final left = modMin(_point.x + frameWidth, tileSize.x, viewMargins.left) - frameWidth; + final right = modMax(_point.x, tileSize.x, viewMargins.right) + tileSize.x; tilesX = Math.round((right - left) / tileSize.x); final origTileSizeX = frameWidth + spacing.x; - _point.x = modMin(_point.x + frameWidth, origTileSizeX, view.left) - frameWidth; + _point.x = modMin(_point.x + frameWidth, origTileSizeX, viewMargins.left) - frameWidth; } if (repeatAxes.y) { - final top = modMin(_point.y + frameHeight, tileSize.y, view.top) - frameHeight; - final bottom = modMax(_point.y, tileSize.y, view.bottom) + tileSize.y; + final top = modMin(_point.y + frameHeight, tileSize.y, viewMargins.top) - frameHeight; + final bottom = modMax(_point.y, tileSize.y, viewMargins.bottom) + tileSize.y; tilesY = Math.round((bottom - top) / tileSize.y); final origTileSizeY = frameHeight + spacing.y; - _point.y = modMin(_point.y + frameHeight, origTileSizeY, view.top) - frameHeight; + _point.y = modMin(_point.y + frameHeight, origTileSizeY, viewMargins.top) - frameHeight; } + viewMargins.put(); } if (drawBlit) @@ -254,6 +258,7 @@ class FlxBackdrop extends FlxSprite } } + tileSize.put(); camera.buffer.unlock(); } @@ -273,7 +278,7 @@ class FlxBackdrop extends FlxSprite _matrix.translate(-origin.x, -origin.y); // The distance between repeated sprites, in screen space - var tileSize = FlxPoint.get(frame.frame.width, frame.frame.height); + final tileSize = FlxPoint.get(frame.frame.width, frame.frame.height); if (drawDirect) { @@ -311,13 +316,13 @@ class FlxBackdrop extends FlxSprite var tilesY = 1; if (repeatAxes != NONE) { - final view = camera.getViewRect(); + final viewMargins = camera.getViewMarginRect(); final bounds = getScreenBounds(camera); if (repeatAxes.x) { final origTileSizeX = (frameWidth + spacing.x) * scale.x; - final left = modMin(bounds.right, origTileSizeX, view.left) - bounds.width; - final right = modMax(bounds.left, origTileSizeX, view.right) + origTileSizeX; + final left = modMin(bounds.right, origTileSizeX, viewMargins.left) - bounds.width; + final right = modMax(bounds.left, origTileSizeX, viewMargins.right) + origTileSizeX; tilesX = Math.round((right - left) / tileSize.x); _point.x = left + _point.x - bounds.x; } @@ -325,45 +330,45 @@ class FlxBackdrop extends FlxSprite if (repeatAxes.y) { final origTileSizeY = (frameHeight + spacing.y) * scale.y; - final top = modMin(bounds.bottom, origTileSizeY, view.top) - bounds.height; - final bottom = modMax(bounds.top, origTileSizeY, view.bottom) + origTileSizeY; + final top = modMin(bounds.bottom, origTileSizeY, viewMargins.top) - bounds.height; + final bottom = modMax(bounds.top, origTileSizeY, viewMargins.bottom) + origTileSizeY; tilesY = Math.round((bottom - top) / tileSize.y); _point.y = top + _point.y - bounds.y; } - view.put(); + viewMargins.put(); bounds.put(); } _point.addPoint(origin); if (drawBlit) _point.addPoint(_blitOffset); - final mat = new FlxMatrix(); for (tileX in 0...tilesX) { for (tileY in 0...tilesY) { - mat.copyFrom(_matrix); + _tileMatrix.copyFrom(_matrix); - mat.translate(_point.x + (tileSize.x * tileX), _point.y + (tileSize.y * tileY)); + _tileMatrix.translate(_point.x + (tileSize.x * tileX), _point.y + (tileSize.y * tileY)); if (isPixelPerfectRender(camera)) { - mat.tx = Math.floor(mat.tx); - mat.ty = Math.floor(mat.ty); + _tileMatrix.tx = Math.floor(_tileMatrix.tx); + _tileMatrix.ty = Math.floor(_tileMatrix.ty); } if (FlxG.renderBlit) { final pixels = drawBlit ? _blitGraphic.bitmap: framePixels; - camera.drawPixels(frame, pixels, mat, colorTransform, blend, antialiasing, shader); + camera.drawPixels(frame, pixels, _tileMatrix, colorTransform, blend, antialiasing, shader); } else { - drawItem.addQuad(frame, mat, colorTransform); + drawItem.addQuad(frame, _tileMatrix, colorTransform); } } } + tileSize.put(); if (FlxG.renderBlit) camera.buffer.unlock(); } @@ -407,7 +412,7 @@ class FlxBackdrop extends FlxSprite (frameHeight + spacing.y) * scale.y ); - var view = camera.getViewRect(); + final viewMargins = camera.getViewMarginRect(); var tilesX = 1; var tilesY = 1; if (repeatAxes != NONE) @@ -416,22 +421,22 @@ class FlxBackdrop extends FlxSprite switch (blitMode) { case AUTO | SPLIT (1): - if (repeatAxes.x) tilesX = Math.ceil(view.width / tileSize.x) + 1; - if (repeatAxes.y) tilesY = Math.ceil(view.height / tileSize.y) + 1; + if (repeatAxes.x) tilesX = Math.ceil(viewMargins.width / tileSize.x) + 1; + if (repeatAxes.y) tilesY = Math.ceil(viewMargins.height / tileSize.y) + 1; case MAX_TILES(1) | MAX_TILES_XY(1, 1): case MAX_TILES(max): - if (repeatAxes.x) tilesX = min(max, Math.ceil(view.width / tileSize.x) + 1); - if (repeatAxes.y) tilesY = min(max, Math.ceil(view.height / tileSize.y) + 1); + if (repeatAxes.x) tilesX = min(max, Math.ceil(viewMargins.width / tileSize.x) + 1); + if (repeatAxes.y) tilesY = min(max, Math.ceil(viewMargins.height / tileSize.y) + 1); case MAX_TILES_XY(maxX, maxY): - if (repeatAxes.x) tilesX = min(maxX, Math.ceil(view.width / tileSize.x) + 1); - if (repeatAxes.y) tilesY = min(maxY, Math.ceil(view.height / tileSize.y) + 1); + if (repeatAxes.x) tilesX = min(maxX, Math.ceil(viewMargins.width / tileSize.x) + 1); + if (repeatAxes.y) tilesY = min(maxY, Math.ceil(viewMargins.height / tileSize.y) + 1); case SPLIT(portions): - if (repeatAxes.x) tilesX = repeatAxes.x ? Math.ceil(view.width / tileSize.x / portions + 1) : 1; - if (repeatAxes.y) tilesY = repeatAxes.y ? Math.ceil(view.height / tileSize.y / portions + 1) : 1; + if (repeatAxes.x) tilesX = repeatAxes.x ? Math.ceil(viewMargins.width / tileSize.x / portions + 1) : 1; + if (repeatAxes.y) tilesY = repeatAxes.y ? Math.ceil(viewMargins.height / tileSize.y / portions + 1) : 1; } } - view.put(); + viewMargins.put(); if (matchPrevDrawParams(tilesX, tilesY)) { diff --git a/flixel/addons/display/FlxNestedSprite.hx b/flixel/addons/display/FlxNestedSprite.hx index 3aed5722..1d71abb0 100644 --- a/flixel/addons/display/FlxNestedSprite.hx +++ b/flixel/addons/display/FlxNestedSprite.hx @@ -259,7 +259,8 @@ class FlxNestedSprite extends FlxSprite override public function draw():Void { - super.draw(); + if(_frame != null) + super.draw(); for (child in children) { diff --git a/flixel/addons/display/FlxRuntimeShader.hx b/flixel/addons/display/FlxRuntimeShader.hx index 6d56fa15..971eac00 100644 --- a/flixel/addons/display/FlxRuntimeShader.hx +++ b/flixel/addons/display/FlxRuntimeShader.hx @@ -1,6 +1,15 @@ package flixel.addons.display; -import flixel.system.FlxAssets.FlxShader; +#if (nme || flash) + #if (FLX_NO_COVERAGE_TEST && !(doc_gen)) + #error "FlxRuntimeShader isn't available with nme or flash." + #end +#else +import flixel.graphics.tile.FlxGraphicsShader; +#end +#if lime +import lime.utils.Float32Array; +#end import openfl.display.BitmapData; import openfl.display.ShaderInput; import openfl.display.ShaderParameter; diff --git a/flixel/addons/display/FlxSliceSprite.hx b/flixel/addons/display/FlxSliceSprite.hx index 24dfbe1e..a948ec39 100644 --- a/flixel/addons/display/FlxSliceSprite.hx +++ b/flixel/addons/display/FlxSliceSprite.hx @@ -511,7 +511,7 @@ class FlxSliceSprite extends FlxStrip renderSprite.y = y; renderSprite.scale.copyFrom(scale); renderSprite.scrollFactor.set(scrollFactor.x, scrollFactor.y); - renderSprite.cameras = cameras; + renderSprite._cameras = _cameras; renderSprite.draw(); } else diff --git a/flixel/addons/display/FlxTiledSprite.hx b/flixel/addons/display/FlxTiledSprite.hx index 74961a5f..da8004fe 100644 --- a/flixel/addons/display/FlxTiledSprite.hx +++ b/flixel/addons/display/FlxTiledSprite.hx @@ -153,7 +153,7 @@ class FlxTiledSprite extends FlxStrip renderSprite.x = x; renderSprite.y = y; renderSprite.scrollFactor.set(scrollFactor.x, scrollFactor.y); - renderSprite.cameras = cameras; + renderSprite._cameras = _cameras; renderSprite.draw(); } else diff --git a/flixel/addons/editors/spine/FlxSpine.hx b/flixel/addons/editors/spine/FlxSpine.hx index bd95dcd2..7851c57c 100644 --- a/flixel/addons/editors/spine/FlxSpine.hx +++ b/flixel/addons/editors/spine/FlxSpine.hx @@ -268,7 +268,7 @@ class FlxSpine extends FlxSprite { wrapper.x = 0; wrapper.y = 0; - wrapper.cameras = cameras; + wrapper._cameras = _cameras; #if (flash || openfl >= "4.0.0") wrapper.vertices.length = verticesLength; diff --git a/flixel/addons/effects/FlxTrail.hx b/flixel/addons/effects/FlxTrail.hx index 186637fa..6f5112b1 100644 --- a/flixel/addons/effects/FlxTrail.hx +++ b/flixel/addons/effects/FlxTrail.hx @@ -4,7 +4,7 @@ import flixel.animation.FlxAnimation; import flixel.FlxG; import flixel.FlxSprite; import flixel.group.FlxGroup; -import flixel.group.FlxSpriteGroup; +import flixel.group.*; import flixel.system.FlxAssets; import flixel.util.FlxArrayUtil; import flixel.util.FlxDestroyUtil; @@ -17,7 +17,7 @@ import flixel.math.FlxPoint; * Feel free to use this class and adjust it to your needs. * @author Gama11 */ -class FlxTrail extends FlxSpriteGroup +class FlxTrail extends #if (flixel < "5.7.0") FlxSpriteGroup #else FlxSpriteContainer #end { /** * Stores the FlxSprite the trail is attached to. diff --git a/flixel/addons/effects/chainable/FlxEffectSprite.hx b/flixel/addons/effects/chainable/FlxEffectSprite.hx index 37d64ba3..cfc87a99 100644 --- a/flixel/addons/effects/chainable/FlxEffectSprite.hx +++ b/flixel/addons/effects/chainable/FlxEffectSprite.hx @@ -1,5 +1,11 @@ package flixel.addons.effects.chainable; +// TODO: remove this check when min flixel version is 5.6.0, +// So that FlxAddonDefines will handle this +#if (flixel < "5.3.0") +#error "Flixel-Addons is not compatible with flixel versions older than 5.3.0"; +#end + import flixel.FlxCamera; import flixel.FlxSprite; import flixel.graphics.FlxGraphic; diff --git a/flixel/addons/nape/FlxNapeSpace.hx b/flixel/addons/nape/FlxNapeSpace.hx index 9e6330bf..054aea43 100644 --- a/flixel/addons/nape/FlxNapeSpace.hx +++ b/flixel/addons/nape/FlxNapeSpace.hx @@ -64,7 +64,11 @@ class FlxNapeSpace extends FlxBasic */ public static function init():Void { + #if (flixel < "5.6.0") FlxG.plugins.add(new FlxNapeSpace()); + #else + FlxG.plugins.addPlugin(new FlxNapeSpace()); + #end if (space == null) space = new Space(new Vec2()); diff --git a/flixel/addons/system/macros/FlxAddonDefines.hx b/flixel/addons/system/macros/FlxAddonDefines.hx new file mode 100644 index 00000000..8a7f9168 --- /dev/null +++ b/flixel/addons/system/macros/FlxAddonDefines.hx @@ -0,0 +1,64 @@ +package flixel.addons.system.macros; + +#if macro +import haxe.macro.Compiler; +import haxe.macro.Context; +import haxe.macro.Expr.Position; + +// private enum UserAddonDefines {} +// private enum HelperAddonDefines {} + +/** + * The purpose of these "defines" classes is mainly to properly communicate version compatibility + * among flixel libs, we shouldn't be overly concerned with backwards compatibility, but we do want + * to know when a change breaks compatibility between Flixel-Addons and Flixel. + * + * @since 3.2.2 + */ +@:allow(flixel.system.macros.FlxDefines) +@:access(flixel.system.macros.FlxDefines) +class FlxAddonDefines +{ + /** + * Called from `flixel.system.macros.FlxDefines` on versions 5.6.0 or later + */ + public static function run() + { + #if !display + checkCompatibility(); + #end + } + + static function checkCompatibility() + { + /** this function is only ran in flixel versions 5.6.0 or later, meaning this error will + * never happen. So we've added flixel version checks in the following modules: + * - `FlxEffectSprite` + * - `FlxTypeText` + * - `FlxTransitionableState` + * - `FlxWeapon` + * + * When the minimum version of flixel is changed to 5.6.0 or greater, remove the above + * checks and this comment. + */ + #if (flixel < "5.3.0") + FlxDefines.abortVersion("Flixel", "5.3.0 or newer", "flixel", (macro null).pos); + #end + } + + static function isValidUserDefine(define:Any) + { + return false; + } + + static function abortVersion(dependency:String, supported:String, found:String, pos:Position) + { + abort('Flixel-Addons: Unsupported $dependency version! Supported versions are $supported (found ${Context.definedValue(found)}).', pos); + } + + static function abort(message:String, pos:Position) + { + Context.fatalError(message, pos); + } +} +#end \ No newline at end of file diff --git a/flixel/addons/text/FlxTypeText.hx b/flixel/addons/text/FlxTypeText.hx index 7fd492cd..2774ef5f 100644 --- a/flixel/addons/text/FlxTypeText.hx +++ b/flixel/addons/text/FlxTypeText.hx @@ -1,5 +1,11 @@ package flixel.addons.text; +// TODO: remove this check when min flixel version is 5.6.0, +// So that FlxAddonDefines will handle this +#if (flixel < "5.3.0") +#error "Flixel-Addons is not compatible with flixel versions older than 5.3.0"; +#end + import flixel.FlxG; import flixel.input.keyboard.FlxKey; import flixel.math.FlxMath; diff --git a/flixel/addons/transition/FlxTransitionableState.hx b/flixel/addons/transition/FlxTransitionableState.hx index f298cc68..3dea1507 100644 --- a/flixel/addons/transition/FlxTransitionableState.hx +++ b/flixel/addons/transition/FlxTransitionableState.hx @@ -1,5 +1,11 @@ package flixel.addons.transition; +// TODO: remove this check when min flixel version is 5.6.0, +// So that FlxAddonDefines will handle this +#if (flixel < "5.3.0") +#error "Flixel-Addons is not compatible with flixel versions older than 5.3.0"; +#end + import flixel.FlxState; /** diff --git a/flixel/addons/transition/TransitionEffect.hx b/flixel/addons/transition/TransitionEffect.hx index fda10cc2..281d7af7 100644 --- a/flixel/addons/transition/TransitionEffect.hx +++ b/flixel/addons/transition/TransitionEffect.hx @@ -3,14 +3,14 @@ package flixel.addons.transition; import flixel.addons.transition.FlxTransitionSprite.TransitionStatus; import flixel.addons.transition.TransitionData; import flixel.group.FlxGroup; -import flixel.group.FlxSpriteGroup; +import flixel.group.*; import flixel.util.FlxTimer; /** * @author larsiusprime */ @:allow(flixel.addons.transition.Transition) -class TransitionEffect extends FlxSpriteGroup +class TransitionEffect extends #if (flixel < "5.7.0") FlxSpriteGroup #else FlxSpriteContainer #end { public var finishCallback:Void->Void; public var finished(default, null):Bool = false; diff --git a/flixel/addons/ui/FlxButtonPlus.hx b/flixel/addons/ui/FlxButtonPlus.hx index 2b13ca15..a2d2b93c 100644 --- a/flixel/addons/ui/FlxButtonPlus.hx +++ b/flixel/addons/ui/FlxButtonPlus.hx @@ -9,7 +9,7 @@ import flixel.FlxCamera; import flixel.FlxG; import flixel.FlxSprite; import flixel.graphics.FlxGraphic; -import flixel.group.FlxSpriteGroup; +import flixel.group.*; import flixel.text.FlxText; import flixel.util.FlxColor; import flixel.util.FlxDestroyUtil; @@ -24,7 +24,7 @@ import flixel.math.FlxMath; * @link http://www.photonstorm.com * @author Richard Davey / Photon Storm */ -class FlxButtonPlus extends FlxSpriteGroup +class FlxButtonPlus extends #if (flixel < "5.7.0") FlxSpriteGroup #else FlxSpriteContainer #end { public static inline var NORMAL:Int = 0; public static inline var HIGHLIGHT:Int = 1; diff --git a/flixel/addons/ui/FlxClickArea.hx b/flixel/addons/ui/FlxClickArea.hx index 8658b4a3..bc18acb1 100644 --- a/flixel/addons/ui/FlxClickArea.hx +++ b/flixel/addons/ui/FlxClickArea.hx @@ -9,6 +9,12 @@ import flixel.FlxObject; import flixel.ui.FlxButton; import flixel.math.FlxPoint; +#if (flixel < version("5.7.0")) +import flixel.ui.FlxButton.NORMAL; +import flixel.ui.FlxButton.HIGHLIGHT; +import flixel.ui.FlxButton.PRESSED; +#end + /** * Trimmed-down button, invisible click area, only responds to onUP */ @@ -56,7 +62,7 @@ class FlxClickArea extends FlxObject onUp = OnUp; - status = FlxButton.NORMAL; + status = NORMAL; _pressed = false; _initialized = false; @@ -127,6 +133,9 @@ class FlxClickArea extends FlxObject if (continueUpdate) { var offAll:Bool = true; + #if (flixel >= "5.7.0") + final cameras = getCameras(); // else use this.cameras + #end for (camera in cameras) { #if FLX_MOUSE @@ -148,7 +157,7 @@ class FlxClickArea extends FlxObject } if (offAll) { - status = FlxButton.NORMAL; + status = NORMAL; } } } @@ -166,11 +175,11 @@ class FlxClickArea extends FlxObject if (JustPressed) { - status = FlxButton.PRESSED; + status = PRESSED; } - if (status == FlxButton.NORMAL) + if (status == NORMAL) { - status = FlxButton.HIGHLIGHT; + status = HIGHLIGHT; } } @@ -182,7 +191,7 @@ class FlxClickArea extends FlxObject */ function onMouseUp(event:Event):Void { - if (!exists || !visible || !active || (status != FlxButton.PRESSED)) + if (!exists || !visible || !active || (status != PRESSED)) { return; } @@ -190,6 +199,6 @@ class FlxClickArea extends FlxObject { onUp(); } - status = FlxButton.NORMAL; + status = NORMAL; } } diff --git a/flixel/addons/ui/FlxSlider.hx b/flixel/addons/ui/FlxSlider.hx index 360f1f62..9522d8e4 100644 --- a/flixel/addons/ui/FlxSlider.hx +++ b/flixel/addons/ui/FlxSlider.hx @@ -3,20 +3,20 @@ package flixel.addons.ui; #if FLX_MOUSE import flixel.FlxG; import flixel.FlxSprite; -import flixel.group.FlxSpriteGroup; -import flixel.text.FlxText; -import flixel.util.FlxDestroyUtil; +import flixel.group.*; import flixel.math.FlxMath; import flixel.math.FlxPoint; import flixel.math.FlxRect; -import flixel.util.FlxSpriteUtil; +import flixel.text.FlxText; import flixel.util.FlxColor; +import flixel.util.FlxDestroyUtil; +import flixel.util.FlxSpriteUtil; /** * A slider GUI element for float and integer manipulation. * @author Gama11 */ -class FlxSlider extends FlxSpriteGroup +class FlxSlider extends #if (flixel < "5.7.0") FlxSpriteGroup #else FlxSpriteContainer #end { /** * The horizontal line in the background. @@ -271,7 +271,11 @@ class FlxSlider extends FlxSpriteGroup override public function update(elapsed:Float):Void { // Clicking and sound logic - if (FlxMath.mouseInFlxRect(false, _bounds)) + #if (flixel >= "5.7.0") + final camera = getCameras()[0];// else use this.camera + #end + final mouse = FlxG.mouse.getScreenPosition(camera); + if (FlxMath.pointInFlxRect(mouse.x, mouse.y, _bounds)) { if (hoverAlpha != 1) { diff --git a/flixel/addons/util/FlxFSM.hx b/flixel/addons/util/FlxFSM.hx index c34d9a0e..6167de6f 100644 --- a/flixel/addons/util/FlxFSM.hx +++ b/flixel/addons/util/FlxFSM.hx @@ -128,7 +128,7 @@ class FlxFSM implements IFlxDestroyable if (newName != null && !pools.exists(newName)) { - #if (flixel < version("5.4.0")) + #if (flixel < version("5.5.0")) final newStateConstructor = newStateClass; #else final newStateConstructor = ()->Type.createInstance(newStateClass, []); diff --git a/flixel/addons/weapon/FlxWeapon.hx b/flixel/addons/weapon/FlxWeapon.hx index 289786fe..0c43dd37 100644 --- a/flixel/addons/weapon/FlxWeapon.hx +++ b/flixel/addons/weapon/FlxWeapon.hx @@ -1,5 +1,11 @@ package flixel.addons.weapon; +// TODO: remove this check when min flixel version is 5.6.0, +// So that FlxAddonDefines will handle this +#if (flixel < "5.3.0") +#error "Flixel-Addons is not compatible with flixel versions older than 5.3.0"; +#end + import flixel.FlxBasic; import flixel.FlxG; import flixel.FlxObject; diff --git a/haxelib.json b/haxelib.json index 40378a6b..9cda487a 100644 --- a/haxelib.json +++ b/haxelib.json @@ -4,7 +4,7 @@ "license": "MIT", "tags": ["game", "openfl", "flash", "neko", "cpp", "android", "ios", "cross"], "description": "flixel-addons is a set of useful, additional classes for HaxeFlixel.", - "version": "3.2.1", - "releasenote": "Deprecate FlxExtendedSprite", + "version": "3.2.3", + "releasenote": "Compatibility with flixel 5.7.0", "contributors": ["haxeflixel", "Gama11", "GeoKureli"] }