diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f5e3369fe..69178c8b1b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,40 @@ +6.0.0 (TBD) + +#### Changes and improvements: +- `FlxSpritegroup`: Setting `origin` now causes members to pivot around the same point ([#2981](https://github.com/HaxeFlixel/flixel/pull/2981)) +- `FlxCamera`: Smoother camera lerping, particularly with non-fixed timesteps ([#2922](https://github.com/HaxeFlixel/flixel/pull/2922)) +- `FlxState`: Removed deprecated `switchTo` ([#2733](https://github.com/HaxeFlixel/flixel/pull/2733)) +- `FlxG`: Added deprecation warning on `switchState` with instances ([#2733](https://github.com/HaxeFlixel/flixel/pull/2733)) +- `FlxCamera`: Removed `defaultCameras` +- `FlxCamera`: Fixed `zoom` and `defaultZoom` so it works with values other than 1.0 ([#2907](https://github.com/HaxeFlixel/flixel/pull/2907)) +- `FlxBasic`: Added `getDefaultCamera`, used in nearly all methods taking an optional `camera` arg ([#3072](https://github.com/HaxeFlixel/flixel/pull/3072)) + +#### Removals +We removed many features and utilities that were previously deprecated +- `flixel.util.FlxPath`: New package, `flixel.path.FlxPath` +- `FlxSwipe::angle`: Use `FlxSwipe.degrees`, instead +- `FlxAngle.angleFromFacing`: Use `degrees` in `FlxDirectionFlags`, instead +- `FlxAngle.getCartesianCoords`: Use `FlxVector.setPolarDegrees`, instead +- `FlxObject` (legacy directions): Use `FlxDirectionFlags`, instead +- `FlxObject::collisonXDrag`: Typo in name corrected to `FlxObject::collisionXDrag` +- `FlxCamera::viewOffsetX/Y/Width/Height`: Use `viewMarginX/Y/Top/Bottom/Left/Right`, instead +- `FlxTween` (legacy FlxTweenTypes): Use `FlxTweenType`, instead +- `FlxRandom.shuffleArray`: Use `shuffle`, instead +- `FlxPoint.rotate`: Use `pivotDegrees`, instead +- `FlxPoint.angleBetween`: Use `degreesTo`, instead +- `FlxVector`: Use `FlxPoint`, instead +- `FlxTilemap.useScaleHack`: No longer needed, due to `defaultFramePadding` +- `FlxG.signals.stateSwitched` and `gameStarted`: Use `preStateSwitch` and `postGameStart`, respectively +- `FlxPath` (Legacy types): Use `FlxPathType`, instead +- `flixel.system.FlxSound` and `FlxSoundGroup`: new package, `flixel.sound` +- `FlxState::switchTo`: Use `startOutro`, instead +- `FlxAnimation::delay`: Use `frameDuration`, instead +- `FlxCollision.pixelPerfectPointCheck`: Use `FlxSprite::pixelsOverlapPoint`, instead +- `FlxAnimationController.frames`: Use `numFrames`, instead +- `FlxAssets.FlxAngelCodeSource`: Use `FlxAssets.FlxAngelCodeAsset`, instead +- `FlxAssets.FlxTexturePackerSource`: Use `FlxTexturePackerJsonAsset`, instead +- `FlxUnicodeUtil`: Use `UnicodeString`, instead + 5.9.0 (December 12, 2024) ------------------------------ #### New features: @@ -225,7 +262,7 @@ - **README.md**: Add Turkish translations - `AssetPaths`: Add `allFiles` field, and an arg in `FlxAssets.buildFileReferences` to change the identifier ([#2807](https://github.com/HaxeFlixel/flixel/pull/2807)) - Debug tools: Add ways to remove custom debug tools ([#2792](https://github.com/HaxeFlixel/flixel/pull/2792)) - - `FlxG.console`: Add `removeByAlias`, `removeEnum`, `removeClass`, `removeObject` and `removeFunction` + - `FlxG.console`: Add `removeByAlias`, `removeEnum`, `removeClass`, `removeObject` and `removeFunction` - `FlxG.game.debugger.interaction`: Add `removeTool` - `FlxText`: Add `fieldHeight` field ([#2789](https://github.com/HaxeFlixel/flixel/pull/2789)) - `FlxG`: Add compiler flag `FLX_NO_SAVE` to remove `FlxG.save` (also counter-flag `FLX_SAVE`) ([#2840](https://github.com/HaxeFlixel/flixel/pull/2840)) @@ -365,7 +402,7 @@ - `AssetPaths`: various fixes ([#2680](https://github.com/HaxeFlixel/flixel/pull/2680)) - apply `include`/`exclude` args to files, not directories - default file renamer will replace spaces with underscore - + #### New features: - `FlxKeys`: Added `SCROLL_LOCK`, `NUMLOCK`, `WINDOWS`, `MENU`, `BREAK` and `NUMPADSLASH` keys ([#2638](https://github.com/HaxeFlixel/flixel/pull/2638)) diff --git a/flixel/FlxBasic.hx b/flixel/FlxBasic.hx index 769368dae3..02d5c1d702 100644 --- a/flixel/FlxBasic.hx +++ b/flixel/FlxBasic.hx @@ -193,6 +193,20 @@ class FlxBasic implements IFlxDestroyable return Value; } + /** + * The main camera that will draw this. Use `this.cameras` to set specific cameras for this + * object, otherwise the container's camera is used, or the container's container and so on. + * If there is no container, say, if this is inside `FlxGroups` rather than a `FlxContainer` + * then `FlxG.camera` is returned. + * @since 5.7.0 + */ + public function getDefaultCamera():FlxCamera + { + final cameras = getCameras(); + // should never be null, unless people do something stupid, but just in case + return cameras == null || cameras.length == 0 ? FlxG.camera : cameras[0]; + } + /** * The cameras that will draw this. Use `this.cameras` to set specific cameras for this object, * otherwise the container's cameras are used, or the container's container and so on. If there @@ -200,7 +214,7 @@ class FlxBasic implements IFlxDestroyable * default draw cameras are returned. * @since 5.7.0 */ - public function getCameras() + public function getCameras():Array { return if (_cameras != null) _cameras; diff --git a/flixel/FlxCamera.hx b/flixel/FlxCamera.hx index 99a6a731b6..118b3a601f 100644 --- a/flixel/FlxCamera.hx +++ b/flixel/FlxCamera.hx @@ -48,18 +48,6 @@ class FlxCamera extends FlxBasic * Any `FlxCamera` with a zoom of 0 (the default value) will have this zoom value. */ public static var defaultZoom:Float = 1.0; - - /** - * Used behind-the-scenes during the draw phase so that members use the same default - * cameras as their parent. - * - * Prior to 4.9.0 it was useful to change this value, but that feature is deprecated. - * Instead use the `defaultDrawTarget` argument in `FlxG.cameras.add `. - * or`FlxG.cameras.setDefaultDrawTarget` . - * @see FlxG.cameras.setDefaultDrawTarget - */ - @:deprecated("`FlxCamera.defaultCameras` is deprecated, use `FlxG.cameras.setDefaultDrawTarget` instead") - public static var defaultCameras(get, set):Array; /** * Used behind-the-scenes during the draw phase so that members use the same default @@ -126,12 +114,12 @@ class FlxCamera extends FlxBasic public var targetOffset(default, null):FlxPoint = FlxPoint.get(); /** - * Used to smoothly track the camera as it follows: - * The percent of the distance to the follow `target` the camera moves per 1/60 sec. - * Values are bounded between `0.0` and `60 / FlxG.updateFramerate` for consistency across framerates. - * The maximum value means no camera easing. A value of `0` means the camera does not move. + * The ratio of the distance to the follow `target` the camera moves per 1/60 sec. + * Valid values range from `0.0` to `1.0`. `1.0` means the camera always snaps to its target + * position. `0.5` means the camera always travels halfway to the target position, `0.0` means + * the camera does not move. Generally, the lower the value, the more smooth. */ - public var followLerp(default, set):Float = 60 / FlxG.updateFramerate; + public var followLerp:Float = 1.0; /** * You can assign a "dead zone" to the camera in order to better control its movement. @@ -256,17 +244,6 @@ class FlxCamera extends FlxBasic */ public var viewMarginY(default, null):Float; - // deprecated vars - - @:deprecated("use viewMarginLeft or viewMarginX") - var viewOffsetX(get, set):Float; - @:deprecated("use viewMarginTop or viewMarginY") - var viewOffsetY(get, set):Float; - @:deprecated("use viewMarginLeft or viewMarginX") - var viewOffsetWidth(get, never):Float; - @:deprecated("use viewMarginTop or viewMarginY") - var viewOffsetHeight(get, never):Float; - // delegates /** @@ -494,9 +471,6 @@ class FlxCamera extends FlxBasic */ public var filters:Null> = null; - @:deprecated("_filters is deprecated, use filters instead") - var _filters(get, set):Null>; - /** * Camera's initial zoom value. Used for camera's scale handling. */ @@ -1024,23 +998,26 @@ class FlxCamera extends FlxBasic /** * Instantiates a new camera at the specified location, with the specified size and zoom level. * - * @param X X location of the camera's display in pixels. Uses native, 1:1 resolution, ignores zoom. - * @param Y Y location of the camera's display in pixels. Uses native, 1:1 resolution, ignores zoom. - * @param Width The width of the camera display in pixels. - * @param Height The height of the camera display in pixels. - * @param Zoom The initial zoom level of the camera. - * A zoom level of 2 will make all pixels display at 2x resolution. + * @param x X location of the camera's display in pixels. Uses native, 1:1 resolution, ignores zoom. + * @param y Y location of the camera's display in pixels. Uses native, 1:1 resolution, ignores zoom. + * @param width The width of the camera display in pixels. + * @param height The height of the camera display in pixels. + * @param zoom The initial zoom level of the camera. + * A zoom level of 2 will make all pixels display at 2x resolution. */ - public function new(X:Float = 0, Y:Float = 0, Width:Int = 0, Height:Int = 0, Zoom:Float = 0) + public function new(x = 0.0, y = 0.0, width = 0, height = 0, zoom = 0.0) { super(); - x = X; - y = Y; + this.x = x; + this.y = y; + if (zoom == 0) + zoom = defaultZoom; + // Use the game dimensions if width / height are <= 0 - width = (Width <= 0) ? FlxG.width : Width; - height = (Height <= 0) ? FlxG.height : Height; + this.width = width <= 0 ? Math.ceil(FlxG.width / zoom) : width; + this.height = height <= 0 ? Math.ceil(FlxG.height / zoom) : height; _flashRect = new Rectangle(0, 0, width, height); flashSprite.addChild(_scrollRect); @@ -1070,10 +1047,10 @@ class FlxCamera extends FlxBasic } set_color(FlxColor.WHITE); - - initialZoom = (Zoom == 0) ? defaultZoom : Zoom; - zoom = Zoom; // sets the scale of flash sprite, which in turn loads flashOffset values - + + // sets the scale of flash sprite, which in turn loads flashOffset values + this.zoom = initialZoom = zoom; + updateScrollRect(); updateFlashOffset(); updateFlashSpritePosition(); @@ -1150,6 +1127,7 @@ class FlxCamera extends FlxBasic if (target != null) { updateFollow(); + updateLerp(elapsed); } updateScroll(); @@ -1182,14 +1160,14 @@ class FlxCamera extends FlxBasic */ public function bindScrollPos(scrollPos:FlxPoint) { - var minX:Null = minScrollX == null ? null : minScrollX - (zoom - 1) * width / (2 * zoom); - var maxX:Null = maxScrollX == null ? null : maxScrollX + (zoom - 1) * width / (2 * zoom); - var minY:Null = minScrollY == null ? null : minScrollY - (zoom - 1) * height / (2 * zoom); - var maxY:Null = maxScrollY == null ? null : maxScrollY + (zoom - 1) * height / (2 * zoom); + final minX:Null = minScrollX == null ? null : minScrollX - viewMarginLeft; + final maxX:Null = maxScrollX == null ? null : maxScrollX - viewMarginRight; + final minY:Null = minScrollY == null ? null : minScrollY - viewMarginTop; + final maxY:Null = maxScrollY == null ? null : maxScrollY - viewMarginBottom; - // keep point with bounds - scrollPos.x = FlxMath.bound(scrollPos.x, minX, (maxX != null) ? maxX - width : null); - scrollPos.y = FlxMath.bound(scrollPos.y, minY, (maxY != null) ? maxY - height : null); + // keep point within bounds + scrollPos.x = FlxMath.bound(scrollPos.x, minX, maxX); + scrollPos.y = FlxMath.bound(scrollPos.y, minY, maxY); return scrollPos; } @@ -1197,7 +1175,7 @@ class FlxCamera extends FlxBasic * Updates camera's scroll. * Called every frame by camera's `update()` method (if camera's `target` isn't `null`). */ - public function updateFollow():Void + function updateFollow():Void { // Either follow the object closely, // or double check our deadzone and update accordingly. @@ -1274,15 +1252,21 @@ class FlxCamera extends FlxBasic _lastTargetPosition.y = target.y; } } - - if (followLerp >= 60 / FlxG.updateFramerate) + } + + function updateLerp(elapsed:Float) + { + if (followLerp >= 1.0) { scroll.copyFrom(_scrollTarget); // no easing } - else + else if (followLerp > 0.0) { - scroll.x += (_scrollTarget.x - scroll.x) * followLerp * (60 / FlxG.updateFramerate); - scroll.y += (_scrollTarget.y - scroll.y) * followLerp * (60 / FlxG.updateFramerate); + // Adjust lerp based on the current frame rate so lerp is less framerate dependant + final adjustedLerp = 1.0 - Math.pow(1.0 - followLerp, elapsed * 60); + + scroll.x += (_scrollTarget.x - scroll.x) * adjustedLerp; + scroll.y += (_scrollTarget.y - scroll.y) * adjustedLerp; } } @@ -1459,27 +1443,21 @@ class FlxCamera extends FlxBasic /** * Tells this camera object what `FlxObject` to track. * - * @param Target The object you want the camera to track. Set to `null` to not follow anything. - * @param Style Leverage one of the existing "deadzone" presets. Default is `LOCKON`. + * @param target The object you want the camera to track. Set to `null` to not follow anything. + * @param style Leverage one of the existing "deadzone" presets. Default is `LOCKON`. * If you use a custom deadzone, ignore this parameter and * manually specify the deadzone after calling `follow()`. - * @param Lerp How much lag the camera should have (can help smooth out the camera movement). + * @param lerp How much lag the camera should have (can help smooth out the camera movement). */ - public function follow(Target:FlxObject, ?Style:FlxCameraFollowStyle, ?Lerp:Float):Void + public function follow(target:FlxObject, style = LOCKON, lerp = 1.0):Void { - if (Style == null) - Style = LOCKON; - - if (Lerp == null) - Lerp = 60 / FlxG.updateFramerate; - - style = Style; - target = Target; - followLerp = Lerp; + this.style = style; + this.target = target; + followLerp = lerp; _lastTargetPosition = FlxDestroyUtil.put(_lastTargetPosition); deadzone = FlxDestroyUtil.put(deadzone); - switch (Style) + switch (style) { case LOCKON: var w:Float = 0; @@ -1641,15 +1619,6 @@ class FlxCamera extends FlxBasic _fxShakeDuration = 0.0; } - /** - * Sets the filter array to be applied to the camera. - */ - @:deprecated("setFilters() is deprecated, use the filters array instead") - public function setFilters(filters:Array):Void - { - this.filters = filters; - } - /** * Copy the bounds, focus object, and `deadzone` info from an existing camera. * @@ -1901,24 +1870,6 @@ class FlxCamera extends FlxBasic setScale(scaleX, scaleY); } - /** - * The size and position of this camera's margins, via `viewMarginLeft`, `viewMarginTop`, `viewWidth` - * and `viewHeight`. - * - * Notes: Deprecated, in 4.11.0 this was made public, but the wording is confusing. - * After flixel 6.0.0 this will be changed to use `viewX`, `viewY`, `viewWidth` and `viewHeight`, - * meaning, this will return the world coordinates of the camera. - * @since 4.11.0 - */ - @:deprecated("getViewRect is deprecated, use getViewMarginRect") - public function getViewRect(?rect:FlxRect) - { - if (rect == null) - rect = FlxRect.get(); - - return rect.set(viewMarginLeft, viewMarginTop, viewWidth, viewHeight); - } - /** * The size and position of this camera's margins, via `viewMarginLeft`, `viewMarginTop`, `viewWidth` * and `viewHeight`. @@ -1957,11 +1908,6 @@ class FlxCamera extends FlxBasic return contained; } - function set_followLerp(Value:Float):Float - { - return followLerp = FlxMath.bound(Value, 0, 60 / FlxG.updateFramerate); - } - function set_width(Value:Int):Int { if (width != Value && Value > 0) @@ -2087,12 +2033,6 @@ class FlxCamera extends FlxBasic return this.visible = visible; } - @:deprecated("Use calcMarginX") - inline function calcOffsetX():Void calcMarginX(); - - @:deprecated("Use calcMarginY") - inline function calcOffsetY():Void calcMarginY(); - inline function calcMarginX():Void { viewMarginX = 0.5 * width * (scaleX - initialZoom) / scaleX; @@ -2173,48 +2113,6 @@ class FlxCamera extends FlxBasic return scroll.y + viewMarginBottom; } - // deprecated vars - - inline function get_viewOffsetX():Float - { - return viewMarginX; - } - - inline function set_viewOffsetX(value:Float):Float - { - return viewMarginX = value; - } - - inline function get_viewOffsetY():Float - { - return viewMarginY; - } - - inline function set_viewOffsetY(value:Float):Float - { - return viewMarginY = value; - } - - inline function get_viewOffsetWidth():Float - { - return viewMarginRight; - } - - inline function get_viewOffsetHeight():Float - { - return viewMarginBottom; - } - - inline function get__filters():Array - { - return filters; - } - - inline function set__filters(Value:Array):Array - { - return filters = Value; - } - /** * Do not use the following fields! They only exists because FlxCamera extends FlxBasic, * we're hiding them because they've only caused confusion. diff --git a/flixel/FlxG.hx b/flixel/FlxG.hx index 912532fdcb..2e65a37dfc 100644 --- a/flixel/FlxG.hx +++ b/flixel/FlxG.hx @@ -384,34 +384,13 @@ class FlxG public static inline function switchState(nextState:NextState):Void { final stateOnCall = FlxG.state; - - if (!nextState.isInstance() || canSwitchTo(cast nextState)) + state.startOutro(function() { - state.startOutro(function() - { - if (FlxG.state == stateOnCall) - game._nextState = nextState; - else - FlxG.log.warn("`onOutroComplete` was called after the state was switched. This will be ignored"); - }); - } - } - - /** - * Calls state.switchTo(nextState) without a deprecation warning. - * This will be removed in Flixel 6.0.0 - * @since 5.6.0 - */ - @:noCompletion - @:haxe.warning("-WDeprecated") - static function canSwitchTo(nextState:FlxState) - { - #if (haxe < version("4.3.0")) - // Use reflection because @:haxe.warning("-WDeprecated") doesn't work until haxe 4.3 - return Reflect.callMethod(state, Reflect.field(state, 'switchTo'), [nextState]); - #else - return state.switchTo(nextState); - #end + if (FlxG.state == stateOnCall) + game._nextState = nextState; + else + FlxG.log.warn("`onOutroComplete` was called after the state was switched. This will be ignored"); + }); } /** @@ -420,13 +399,7 @@ class FlxG */ public static inline function resetState():Void { - if (state == null || state._constructor == null) - FlxG.log.error("FlxG.resetState was called while switching states"); - else if(!state._constructor.isInstance()) - switchState(state._constructor); - else - // create new instance here so that state.switchTo is called (for backwards compatibility) - switchState(Type.createInstance(Type.getClass(state), [])); + switchState(state._constructor); } /** diff --git a/flixel/FlxGame.hx b/flixel/FlxGame.hx index 3dd97089d1..94dc171d17 100644 --- a/flixel/FlxGame.hx +++ b/flixel/FlxGame.hx @@ -254,7 +254,8 @@ class FlxGame extends Sprite * [`scaleMode`](https://api.haxeflixel.com/flixel/system/scaleModes/index.html) * will determine the actual display size of the game. * @param initialState A constructor for the initial state, ex: `PlayState.new` or `()->new PlayState()`. - * Note: Also allows `Class` for backwards compatibility. + * Note: Before Flixel 6, this took a `Class`, this has been + * deprecated, but is still available, for backwards compatibility. * @param updateFramerate How frequently the game should update. Default is 60 fps. * @param drawFramerate Sets the actual display / draw framerate for the game. Default is 60 fps. * @param skipSplash Whether you want to skip the flixel splash screen with `FLX_NO_DEBUG`. @@ -632,7 +633,7 @@ class FlxGame extends Sprite // Finally assign and create the new state _state = _nextState.createInstance(); - _state._constructor = _nextState; + _state._constructor = _nextState.getConstructor(); _nextState = null; if (_gameJustStarted) @@ -651,8 +652,8 @@ class FlxGame extends Sprite FlxG.signals.postStateSwitch.dispatch(); } - - function gameStart():Void + + function gameStart() { FlxG.signals.postGameStart.dispatch(); _gameJustStarted = false; diff --git a/flixel/FlxObject.hx b/flixel/FlxObject.hx index 21f5795b88..3acd654348 100644 --- a/flixel/FlxObject.hx +++ b/flixel/FlxObject.hx @@ -92,78 +92,6 @@ class FlxObject extends FlxBasic * @since 5.6.0 */ public static var defaultMoves:Bool = true; - - /** - * Generic value for "left". Used by `facing`, `allowCollisions`, and `touching`. - * Note: This exists for backwards compatibility, prefer using `FlxDirectionFlags.LEFT` directly. - */ - @:deprecated("Use LEFT or FlxDirectionFlags.LEFT instead") - @:noCompletion - public static inline var LEFT = FlxDirectionFlags.LEFT; - - /** - * Generic value for "right". Used by `facing`, `allowCollisions`, and `touching`. - * Note: This exists for backwards compatibility, prefer using `FlxDirectionFlags.RIGHT` directly. - */ - @:deprecated("Use RIGHT or FlxDirectionFlags.RIGHT instead") - @:noCompletion - public static inline var RIGHT = FlxDirectionFlags.RIGHT; - - /** - * Generic value for "up". Used by `facing`, `allowCollisions`, and `touching`. - * Note: This exists for backwards compatibility, prefer using `FlxDirectionFlags.UP` directly. - */ - @:deprecated("Use UP or FlxDirectionFlags.UP instead") - @:noCompletion - public static inline var UP = FlxDirectionFlags.UP; - - /** - * Generic value for "down". Used by `facing`, `allowCollisions`, and `touching`. - * Note: This exists for backwards compatibility, prefer using `FlxDirectionFlags.DOWN` directly. - */ - @:deprecated("Use DOWN or FlxDirectionFlags.DOWN instead") - @:noCompletion - public static inline var DOWN = FlxDirectionFlags.DOWN; - - /** - * Special-case constant meaning no collisions, used mainly by `allowCollisions` and `touching`. - * Note: This exists for backwards compatibility, prefer using `FlxDirectionFlags.NONE` directly. - */ - @:deprecated("Use NONE or FlxDirectionFlags.NONE instead") - @:noCompletion - public static inline var NONE = FlxDirectionFlags.NONE; - - /** - * Special-case constant meaning up, used mainly by `allowCollisions` and `touching`. - * Note: This exists for backwards compatibility, prefer using `FlxDirectionFlags.CEILING` directly. - */ - @:deprecated("Use CEILING or FlxDirectionFlags.CEILING instead") - @:noCompletion - public static inline var CEILING = FlxDirectionFlags.CEILING; - - /** - * Special-case constant meaning down, used mainly by `allowCollisions` and `touching`. - * Note: This exists for backwards compatibility, prefer using `FlxDirectionFlags.FLOOR` directly. - */ - @:deprecated("Use FLOOR or FlxDirectionFlags.FLOOR instead") - @:noCompletion - public static inline var FLOOR = FlxDirectionFlags.FLOOR; - - /** - * Special-case constant meaning only the left and right sides, used mainly by `allowCollisions` and `touching`. - * Note: This exists for backwards compatibility, prefer using `FlxDirectionFlags.WALL` directly. - */ - @:deprecated("Use WALL or FlxDirectionFlags.WALL instead") - @:noCompletion - public static inline var WALL = FlxDirectionFlags.WALL; - - /** - * Special-case constant meaning any direction, used mainly by `allowCollisions` and `touching`. - * Note: This exists for backwards compatibility, prefer using `FlxDirectionFlags.ANY` directly. - */ - @:deprecated("Use ANY or FlxDirectionFlags.ANY instead") - @:noCompletion - public static inline var ANY = FlxDirectionFlags.ANY; static function allowCollisionDrag(type:CollisionDragType, object1:FlxObject, object2:FlxObject):Bool { @@ -764,15 +692,6 @@ class FlxObject extends FlxBasic */ public var allowCollisions(default, set) = FlxDirectionFlags.ANY; - /** DEPRECATED - * Whether this sprite is dragged along with the horizontal movement of objects it collides with - * (makes sense for horizontally-moving platforms in platformers for example). - * - * Apart from having a weird typo, this has been deprecated for collisionXDrag, which allows more options. - */ - @:deprecated("Use `collisionXDrag`, instead. Note the corrected spelling: `collis(i)onXDrag") - public var collisonXDrag(get, set):Bool; - /** * Whether this sprite is dragged along with the horizontal movement of objects it collides with * (makes sense for horizontally-moving platforms in platformers for example). Use values @@ -970,11 +889,10 @@ class FlxObject extends FlxBasic * If the group has a LOT of things in it, it might be faster to use `FlxG.overlap()`. * WARNING: Currently tilemaps do NOT support screen space overlap checks! * - * @param objectOrGroup The object or group being tested. - * @param inScreenSpace Whether to take scroll factors into account when checking for overlap. - * Default is `false`, or "only compare in world space." - * @param camera Specify which game camera you want. - * If `null`, it will just grab the first global camera. + * @param objectOrGroup The object or group being tested. + * @param inScreenSpace Whether to take scroll factors into account when checking for overlap. + * Default is `false`, or "only compare in world space." + * @param camera The desired "screen" space. If `null`, `getDefaultCamera()` is used * @return Whether or not the two objects overlap. */ @:access(flixel.group.FlxTypedGroup) @@ -1001,9 +919,8 @@ class FlxObject extends FlxBasic } if (camera == null) - { - camera = FlxG.camera; - } + camera = getDefaultCamera(); + var objectScreenPos:FlxPoint = object.getScreenPosition(null, camera); getScreenPosition(_point, camera); return (objectScreenPos.x + object.width > _point.x) @@ -1025,15 +942,14 @@ class FlxObject extends FlxBasic * rather than taking the object's size into account. * WARNING: Currently tilemaps do NOT support screen space overlap checks! * - * @param x The X position you want to check. - * Pretends this object (the caller, not the parameter) is located here. - * @param y The Y position you want to check. - * Pretends this object (the caller, not the parameter) is located here. - * @param objectOrGroup The object or group being tested. - * @param inScreenSpace Whether to take scroll factors into account when checking for overlap. - * Default is `false`, or "only compare in world space." - * @param camera Specify which game camera you want. - * If `null`, it will just grab the first global camera. + * @param x The X position you want to check. + * Pretends this object (the caller, not the parameter) is located here. + * @param y The Y position you want to check. + * Pretends this object (the caller, not the parameter) is located here. + * @param objectOrGroup The object or group being tested. + * @param inScreenSpace Whether to take scroll factors into account when checking for overlap. + * Default is `false`, or "only compare in world space." + * @param camera The desired "screen" space. If `null`, `getDefaultCamera()` is used * @return Whether or not the two objects overlap. */ @:access(flixel.group.FlxTypedGroup) @@ -1062,9 +978,8 @@ class FlxObject extends FlxBasic } if (camera == null) - { - camera = FlxG.camera; - } + camera = getDefaultCamera(); + var objectScreenPos:FlxPoint = object.getScreenPosition(null, camera); getScreenPosition(_point, camera); return (objectScreenPos.x + object.width > _point.x) @@ -1082,10 +997,9 @@ class FlxObject extends FlxBasic /** * Checks to see if a point in 2D world space overlaps this `FlxObject`. * - * @param point The point in world space you want to check. - * @param inScreenSpace Whether to take scroll factors into account when checking for overlap. - * @param camera Specify which game camera you want. - * If `null`, it will just grab the first global camera. + * @param point The point in world space you want to check. + * @param inScreenSpace Whether to take scroll factors into account when checking for overlap. + * @param camera The desired "screen" space. If `null`, `getDefaultCamera()` is used * @return Whether or not the point overlaps this object. */ public function overlapsPoint(point:FlxPoint, inScreenSpace = false, ?camera:FlxCamera):Bool @@ -1096,11 +1010,10 @@ class FlxObject extends FlxBasic } if (camera == null) - { - camera = FlxG.camera; - } - var xPos:Float = point.x - camera.scroll.x; - var yPos:Float = point.y - camera.scroll.y; + camera = getDefaultCamera(); + + final xPos:Float = point.x - camera.scroll.x; + final yPos:Float = point.y - camera.scroll.y; getScreenPosition(_point, camera); point.putWeak(); return (xPos >= _point.x) && (xPos < _point.x + width) && (yPos >= _point.y) && (yPos < _point.y + height); @@ -1121,7 +1034,7 @@ class FlxObject extends FlxBasic * Returns the screen position of this object. * * @param result Optional arg for the returning point - * @param camera The desired "screen" coordinate space. If `null`, `FlxG.camera` is used. + * @param camera The desired "screen" coordinate space. If `null`, `getDefaultCamera()` is used. * @return The screen position of this object. */ public function getScreenPosition(?result:FlxPoint, ?camera:FlxCamera):FlxPoint @@ -1130,7 +1043,7 @@ class FlxObject extends FlxBasic result = FlxPoint.get(); if (camera == null) - camera = FlxG.camera; + camera = getDefaultCamera(); result.set(x, y); if (pixelPerfectPosition) @@ -1178,8 +1091,8 @@ class FlxObject extends FlxBasic * Handy function for reviving game objects. * Resets their existence flags and position. * - * @param x The new X position of this object. - * @param y The new Y position of this object. + * @param x The new X position of this object. + * @param y The new Y position of this object. */ public function reset(x:Float, y:Float):Void { @@ -1194,14 +1107,13 @@ class FlxObject extends FlxBasic /** * Check and see if this object is currently on screen. * - * @param camera Specify which game camera you want. - * If `null`, it will just grab the first global camera. + * @param camera Specify which game camera you want. If `null`, `getDefaultCamera()` is used * @return Whether the object is on screen or not. */ public function isOnScreen(?camera:FlxCamera):Bool { if (camera == null) - camera = FlxG.camera; + camera = getDefaultCamera(); getScreenPosition(_point, camera); return camera.containsPoint(_point, width, height); @@ -1213,7 +1125,7 @@ class FlxObject extends FlxBasic public function isPixelPerfectRender(?camera:FlxCamera):Bool { if (camera == null) - camera = FlxG.camera; + camera = getDefaultCamera(); return pixelPerfectRender == null ? camera.pixelPerfectRender : pixelPerfectRender; } @@ -1528,19 +1440,6 @@ class FlxObject extends FlxBasic return allowCollisions = value; } - @:noCompletion - function get_collisonXDrag():Bool - { - return collisionXDrag == IMMOVABLE; - } - - @:noCompletion - function set_collisonXDrag(value:Bool):Bool - { - collisionXDrag = value ? IMMOVABLE : NEVER; - return value; - } - #if FLX_DEBUG @:noCompletion function set_debugBoundingBoxColorSolid(color:FlxColor) diff --git a/flixel/FlxSprite.hx b/flixel/FlxSprite.hx index 739fd1a11e..cb402cfb9d 100644 --- a/flixel/FlxSprite.hx +++ b/flixel/FlxSprite.hx @@ -1029,7 +1029,7 @@ class FlxSprite extends FlxObject * * @param worldPoint point in world space you want to check. * @param alphaTolerance Used to determine what counts as solid. - * @param camera The desired "screen" coordinate space. If `null`, `FlxG.camera` is used. + * @param camera The desired "screen" space. If `null`, `getDefaultCamera()` is used * @return Whether or not the point overlaps this object. */ public function pixelsOverlapPoint(worldPoint:FlxPoint, alphaTolerance = 0xFF, ?camera:FlxCamera):Bool @@ -1048,7 +1048,7 @@ class FlxSprite extends FlxObject * Factors in `scale`, `angle`, `offset`, `origin`, and `scrollFactor`. * * @param worldPoint The point in world space - * @param camera The camera, used for `scrollFactor`. If `null`, `FlxG.camera` is used. + * @param camera The camera, used for `scrollFactor`. If `null`, `getDefaultCamera()` is used. * @return a `FlxColor`, if the point is in the sprite's graphic, otherwise `null` is returned. * @since 5.0.0 */ @@ -1071,7 +1071,7 @@ class FlxSprite extends FlxObject * Factors in `scale`, `angle`, `offset`, `origin`, and `scrollFactor`. * * @param screenPoint The point in screen space - * @param camera The desired "screen" coordinate space. If `null`, `FlxG.camera` is used. + * @param camera The desired "screen" space. If `null`, `getDefaultCamera()` is used * @return a `FlxColor`, if the point is in the sprite's graphic, otherwise `null` is returned. * @since 5.0.0 */ @@ -1094,14 +1094,14 @@ class FlxSprite extends FlxObject * is the top left of the graphic. * Factors in `scale`, `angle`, `offset`, `origin`, and `scrollFactor`. * - * @param worldPoint The world coordinates. - * @param camera The camera, used for `scrollFactor`. If `null`, `FlxG.camera` is used. + * @param worldPoint The world coordinates + * @param camera The camera, used for `scrollFactor`. If `null`, `getDefaultCamera()` is used * @param result Optional arg for the returning point */ public function transformWorldToPixels(worldPoint:FlxPoint, ?camera:FlxCamera, ?result:FlxPoint):FlxPoint { if (camera == null) - camera = FlxG.camera; + camera = getDefaultCamera(); var screenPoint = FlxPoint.weak(worldPoint.x - camera.scroll.x, worldPoint.y - camera.scroll.y); worldPoint.putWeak(); @@ -1139,7 +1139,7 @@ class FlxSprite extends FlxObject * Factors in `scale`, `angle`, `offset`, `origin`, and `scrollFactor`. * * @param screenPoint The screen coordinates - * @param camera The desired "screen" coordinate space. If `null`, `FlxG.camera` is used. + * @param camera The desired "screen" space. If `null`, `getDefaultCamera()` is used * @param result Optional arg for the returning point */ public function transformScreenToPixels(screenPoint:FlxPoint, ?camera:FlxCamera, ?result:FlxPoint):FlxPoint @@ -1265,13 +1265,13 @@ class FlxSprite extends FlxObject * Check and see if this object is currently on screen. Differs from `FlxObject`'s implementation * in that it takes the actual graphic into account, not just the hitbox or bounding box or whatever. * - * @param Camera Specify which game camera you want. If `null`, `FlxG.camera` is used. + * @param camera Specify which game camera you want. If `null`, `getDefaultCamera()` is used * @return Whether the object is on screen or not. */ override public function isOnScreen(?camera:FlxCamera):Bool { if (camera == null) - camera = FlxG.camera; + camera = getDefaultCamera(); return camera.containsRect(getScreenBounds(_rect, camera)); } @@ -1324,8 +1324,8 @@ class FlxSprite extends FlxObject /** * Calculates the smallest globally aligned bounding box that encompasses this sprite's graphic as it * would be displayed. Honors scrollFactor, rotation, scale, offset and origin. - * @param newRect Optional output `FlxRect`, if `null`, a new one is created. - * @param camera Optional camera used for scrollFactor, if null `FlxG.camera` is used. + * @param newRect Optional output `FlxRect`, if `null`, a new one is created + * @param camera Optional camera used for scrollFactor, if null `getDefaultCamera()` is used * @return A globally aligned `FlxRect` that fully contains the input sprite. * @since 4.11.0 */ @@ -1335,7 +1335,7 @@ class FlxSprite extends FlxObject newRect = FlxRect.get(); if (camera == null) - camera = FlxG.camera; + camera = getDefaultCamera(); newRect.setPosition(x, y); if (pixelPerfectPosition) diff --git a/flixel/FlxState.hx b/flixel/FlxState.hx index c13149f646..ade5b320fc 100644 --- a/flixel/FlxState.hx +++ b/flixel/FlxState.hx @@ -11,10 +11,6 @@ import flixel.util.typeLimit.NextState; * It is for all intents and purpose a fancy `FlxContainer`. And really, it's not even that fancy. */ @:keepSub // workaround for HaxeFoundation/haxe#3749 -#if FLX_NO_UNIT_TEST -@:autoBuild(flixel.system.macros.FlxMacroUtil.deprecateOverride("switchTo", "switchTo is deprecated, use startOutro")) -#end -// show deprecation warning when `switchTo` is overriden in dereived classes class FlxState extends FlxContainer { /** @@ -54,7 +50,7 @@ class FlxState extends FlxContainer */ @:allow(flixel.FlxGame) @:allow(flixel.FlxG) - var _constructor:NextState; + var _constructor:()->FlxState; /** * Current substate. Substates also can be nested. @@ -107,7 +103,7 @@ class FlxState extends FlxContainer */ public function create():Void {} - override public function draw():Void + override function draw():Void { if (persistentDraw || subState == null) super.draw(); @@ -188,18 +184,6 @@ class FlxState extends FlxContainer super.destroy(); } - /** - * Called from `FlxG.switchState()`. If `false` is returned, the state - * switch is cancelled - the default implementation returns `true`. - * - * Useful for customizing state switches, e.g. for transition effects. - */ - @:deprecated("switchTo is deprecated, use startOutro") - public function switchTo(nextState:FlxState):Bool - { - return true; - } - /** * Called from `FlxG.switchState()`, when `onOutroComplete` is called, the actual state * switching will happen. @@ -262,7 +246,7 @@ class FlxState extends FlxContainer { return FlxG.cameras.bgColor = Value; } - + @:noCompletion function get_subStateOpened():FlxTypedSignalVoid> { diff --git a/flixel/animation/FlxAnimation.hx b/flixel/animation/FlxAnimation.hx index 1bb90a335f..d8600f5a9d 100644 --- a/flixel/animation/FlxAnimation.hx +++ b/flixel/animation/FlxAnimation.hx @@ -30,13 +30,7 @@ class FlxAnimation extends FlxBaseAnimation * those values will override this value. */ public var frameDuration:Float = 0; - - /** - * Seconds between frames (inverse of the framerate) - */ - @:deprecated('FlxAnimation.delay is deprecated, use `frameDuration`') - public var delay(get, set):Float; - + /** * Whether the current animation has finished. */ @@ -294,14 +288,4 @@ class FlxAnimation extends FlxBaseAnimation { return frames.length; } - - inline function get_delay() - { - return frameDuration; - } - - inline function set_delay(value:Float) - { - return frameDuration = value; - } } diff --git a/flixel/animation/FlxAnimationController.hx b/flixel/animation/FlxAnimationController.hx index e9b8c440b5..938ea13625 100644 --- a/flixel/animation/FlxAnimationController.hx +++ b/flixel/animation/FlxAnimationController.hx @@ -48,13 +48,6 @@ class FlxAnimationController implements IFlxDestroyable */ public var numFrames(get, never):Int; - /** - * The total number of frames in this image. - * WARNING: assumes each row in the sprite sheet is full! - */ - @:deprecated("frames is deprecated, use numFrames") // 5.3.0 - public var frames(get, never):Int; - /** * If assigned, will be called each time the current animation's frame changes * @@ -1007,11 +1000,6 @@ class FlxAnimationController implements IFlxDestroyable return value; } - inline function get_frames():Int - { - return _sprite.numFrames; - } - inline function get_numFrames():Int { return _sprite.numFrames; diff --git a/flixel/group/FlxSpriteGroup.hx b/flixel/group/FlxSpriteGroup.hx index a5e6153797..8c4da0f1ef 100644 --- a/flixel/group/FlxSpriteGroup.hx +++ b/flixel/group/FlxSpriteGroup.hx @@ -1072,7 +1072,7 @@ class FlxTypedSpriteGroup extends FlxSprite Sprite.offset.copyFrom(Offset); inline function originTransform(Sprite:FlxSprite, Origin:FlxPoint) - Sprite.origin.copyFrom(Origin); + Sprite.origin.set(x + origin.x - Sprite.x, y + origin.y - Sprite.y); inline function scaleTransform(Sprite:FlxSprite, Scale:FlxPoint) Sprite.scale.copyFrom(Scale); diff --git a/flixel/input/FlxSwipe.hx b/flixel/input/FlxSwipe.hx index 207c7f2f0d..3e7d1e0d4d 100644 --- a/flixel/input/FlxSwipe.hx +++ b/flixel/input/FlxSwipe.hx @@ -20,8 +20,6 @@ class FlxSwipe implements IFlxDestroyable public var endPosition(default, null):FlxPoint; public var distance(get, never):Float; - @:deprecated("FlxSwipe.angle is deprecated, use degrees") - public var angle(get, never):Float; public var degrees(get, never):Float; public var radians(get, never):Float; public var duration(get, never):Float; @@ -61,11 +59,6 @@ class FlxSwipe implements IFlxDestroyable return FlxMath.vectorLength(startPosition.x - endPosition.x, startPosition.y - endPosition.y); } - inline function get_angle():Float - { - return startPosition.degreesTo(endPosition); - } - inline function get_degrees():Float { return startPosition.degreesTo(endPosition); diff --git a/flixel/math/FlxAngle.hx b/flixel/math/FlxAngle.hx index af87627640..5d0f6975ed 100644 --- a/flixel/math/FlxAngle.hx +++ b/flixel/math/FlxAngle.hx @@ -332,61 +332,7 @@ class FlxAngle return angleBetweenTouch(Object, Touch, false); } #end - - /** - * Translate an object's facing to angle. - * - * @param FacingBitmask Bitmask from which to calculate the angle, as in FlxSprite::facing - * @param AsDegrees If you need the value in degrees instead of radians, set to true - * @return The angle (in radians unless AsDegrees is true) - */ - @:deprecated("FlxAngle.angleFromFacing is deprecated, use flags.degrees.") - public static function angleFromFacing(Facing:FlxDirectionFlags, AsDegrees:Bool = false):Float - { - var degrees = Facing.degrees; - return AsDegrees ? degrees : asRadians(degrees); - } - - /** - * Convert polar coordinates (radius + angle) to cartesian coordinates (x + y) - * - * @param Radius The radius - * @param Angle The angle, in degrees - * @param point Optional FlxPoint if you don't want a new one created - * @return The point in cartesian coords - */ - @:deprecated("FlxAngle.getCartesianCoords is deprecated, use FlxVector.setPolarDegrees") - public static function getCartesianCoords(Radius:Float, Angle:Float, ?point:FlxPoint):FlxPoint - { - var p = point; - if (p == null) - p = FlxPoint.get(); - - p.x = Radius * Math.cos(Angle * TO_RAD); - p.y = Radius * Math.sin(Angle * TO_RAD); - return p; - } - - /** - * Convert cartesian coordinates (x + y) to polar coordinates (radius + angle) - * - * @param X x position - * @param Y y position - * @param point Optional FlxPoint if you don't want a new one created - * @return The point in polar coords (x = Radius, y = Angle (degrees)) - */ - @:deprecated("FlxAngle.getCartesianCoords is deprecated, use FlxPoint") - public static function getPolarCoords(X:Float, Y:Float, ?point:FlxPoint):FlxPoint - { - var p = point; - if (p == null) - p = FlxPoint.get(); - - p.x = Math.sqrt((X * X) + (Y * Y)); - p.y = degreesFromOrigin(X, Y); - return p; - } - + static inline function get_TO_DEG():Float { return 180 / Math.PI; diff --git a/flixel/math/FlxPoint.hx b/flixel/math/FlxPoint.hx index a7db15929e..599c25fbf2 100644 --- a/flixel/math/FlxPoint.hx +++ b/flixel/math/FlxPoint.hx @@ -674,19 +674,6 @@ import openfl.geom.Point; return FlxMath.pointInFlxRect(x, y, rect); } - /** - * Rotates this point clockwise in 2D space around another point by the given degrees. - * - * @param pivot The pivot you want to rotate this point around - * @param degrees Rotate the point by this many degrees clockwise. - * @return A FlxPoint containing the coordinates of the rotated point. - */ - @:deprecated("rotate is deprecated, use pivotDegrees") - public function rotate(pivot:FlxPoint, degrees:Float):FlxPoint - { - return pivotDegrees(pivot, degrees); - } - /** * Rotates this point clockwise in 2D space around another point by the given radians. * Note: To rotate a point around 0,0 you can use `p.radians += angle` @@ -820,56 +807,6 @@ import openfl.geom.Point; return point.degreesTo(this); } - /** DEPRECATED - * - * Calculates the angle between this and another point. 0 degrees points straight up. - * - * Note: Every other flixel function treats straight right as 0 degrees. - * - * Also Note: The result is very innacurate. - * - * @param point The other point. - * @return The angle in degrees, between -180 and 180. - * - * @see [Flixel 5.0.0 Migration guide](https://github.com/HaxeFlixel/flixel/wiki/Flixel-5.0.0-Migration-guide) - */ - @:deprecated("angleBetween is deprecated, use degreesTo instead") - public function angleBetween(point:FlxPoint):Float - { - var x:Float = point.x - x; - var y:Float = point.y - y; - var angle:Float = 0; - - if ((x != 0) || (y != 0)) - { - var c1:Float = Math.PI * 0.25; - var c2:Float = 3 * c1; - var ay:Float = (y < 0) ? -y : y; - - if (x >= 0) - { - angle = c1 - c1 * ((x - ay) / (x + ay)); - } - else - { - angle = c2 - c1 * ((x + ay) / (ay - x)); - } - angle = ((y < 0) ? -angle : angle) * FlxAngle.TO_DEG; - - if (angle > 90) - { - angle = angle - 270; - } - else - { - angle += 90; - } - } - - point.putWeak(); - return angle; - } - /** * Applies transformation matrix to this point * @param matrix transformation matrix diff --git a/flixel/math/FlxRandom.hx b/flixel/math/FlxRandom.hx index 829460bd78..7a78034cc2 100644 --- a/flixel/math/FlxRandom.hx +++ b/flixel/math/FlxRandom.hx @@ -295,35 +295,6 @@ class FlxRandom return selected; } - /** - * Shuffles the entries in an array into a new pseudorandom order. - * - * @param Objects An array to shuffle. - * @param HowManyTimes How many swaps to perform during the shuffle operation. - * A good rule of thumb is 2-4 times the number of objects in the list. - * @return The newly shuffled array. - */ - @:generic - @:deprecated("Unless you rely on reproducing the exact output of shuffleArray(), you should use shuffle() instead, which is both faster and higher quality.") - public function shuffleArray(Objects:Array, HowManyTimes:Int):Array - { - HowManyTimes = Std.int(Math.max(HowManyTimes, 0)); - - var tempObject:Null = null; - - for (i in 0...HowManyTimes) - { - var pick1:Int = int(0, Objects.length - 1); - var pick2:Int = int(0, Objects.length - 1); - - tempObject = Objects[pick1]; - Objects[pick1] = Objects[pick2]; - Objects[pick2] = tempObject; - } - - return Objects; - } - /** * Shuffles the entries in an array in-place into a new pseudorandom order, * using the standard Fisher-Yates shuffle algorithm. diff --git a/flixel/math/FlxVector.hx b/flixel/math/FlxVector.hx deleted file mode 100644 index d85bcecbb9..0000000000 --- a/flixel/math/FlxVector.hx +++ /dev/null @@ -1,8 +0,0 @@ -package flixel.math; - -/** - * DEPRECATED - Use `FlxPoint` - * @see [Flixel 5.0.0 Migration guide](https://github.com/HaxeFlixel/flixel/wiki/Flixel-5.0.0-Migration-guide) - */ -@:deprecated("FlxVector utils have been moved to FlxPoint") -typedef FlxVector = FlxPoint; diff --git a/flixel/path/FlxPath.hx b/flixel/path/FlxPath.hx index d3d08844f8..6cfcb3316e 100644 --- a/flixel/path/FlxPath.hx +++ b/flixel/path/FlxPath.hx @@ -113,41 +113,6 @@ private class AnchorTools */ class FlxPath extends FlxBasePath { - /** - * Move from the start of the path to the end then stop. - */ - @:deprecated("Use FORWARD or FlxPathType.FORWARD instead") - @:noCompletion - public static inline var FORWARD = FlxPathType.FORWARD; - - /** - * Move from the end of the path to the start then stop. - */ - @:deprecated("Use BACKWARD or FlxPathType.BACKWARD instead") - @:noCompletion - public static inline var BACKWARD = FlxPathType.BACKWARD; - - /** - * Move from the start of the path to the end then directly back to the start, and start over. - */ - @:deprecated("Use LOOP_FORWARD or FlxPathType.LOOP_FORWARD instead") - @:noCompletion - public static inline var LOOP_FORWARD = FlxPathType.LOOP_FORWARD; - - /** - * Move from the end of the path to the start then directly back to the end, and start over. - */ - @:deprecated("Use LOOP_BACKWARD or FlxPathType.LOOP_BACKWARD instead") - @:noCompletion - public static inline var LOOP_BACKWARD = FlxPathType.LOOP_BACKWARD; - - /** - * Move from the start of the path to the end then turn around and go back to the start, over and over. - */ - @:deprecated("Use YOYO or FlxPathType.YOYO instead") - @:noCompletion - public static inline var YOYO = FlxPathType.YOYO; - /** * Path behavior controls: move from the start of the path to the end then stop. */ diff --git a/flixel/system/FlxAssets.hx b/flixel/system/FlxAssets.hx index 1ab20ca686..c6915bc94f 100644 --- a/flixel/system/FlxAssets.hx +++ b/flixel/system/FlxAssets.hx @@ -50,15 +50,9 @@ abstract FlxAngelCodeAsset(OneOfThree) from Xml from String } -@:deprecated("`FlxAngelCodeXmlAsset` is deprecated, use `FlxAngelCodeAsset` instead") +@:deprecated("`FlxAngelCodeXmlAsset` is deprecated, use `FlxAngelCodeAsset` instead")// 5.6.0 typedef FlxAngelCodeXmlAsset = FlxAngelCodeAsset; -@:deprecated("`FlxAngelCodeSource` is deprecated, use `FlxAngelCodeAsset` instead") -typedef FlxAngelCodeSource = FlxAngelCodeAsset; - -@:deprecated("`FlxTexturePackerSource` is deprecated, use `FlxAtlasDataAsset` instead") -typedef FlxTexturePackerSource = FlxTexturePackerJsonAsset; - abstract FlxXmlAsset(OneOfTwo) from Xml from String { public function getXml() diff --git a/flixel/system/FlxSound.hx b/flixel/system/FlxSound.hx deleted file mode 100644 index 4ac5c01e18..0000000000 --- a/flixel/system/FlxSound.hx +++ /dev/null @@ -1,6 +0,0 @@ -package flixel.system; -/** - * This is the universal flixel sound object, used for streaming, music, and sound effects. - */ -@:deprecated("flixel.system.FlxSound was moved to flixel.sound.FlxSound") -typedef FlxSound = flixel.sound.FlxSound; \ No newline at end of file diff --git a/flixel/system/FlxSoundGroup.hx b/flixel/system/FlxSoundGroup.hx deleted file mode 100644 index 67253997aa..0000000000 --- a/flixel/system/FlxSoundGroup.hx +++ /dev/null @@ -1,7 +0,0 @@ -package flixel.system; - -/** - * A way of grouping sounds for things such as collective volume control - */ -@:deprecated("flixel.system.FlxSoundGroup was moved to flixel.sound.FlxSoundGroup") -typedef FlxSoundGroup = flixel.sound.FlxSoundGroup; \ No newline at end of file diff --git a/flixel/system/frontEnds/CameraFrontEnd.hx b/flixel/system/frontEnds/CameraFrontEnd.hx index 3342a40d20..21b2c07831 100644 --- a/flixel/system/frontEnds/CameraFrontEnd.hx +++ b/flixel/system/frontEnds/CameraFrontEnd.hx @@ -179,11 +179,13 @@ class CameraFrontEnd */ public function reset(?NewCamera:FlxCamera):Void { + FlxG.camera = null; + while (list.length > 0) remove(list[0]); if (NewCamera == null) - NewCamera = new FlxCamera(0, 0, FlxG.width, FlxG.height); + NewCamera = new FlxCamera(); FlxG.camera = add(NewCamera); NewCamera.ID = 0; diff --git a/flixel/system/frontEnds/SignalFrontEnd.hx b/flixel/system/frontEnds/SignalFrontEnd.hx index cf16f866e1..4344b7b154 100644 --- a/flixel/system/frontEnds/SignalFrontEnd.hx +++ b/flixel/system/frontEnds/SignalFrontEnd.hx @@ -17,11 +17,10 @@ class SignalFrontEnd * @since 4.6.0 */ public var postStateSwitch(default, null):FlxSignal = new FlxSignal(); - - @:deprecated("Use preStateSwitch instead of stateSwitched") - public var stateSwitched(get, never):FlxSignal; + + /** Dispatched just before state.create() is called */ public var preStateCreate(default, null):FlxTypedSignalVoid> = new FlxTypedSignalVoid>(); - + /** * Gets dispatched when the game is resized. * Passes the new window width and height to callback functions. @@ -43,8 +42,6 @@ class SignalFrontEnd */ public var postGameStart(default, null):FlxSignal = new FlxSignal(); - @:deprecated("Use postGameStart instead of gameStarted") - public var gameStarted(get, never):FlxSignal; public var preUpdate(default, null):FlxSignal = new FlxSignal(); public var postUpdate(default, null):FlxSignal = new FlxSignal(); public var preDraw(default, null):FlxSignal = new FlxSignal(); @@ -54,14 +51,4 @@ class SignalFrontEnd @:allow(flixel.FlxG) function new() {} - - function get_stateSwitched():FlxSignal - { - return preStateSwitch; - } - - function get_gameStarted():FlxSignal - { - return postGameStart; - } } diff --git a/flixel/tile/FlxBaseTilemap.hx b/flixel/tile/FlxBaseTilemap.hx index 6670750bb0..4858ac21b3 100644 --- a/flixel/tile/FlxBaseTilemap.hx +++ b/flixel/tile/FlxBaseTilemap.hx @@ -1593,7 +1593,7 @@ class FlxBaseTilemap extends FlxObject * * @param worldPoint The point in world space you want to check. * @param inScreenSpace Whether to take scroll factors into account when checking for overlap. - * @param camera Specify which game camera you want. If null getScreenPosition() will just grab the first global camera. + * @param camera The desired "screen" space. If `null`, `getDefaultCamera()` is used * @return Whether or not the point overlaps this object. */ override function overlapsPoint(worldPoint:FlxPoint, inScreenSpace = false, ?camera:FlxCamera):Bool @@ -1601,7 +1601,7 @@ class FlxBaseTilemap extends FlxObject if (inScreenSpace) { if (camera == null) - camera = FlxG.camera; + camera = getDefaultCamera(); worldPoint.subtract(camera.scroll); worldPoint.putWeak(); diff --git a/flixel/tile/FlxTilemap.hx b/flixel/tile/FlxTilemap.hx index 1d15f77fc9..cee1fe130b 100644 --- a/flixel/tile/FlxTilemap.hx +++ b/flixel/tile/FlxTilemap.hx @@ -152,15 +152,6 @@ class FlxTypedTilemap extends FlxBaseTilemap * @since 5.0.0 */ public static var defaultFramePadding = 2; - - /** - * DISABLED, the static var `defaultFramePadding` fixes the tearing issue in a more performant - * and visually appealing way. - */ - @:deprecated("useScaleHaxe is no longer needed") - @:noCompletion - public var useScaleHack:Bool = false; - /** * Eliminates tearing on tilemaps by extruding each tile frame's edge out by the specified @@ -322,7 +313,7 @@ class FlxTypedTilemap extends FlxBaseTilemap /** * Clean up memory. */ - override public function destroy():Void + override function destroy():Void { _flashPoint = null; _flashRect = null; @@ -552,7 +543,7 @@ class FlxTypedTilemap extends FlxBaseTilemap } #if FLX_DEBUG - override public function drawDebugOnCamera(camera:FlxCamera):Void + override function drawDebugOnCamera(camera:FlxCamera):Void { if (!FlxG.renderTile) return; @@ -634,10 +625,10 @@ class FlxTypedTilemap extends FlxBaseTilemap * @param camera Specify which game camera you want. If `null`, it will just grab the first global camera. * @return Whether the object is on screen or not. */ - override public function isOnScreen(?camera:FlxCamera):Bool + override function isOnScreen(?camera:FlxCamera):Bool { if (camera == null) - camera = FlxG.camera; + camera = getDefaultCamera(); var minX:Float = x - offset.x - camera.scroll.x * scrollFactor.x; var minY:Float = y - offset.y - camera.scroll.y * scrollFactor.y; @@ -649,7 +640,7 @@ class FlxTypedTilemap extends FlxBaseTilemap /** * Draws the tilemap buffers to the cameras. */ - override public function draw():Void + override function draw():Void { // don't try to render a tilemap that isn't loaded yet if (graphic == null) @@ -723,7 +714,7 @@ class FlxTypedTilemap extends FlxBaseTilemap * * @param dirty Whether to flag the tilemap buffers as dirty or not. */ - override public function setDirty(dirty:Bool = true):Void + override function setDirty(dirty:Bool = true):Void { if (FlxG.renderTile) return; @@ -876,14 +867,16 @@ class FlxTypedTilemap extends FlxBaseTilemap /** * Call this function to lock the automatic camera to the map's edges. * - * @param camera Specify which game camera you want. If null getScreenPosition() will just grab the first global camera. - * @param border Adjusts the camera follow boundary by whatever number of tiles you specify here. Handy for blocking off deadends that are offscreen, etc. Use a negative number to add padding instead of hiding the edges. + * @param camera The desired camera. If `null`, `getDefaultCamera()` is used. + * @param border Adjusts the camera follow boundary by whatever number of tiles you + * specify here. Handy for blocking off deadends that are offscreen, etc. + * Use a negative number to add padding instead of hiding the edges. * @param updateWorld Whether to update the collision system's world size, default value is true. */ public function follow(?camera:FlxCamera, border = 0, updateWorld = true):Void { if (camera == null) - camera = FlxG.camera; + camera = getDefaultCamera(); camera.setScrollBoundsRect( x + border * scaledTileWidth, diff --git a/flixel/tweens/FlxTween.hx b/flixel/tweens/FlxTween.hx index b97fce4c8a..8f1c62afb4 100644 --- a/flixel/tweens/FlxTween.hx +++ b/flixel/tweens/FlxTween.hx @@ -175,36 +175,6 @@ enum abstract FlxTweenType(Int) from Int to Int */ class FlxTween implements IFlxDestroyable { - /** - * Deprecated, use `FlxTweenType.PERSIST` instead. - */ - @:deprecated("Use FlxTweenType.PERSIST instead") - public static var PERSIST = FlxTweenType.PERSIST; - - /** - * Deprecated, use `FlxTweenType.LOOPING` instead. - */ - @:deprecated("Use FlxTweenType.LOOPING instead") - public static var LOOPING = FlxTweenType.LOOPING; - - /** - * Deprecated, use `FlxTweenType.PINGPONG` instead. - */ - @:deprecated("Use FlxTweenType.PINGPONG instead") - public static var PINGPONG = FlxTweenType.PINGPONG; - - /** - * Deprecated, use `FlxTweenType.ONESHOT` instead. - */ - @:deprecated("Use FlxTweenType.ONESHOT instead") - public static var ONESHOT = FlxTweenType.ONESHOT; - - /** - * Deprecated, use `FlxTweenType.BACKWARD` instead. - */ - @:deprecated("Use FlxTweenType.BACKWARD instead") - public static var BACKWARD = FlxTweenType.BACKWARD; - /** * The global tweening manager that handles global tweens * @since 4.2.0 diff --git a/flixel/util/FlxCollision.hx b/flixel/util/FlxCollision.hx index 7359a34a04..df864ca9c1 100644 --- a/flixel/util/FlxCollision.hx +++ b/flixel/util/FlxCollision.hx @@ -177,27 +177,6 @@ class FlxCollision return hit; } - /** - * Checks to see if a point in 2D world space overlaps this `FlxSprite` object's - * current displayed pixels. This check is ALWAYS made in screen space, and - * factors in `scale`, `angle`, `offset`, `origin`, and `scrollFactor`. - * - * @param worldX The x coordinate of the point given in world space - * @param worldY The y coordinate of the point given in world space - * @param sprite The FlxSprite to check the point against - * @param alphaTolerance The alpha tolerance for with pixels are considered "solid". - * Defaults to 1 (anything that is not fully invisible). - * @return Whether the x/y point overlaps with the sprite, false if not - */ - @:deprecated("Use sprite.pixelsOverlapPoint instead") - public static function pixelPerfectPointCheck(worldX:Int, worldY:Int, target:FlxSprite, alphaTolerance = 1):Bool - { - if (FlxG.renderTile) - target.drawFrame(); - - return target.pixelsOverlapPoint(FlxPoint.weak(worldX, worldY), alphaTolerance); - } - /** * Creates a "wall" around the given camera which can be used for FlxSprite collision * diff --git a/flixel/util/FlxPath.hx b/flixel/util/FlxPath.hx deleted file mode 100644 index 3045095e67..0000000000 --- a/flixel/util/FlxPath.hx +++ /dev/null @@ -1,9 +0,0 @@ -package flixel.util; - -/** - * DEPRECATED - `FlxPath` was moved to the `flixel.path` package. Update your imports. - * - * @see [Flixel 5.0.0 Migration guide](https://github.com/HaxeFlixel/flixel/wiki/Flixel-5.0.0-Migration-guide) - */ -@:deprecated("FlxPath was moved to the package: `flixel.path`") -typedef FlxPath = flixel.path.FlxPath; \ No newline at end of file diff --git a/flixel/util/FlxSpriteUtil.hx b/flixel/util/FlxSpriteUtil.hx index f0a5728145..1846835606 100644 --- a/flixel/util/FlxSpriteUtil.hx +++ b/flixel/util/FlxSpriteUtil.hx @@ -159,16 +159,16 @@ class FlxSpriteUtil /** * Checks the sprite's screen bounds of the FlxSprite and keeps them within the camera by wrapping it around. * - * @param sprite The FlxSprite to wrap. - * @param camera The camera to wrap around. If left null, `FlxG.camera` is used. - * @param edges The edges FROM which to wrap. Use constants like `LEFT`, `RIGHT`, `UP|DOWN` or `ANY`. - * @return The FlxSprite for chaining + * @param sprite The FlxSprite to wrap. + * @param camera The camera to wrap around. If `null`, `sprite.getDefaultCamera()` is used. + * @param edges The edges FROM which to wrap. Use constants like `LEFT`, `RIGHT`, `UP|DOWN` or `ANY`. + * @return The FlxSprite for chaining * @since 4.11.0 */ public static function cameraWrap(sprite:FlxSprite, ?camera:FlxCamera, edges:FlxDirectionFlags = ANY):FlxSprite { if (camera == null) - camera = FlxG.camera; + camera = sprite.getDefaultCamera(); var spriteBounds = sprite.getScreenBounds(camera); var offset = FlxPoint.get( @@ -195,16 +195,16 @@ class FlxSpriteUtil /** * Checks the sprite's screen bounds and keeps it entirely within the camera. * - * @param sprite The FlxSprite to restrict. - * @param camera The camera resitricting the sprite. If left null, `FlxG.camera` is used. - * @param edges The edges to restrict. Use constants like `LEFT`, `RIGHT`, `UP|DOWN` or `ANY`. - * @return The FlxSprite for chaining + * @param sprite The FlxSprite to restrict. + * @param camera The camera resitricting the sprite. If left null, `sprite.getDefaultCamera()` is used. + * @param edges The edges to restrict. Use constants like `LEFT`, `RIGHT`, `UP|DOWN` or `ANY`. + * @return The FlxSprite for chaining * @since 4.11.0 */ public static function cameraBound(sprite:FlxSprite, ?camera:FlxCamera, edges:FlxDirectionFlags = ANY):FlxSprite { if (camera == null) - camera = FlxG.camera; + camera = sprite.getDefaultCamera(); var spriteBounds = sprite.getScreenBounds(camera); var offset = FlxPoint.get( diff --git a/flixel/util/FlxUnicodeUtil.hx b/flixel/util/FlxUnicodeUtil.hx deleted file mode 100644 index 12859bafbd..0000000000 --- a/flixel/util/FlxUnicodeUtil.hx +++ /dev/null @@ -1,57 +0,0 @@ -package flixel.util; - -/** - * Just an internal helper to deal with the deprecation of `haxe.Utf8` - not considered public API. - */ -@:dox(hide) -@:noCompletion -@:deprecated("Use UnicodeString") -class FlxUnicodeUtil -{ - @:deprecated("Use UnicodeString") - public static inline function uLength(s:String):Int - { - return (s : UnicodeString).length; - } - - @:deprecated("Use UnicodeString") - public static inline function uEquals(a:String, b:String):Bool - { - return (a : UnicodeString) == (b : UnicodeString); - } - - @:deprecated("Use UnicodeString") - public static inline function uSub(s:String, pos:Int, len:Int):String - { - return (s : UnicodeString).substr(pos, len); - } - - @:deprecated("Use UnicodeString") - public static inline function uCharCodeAt(s:String, index:Int):Null - { - return (s : UnicodeString).charCodeAt(index); - } -} - -@:dox(hide) -@:noCompletion -@:deprecated("Use UnicodeString") -abstract UnicodeBuffer(UnicodeString) -{ - @:deprecated("Use UnicodeString") - public inline function new(s:String = "") - { - this = s; - } - - @:deprecated("Use UnicodeString") - public inline function addChar(c:Int):UnicodeBuffer - { - return new UnicodeBuffer(this + String.fromCharCode(c)); - } - - public inline function toString():String - { - return this; - } -} diff --git a/flixel/util/typeLimit/NextState.hx b/flixel/util/typeLimit/NextState.hx index bf2d92f9b0..d1979a165a 100644 --- a/flixel/util/typeLimit/NextState.hx +++ b/flixel/util/typeLimit/NextState.hx @@ -35,7 +35,7 @@ import flixel.FlxState; abstract NextState(Dynamic) { @:from - // @:deprecated("use `MyState.new` or `()->new MyState()` instead of `new MyState()`)") // wait until 6.0.0 + @:deprecated("use `MyState.new` or `()->new MyState()` instead of `new MyState()`)") public static function fromState(state:FlxState):NextState { return cast state; @@ -47,23 +47,11 @@ abstract NextState(Dynamic) return cast func; } - @:allow(flixel.FlxG) - inline function isInstance():Bool - { - return this is FlxState; - } - - @:allow(flixel.FlxG) - inline function isClass():Bool - { - return this is Class; - } - public function createInstance():FlxState { - if (isInstance()) + if (this is FlxState) return cast this; - else if (isClass()) + else if (this is Class) return Type.createInstance(this, []); else return cast this(); @@ -71,18 +59,13 @@ abstract NextState(Dynamic) public function getConstructor():()->FlxState { - if (isInstance()) + if (this is FlxState) { return function ():FlxState { return cast Type.createInstance(Type.getClass(this), []); } } - else if (isClass()) - return function ():FlxState - { - return cast Type.createInstance(this, []); - } else return cast this; } @@ -91,7 +74,7 @@ abstract NextState(Dynamic) /** * A utility type that allows methods to accept multiple types, when dealing with "future" `FlxStates`. * Prior to haxeFlixel 6, the `FlxGame` constructor took a `FlxState` class which meant initial - `FlxStates`could not have constructor args. In version 6.0.0 and higher, it now takes a function + * `FlxStates`could not have constructor args. In version 6.0.0 and higher, it now takes a function * that returns a newly created instance. * * ## examples: @@ -143,4 +126,4 @@ abstract InitialState(Dynamic) to NextState else return cast this; } -} +} \ No newline at end of file diff --git a/haxelib.json b/haxelib.json index f10bb4940c..84c57f7ea8 100644 --- a/haxelib.json +++ b/haxelib.json @@ -4,8 +4,8 @@ "license": "MIT", "tags": ["game", "openfl", "flash", "html5", "neko", "cpp", "android", "ios", "cross"], "description": "HaxeFlixel is a 2D game engine based on OpenFL that delivers cross-platform games.", - "version": "5.10.0", - "releasenote": "TBD", + "version": "6.0.0", + "releasenote": "Remove various deprecated tools", "contributors": ["haxeflixel", "Gama11", "GeoKureli"], "dependencies": { "lime": "", diff --git a/tests/unit/src/TestMain.hx b/tests/unit/src/TestMain.hx index bc092e7186..5a4936b3d2 100644 --- a/tests/unit/src/TestMain.hx +++ b/tests/unit/src/TestMain.hx @@ -21,7 +21,7 @@ class TestMain public function new() { // Flixel was not designed for unit testing so we can only have one instance for now. - Lib.current.stage.addChild(new FlxGame(640, 480, FlxState, 60, 60, true)); + Lib.current.stage.addChild(new FlxGame(640, 480, FlxState.new, 60, 60, true)); var suites = new Array>(); suites.push(TestSuite); diff --git a/tests/unit/src/flixel/FlxCameraTest.hx b/tests/unit/src/flixel/FlxCameraTest.hx index 62eeb63819..85459f6094 100644 --- a/tests/unit/src/flixel/FlxCameraTest.hx +++ b/tests/unit/src/flixel/FlxCameraTest.hx @@ -47,7 +47,7 @@ class FlxCameraTest extends FlxTest function testDefaultCamerasStateSwitch():Void { FlxCamera._defaultCameras = [FlxG.camera]; - switchState(new FlxState()); + switchState(FlxState.new); Assert.areEqual(FlxG.cameras.defaults, FlxCamera._defaultCameras); } diff --git a/tests/unit/src/flixel/FlxObjectTest.hx b/tests/unit/src/flixel/FlxObjectTest.hx index 6fe89c7865..dc89530222 100644 --- a/tests/unit/src/flixel/FlxObjectTest.hx +++ b/tests/unit/src/flixel/FlxObjectTest.hx @@ -245,7 +245,7 @@ class FlxObjectTest extends FlxTest function velocityCollidingWith(ground:FlxObject) { - switchState(new CollisionState()); + switchState(CollisionState.new); ground.setPosition(0, 10); object1.setSize(10, 10); diff --git a/tests/unit/src/flixel/FlxStateTest.hx b/tests/unit/src/flixel/FlxStateTest.hx index 0bf2d46a0d..5f81512a98 100644 --- a/tests/unit/src/flixel/FlxStateTest.hx +++ b/tests/unit/src/flixel/FlxStateTest.hx @@ -16,15 +16,6 @@ class FlxStateTest extends FlxTest @Ignore // TODO: investigate function testSwitchState() { - final state = new FlxState(); - - Assert.areNotEqual(state, FlxG.state); - switchState(state); - Assert.areEqual(state, FlxG.state); - - // Make sure this compiles - switchState(FlxState.new); - var nextState:FlxState = null; function createState() { @@ -37,19 +28,20 @@ class FlxStateTest extends FlxTest } @Test - function testResetStateInstance() + @:haxe.warning("-WDeprecated") + function testResetStateLegacy() { - var state = new TestState(); - switchState(state); + switchState(TestState.new); + var state = FlxG.state; Assert.areEqual(state, FlxG.state); resetState(); Assert.areNotEqual(state, FlxG.state); - Assert.isTrue((FlxG.state is TestState)); + Assert.isTrue(FlxG.state is TestState); } @Test - function testResetStateFunction() + function testResetState() { var nextState:TestState = null; function createState() @@ -68,28 +60,11 @@ class FlxStateTest extends FlxTest } @Test // #1676 - function testCancelStateSwitchInstance() - { - var finalState = new FinalStateLegacy(); - switchState(finalState); - Assert.areEqual(finalState, FlxG.state); - - switchState(new FlxState()); - Assert.areEqual(finalState, FlxG.state); - - resetState(); - Assert.areEqual(finalState, FlxG.state); - } - - @Test // #1676 - function testCancelStateSwitchFunction() + function testCancelStateSwitch() { switchState(FinalState.new); final finalState = FlxG.state; - switchState(new FlxState()); - Assert.areEqual(finalState, FlxG.state); - switchState(FlxState.new); Assert.areEqual(finalState, FlxG.state); @@ -100,27 +75,15 @@ class FlxStateTest extends FlxTest @Test function testOutro() { - var outroState = new OutroState(); - - FlxG.switchState(outroState); + FlxG.switchState(OutroState.new); step(); - Assert.areEqual(outroState, FlxG.state); + Assert.isType(FlxG.state, OutroState); - FlxG.switchState(new FlxState()); + FlxG.switchState(FlxState.new); step(); - Assert.areEqual(outroState, FlxG.state); + Assert.isType(FlxG.state, OutroState); step(); - Assert.areNotEqual(outroState, FlxG.state); - - } -} - -class FinalStateLegacy extends FlxState -{ - /* prevents state switches */ - override function switchTo(state) - { - return false; + Assert.isNotType(FlxG.state, OutroState); } } diff --git a/tests/unit/src/flixel/FlxSubStateTest.hx b/tests/unit/src/flixel/FlxSubStateTest.hx index af0389574a..acc26c9a96 100644 --- a/tests/unit/src/flixel/FlxSubStateTest.hx +++ b/tests/unit/src/flixel/FlxSubStateTest.hx @@ -41,28 +41,25 @@ class FlxSubStateTest extends FlxTest @Test // #1971 function testOpenPersistentSubStateFromNewParent() { - var state1 = new FlxState(); - var state2 = new FlxState(); - state1.destroySubStates = false; - FlxG.switchState(state1); + FlxG.switchState(FlxStateNoDestroySubState.new.bind(false)); step(); FlxG.state.openSubState(subState1); step(); - Assert.areEqual(state1.subState, subState1); + Assert.areEqual(FlxG.state.subState, subState1); subState1.close(); step(); - Assert.isNull(state1.subState); + Assert.isNull(FlxG.state.subState); - FlxG.switchState(state2); + FlxG.switchState(FlxStateNoDestroySubState.new.bind(true)); step(); FlxG.state.openSubState(subState1); step(); - Assert.areEqual(state2.subState, subState1); + Assert.areEqual(FlxG.state.subState, subState1); subState1.close(); step(); - Assert.isNull(state2.subState); + Assert.isNull(FlxG.state.subState); } @Test // #2023 @@ -87,3 +84,12 @@ class FlxSubStateTest extends FlxTest Assert.isTrue(closed); } } + +class FlxStateNoDestroySubState extends FlxState +{ + public function new (destroySubStates) + { + super(); + this.destroySubStates = destroySubStates; + } +} \ No newline at end of file diff --git a/tests/unit/src/flixel/group/FlxSpriteGroupTest.hx b/tests/unit/src/flixel/group/FlxSpriteGroupTest.hx index 16a7e3d9e3..7d6db410bb 100644 --- a/tests/unit/src/flixel/group/FlxSpriteGroupTest.hx +++ b/tests/unit/src/flixel/group/FlxSpriteGroupTest.hx @@ -165,6 +165,33 @@ class FlxSpriteGroupTest extends FlxTest Assert.areEqual(cams, member1.cameras); Assert.areEqual(cams, member2.cameras); } + @Test + /** + * Ensure that member origins are correctly set when + * the group origin is set. + */ + function testOriginTransform() + { + var f1 = new FlxSprite(-10, 100); + var f2 = new FlxSprite(50, 50); + group.add(f1); + group.add(f2); + + group.setPosition(280, 300); + group.origin.set(300, 400); + + // Verify positions are updated - absolute + Assert.areEqual(270, f1.x); + Assert.areEqual(400, f1.y); + Assert.areEqual(330, f2.x); + Assert.areEqual(350, f2.y); + + // Verify origins are correct - relative + Assert.areEqual(310, f1.origin.x); + Assert.areEqual(300, f1.origin.y); + Assert.areEqual(250, f2.origin.x); + Assert.areEqual(350, f2.origin.y); + } } class Member extends FlxSprite diff --git a/tests/unit/src/flixel/system/replay/FlxReplayTest.hx b/tests/unit/src/flixel/system/replay/FlxReplayTest.hx index 094465c074..59e953a59b 100644 --- a/tests/unit/src/flixel/system/replay/FlxReplayTest.hx +++ b/tests/unit/src/flixel/system/replay/FlxReplayTest.hx @@ -90,12 +90,11 @@ class FlxReplayTest extends FlxTest createFrameRecord(3, JUST_RELEASED) ]; var recording = frames.map(function(r) return r.save()).join("\n"); - var state = new ReplayState(); - FlxG.vcr.loadReplay(recording, state); + FlxG.vcr.loadReplay(recording, ReplayState.new); step(10); - Assert.isTrue(state.called); + Assert.isTrue((cast FlxG.state:ReplayState).called); } function createFrameRecord(i:Int, mouseState:FlxInputState):FrameRecord