Skip to content

Commit

Permalink
release 4.11.0 to master (#2491)
Browse files Browse the repository at this point in the history
* Enable workflow_dispatch

* Fixing little error for android build (#2407)

* Explain FlxG singletons in input util docs (#2411)

* Mention color in docs for FlxBitmapFont.fromMonospace (#2412)

This makes it a little more clear that if you're loading a FlxBitmapFont from a monospace font file that you wish to change the color of, ensure the pixels are white. This allows the textColor property to work as expected. If the pixels happen to be black, the textColor changes won't be visible.

* redraw sprite before `updateHitbox()`. fixes #2413 (#2417)

* Remove references to FlxObject direction flag constants (#2424)

* fix: image showcase link (#2438)

* Fixed spelling in comment in FlxBasePreloader (#2447)

* Update documentation on scale modes. (#2455)

* Update license link (#2464)

* remove redundant modifier (#2467)

* Fix CI

* Add FlxAnimationController.getNamesList() to get the current list of animation names (#2473)

* Add the list thing

* Oops, beta description

* Kinda a fix?

* Experimental stuff with setting new names lol

* Adds a more safe option in case you don't complete the entire thing

* remove the variable and add the functions

* change some minor stuff

* remove the last _list things

* Update FlxAnimationController.hx

* Idk if it works but maybe the checks are failing cos of that?

* Add a nicer code and description stuff

* add tests, and small corrections

* Add the rename test on FlxAnimationControllertest

Co-authored-by: George FunBook <[email protected]>

* fix typo in unit tests

* Add getRotatedRectBounds helpers (#2298)

* `FlxRect.getRotatedBounds`
* `FlxObject.getRotatedBounds`
* `FlxSprite.getRotatedBounds` - override
* `FlxSprite.getScreenBounds` - similar to `FlxSprite.getScreenPosition`
* `FlxSpriteUtil.cameraWrap` - similar to `FlxSpriteUtil.screenWrap` but uses FlxDirectionFlags instead of 4 booleans
* `FlxSpriteUtil.cameraBounds` - similar to `FlxSpriteUtil.cameraWrap`
* `FlxCamera.getViewRect` - helper for `FlxSpriteUtil.cameraWrap` and `cameraBound`
* `FlxCamera.containsRect`- helper for `FlxSpriteUtil.cameraWrap` and `cameraBound`
* `FlxCollision.pixelPerfectCheck` - uses getScreenBounds to reduce the number of pixel checks, honors FlxSprite's scale
* `FlxSprite.isOnScreen` - uses getScreenBounds for more accuracy
* `FlxCamera.containsPoint` - calls putWeak

* ignore failing test for now

* sceenCenter Readibility (#2441)

* add screenCenter test

* improve readability of screenCenter

* add check with no parameters

* inline screenCenter

* update FlxState comment on constructor

* Prevent hashlink segfaults on linux (#2487)

* change integers used for ANY and NONE FlxKey <REVERTED>

* add FlxKey tests for ANY/NONE

* remove switch causing seg faults

Co-authored-by: jf <[email protected]>
Co-authored-by: George FunBook <[email protected]>

* call members' kill/revive when called on sprite groups (#2423)

* call members' kill/revive when called on sprite groups

* make sure kill/revive is NOT called when not needed

* fix spriteGroup.reset()

* minimize setters

* add resetTest

* remove haxe4 compile conditions (#2489)

* Release 4.11.0 (#2490)

* add release notes

* seg fault bugfix

* FlxSpriteGroup kill/revive

* change haxelib

* wording

* change date

Co-authored-by: Jens Fischer <[email protected]>
Co-authored-by: Gliar <[email protected]>
Co-authored-by: Brett Chalupa <[email protected]>
Co-authored-by: Julian Holfeld <[email protected]>
Co-authored-by: RafPlayz69YT <[email protected]>
Co-authored-by: Eric Myllyoja <[email protected]>
Co-authored-by: MrClogsworthYT <[email protected]>
Co-authored-by: MrCheemsAndFriends <[email protected]>
Co-authored-by: jobf <[email protected]>
Co-authored-by: jf <[email protected]>
  • Loading branch information
11 people authored Jan 26, 2022
1 parent 5b5277e commit 30bc3a4
Show file tree
Hide file tree
Showing 47 changed files with 958 additions and 250 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: CI
on:
push:
pull_request:
workflow_dispatch:
repository_dispatch:
schedule:
- cron: '0 4 * * *'
Expand All @@ -11,7 +12,7 @@ jobs:
build:
strategy:
matrix:
haxe-version: ["3.4.7", stable, nightly]
haxe-version: ["4.0.5", stable, nightly]
target: [html5, hl, neko, flash, cpp]
fail-fast: false
runs-on: ubuntu-latest
Expand Down
29 changes: 29 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,32 @@

4.11.0 (January 26, 2022)
------------------------------
#### Dependencies:

- Dropped support for haxe 3, use 4.0.5 or higher

#### New features:

- `FlxAnimationController`: added `getAnimationList`, `getNameList`, `exists` and `rename` ([#2473](https://github.com/HaxeFlixel/flixel/pull/2473))
- `FlxRect`: added `getRotatedBounds` ([#2298](https://github.com/HaxeFlixel/flixel/pull/2298))
- `FlxObject`: added `getRotatedBounds` ([#2298](https://github.com/HaxeFlixel/flixel/pull/2298))
- `FlxSprite`: added `getScreenBounds` ([#2298](https://github.com/HaxeFlixel/flixel/pull/2298))
- `FlxSpriteUtil`: added `cameraWrap` and `cameraBounds` ([#2298](https://github.com/HaxeFlixel/flixel/pull/2298))
- `FlxCamera`: added `getViewRect` and `containsRect` ([#2298](https://github.com/HaxeFlixel/flixel/pull/2298))

#### Bugfixes:

- Fixed segmentation faults on Hashlink for linux ([#2487](https://github.com/HaxeFlixel/flixel/pull/2487))
- `FlxSpriteGroup`: `kill`, `revive` and `revive` call the respective function on members ([#2423](https://github.com/HaxeFlixel/flixel/pull/2423))

#### Changes and improvements:

- `FlxCollision`: improved `pixelPerfectCheck` performance, now honors scale ([#2298](https://github.com/HaxeFlixel/flixel/pull/2298))
- `FlxSprite`: improved `isOnScreen` accuracy ([#2298](https://github.com/HaxeFlixel/flixel/pull/2298))
- `FlxCamera`: added `putWeak` call in `containsPoint` ([#2298](https://github.com/HaxeFlixel/flixel/pull/2298))
- `FlxObject`: `screenCenter` defaults to `XY` rather than `null` ([#2441](https://github.com/HaxeFlixel/flixel/pull/2441))
- `FlxState`: Clarify restrictions in state constructors ([#2479](https://github.com/HaxeFlixel/flixel/pull/2479))

4.10.0 (September 12, 2021)
------------------------------
#### New features:
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Copyright (c) 2009 Adam 'Atomic' Saltsman <br>
Copyright (c) 2012 Matt Tuttle <br>
Copyright (c) 2013 [HaxeFlixel Team](https://github.com/HaxeFlixel?tab=members)
Copyright (c) 2013 [HaxeFlixel Team](https://github.com/orgs/HaxeFlixel/people)

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
[![Haxelib License](https://badgen.net/haxelib/license/flixel)](LICENSE.md)
[![Patreon](https://img.shields.io/badge/donate-patreon-blue.svg)](https://www.patreon.com/haxeflixel)

[![](images/showcase.png)](http://www.haxeflixel.com/showcase)
[![](images/showcase.png)](https://haxeflixel.com/showcase)

## Links

Expand Down
31 changes: 29 additions & 2 deletions flixel/FlxCamera.hx
Original file line number Diff line number Diff line change
Expand Up @@ -1745,15 +1745,42 @@ class FlxCamera extends FlxBasic
updateFlashOffset();
setScale(scaleX, scaleY);
}


/**
* The size and position of this camera's screen
* @since 4.11.0
*/
public function getViewRect(?rect:FlxRect)
{
if (rect == null)
rect = FlxRect.get();

return rect.set(viewOffsetX, viewOffsetY, viewOffsetWidth - viewOffsetX, viewOffsetHeight - viewOffsetY);
}

/**
* Checks whether this camera contains a given point or rectangle, in
* screen coordinates.
* @since 4.3.0
*/
public inline function containsPoint(point:FlxPoint, width:Float = 0, height:Float = 0):Bool
{
return (point.x + width > viewOffsetX) && (point.x < viewOffsetWidth) && (point.y + height > viewOffsetY) && (point.y < viewOffsetHeight);
var contained = (point.x + width > viewOffsetX) && (point.x < viewOffsetWidth)
&& (point.y + height > viewOffsetY) && (point.y < viewOffsetHeight);
point.putWeak();
return contained;
}

/**
* Checks whether this camera contains a given rectangle, in screen coordinates.
* @since 4.11.0
*/
public inline function containsRect(rect:FlxRect):Bool
{
var contained = (rect.right > viewOffsetX) && (rect.x < viewOffsetWidth)
&& (rect.bottom > viewOffsetY) && (rect.y < viewOffsetHeight);
rect.putWeak();
return contained;
}

function set_followLerp(Value:Float):Float
Expand Down
6 changes: 4 additions & 2 deletions flixel/FlxG.hx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class FlxG
* The HaxeFlixel version, in semantic versioning syntax. Use `Std.string()`
* on it to get a `String` formatted like this: `"HaxeFlixel MAJOR.MINOR.PATCH-COMMIT_SHA"`.
*/
public static var VERSION(default, null):FlxVersion = new FlxVersion(4, 10, 0);
public static var VERSION(default, null):FlxVersion = new FlxVersion(4, 11, 0);

/**
* Internal tracker for game object.
Expand Down Expand Up @@ -172,7 +172,9 @@ class FlxG
public static var height(default, null):Int;

/**
* The scale mode the game should use - available policies are found in `flixel.system.scaleModes`.
* The scale mode the game should use.
* HaxeFlixel includes several available scale modes, which are located in `flixel.system.scaleModes`.
* However, you may also create a class which extends `BaseScaleMode`, and override its behavior according to your needs.
*/
public static var scaleMode(default, set):BaseScaleMode = new RatioScaleMode();

Expand Down
32 changes: 24 additions & 8 deletions flixel/FlxObject.hx
Original file line number Diff line number Diff line change
Expand Up @@ -1064,18 +1064,16 @@ class FlxObject extends FlxBasic
/**
* Centers this `FlxObject` on the screen, either by the x axis, y axis, or both.
*
* @param axes On what axes to center the object - default is `FlxAxes.XY` / both.
* @param axes On what axes to center the object (e.g. `X`, `Y`, `XY`) - default is both.
* @return This FlxObject for chaining
*/
public function screenCenter(?axes:FlxAxes):FlxObject
public inline function screenCenter(axes:FlxAxes = XY):FlxObject
{
if (axes == null)
axes = FlxAxes.XY;
if (axes.match(X | XY))
x = (FlxG.width - width) / 2;

if (axes != FlxAxes.Y)
x = (FlxG.width / 2) - (width / 2);
if (axes != FlxAxes.X)
y = (FlxG.height / 2) - (height / 2);
if (axes.match(Y | XY))
y = (FlxG.height - height) / 2;

return this;
}
Expand Down Expand Up @@ -1193,6 +1191,24 @@ class FlxObject extends FlxBasic

return _rect;
}

/**
* Calculates the smallest globally aligned bounding box that encompasses this
* object's width and height, at its current rotation.
* Note, if called on a `FlxSprite`, the origin is used, but scale and offset are ignored.
* Use `getScreenBounds` to use these properties.
* @param newRect The optional output `FlxRect` to be returned, if `null`, a new one is created.
* @return A globally aligned `FlxRect` that fully contains the input object's width and height.
* @since 4.11.0
*/
public function getRotatedBounds(?newRect:FlxRect)
{
if (newRect == null)
newRect = FlxRect.get();

newRect.set(x, y, width, height);
return newRect.getRotatedBounds(angle, null, newRect);
}

/**
* Convert object to readable string name. Useful for debugging, save games, etc.
Expand Down
95 changes: 51 additions & 44 deletions flixel/FlxSprite.hx
Original file line number Diff line number Diff line change
Expand Up @@ -1000,51 +1000,12 @@ class FlxSprite extends FlxObject
* @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 public function isOnScreen(?camera:FlxCamera):Bool
{
if (Camera == null)
Camera = FlxG.camera;

var minX:Float = x - offset.x - Camera.scroll.x * scrollFactor.x;
var minY:Float = y - offset.y - Camera.scroll.y * scrollFactor.y;

if ((angle == 0 || bakedRotationAngle > 0) && (scale.x == 1) && (scale.y == 1))
{
_point.set(minX, minY);
return Camera.containsPoint(_point, frameWidth, frameHeight);
}

var radiusX:Float = _halfSize.x;
var radiusY:Float = _halfSize.y;

var ox:Float = origin.x;
if (ox != radiusX)
{
var x1:Float = Math.abs(ox);
var x2:Float = Math.abs(frameWidth - ox);
radiusX = Math.max(x2, x1);
}

var oy:Float = origin.y;
if (oy != radiusY)
{
var y1:Float = Math.abs(oy);
var y2:Float = Math.abs(frameHeight - oy);
radiusY = Math.max(y2, y1);
}

radiusX *= Math.abs(scale.x);
radiusY *= Math.abs(scale.y);
var radius:Float = Math.max(radiusX, radiusY);
radius *= FlxMath.SQUARE_ROOT_OF_TWO;

minX += ox - radius;
minY += oy - radius;

var doubleRadius:Float = 2 * radius;

_point.set(minX, minY);
return Camera.containsPoint(_point, doubleRadius, doubleRadius);
if (camera == null)
camera = FlxG.camera;

return camera.containsRect(getScreenBounds(_rect, camera));
}

/**
Expand Down Expand Up @@ -1074,6 +1035,52 @@ class FlxSprite extends FlxObject
return result;
}

/**
* Calculates the smallest globally aligned bounding box that encompasses this
* sprite's width and height, at its current rotation.
* Note, if called on a `FlxSprite`, the origin is used, but scale and offset are ignored.
* Use `getScreenBounds` to use these properties.
* @param newRect The optional output `FlxRect` to be returned, if `null`, a new one is created.
* @return A globally aligned `FlxRect` that fully contains the input object's width and height.
* @since 4.11.0
*/
override function getRotatedBounds(?newRect:FlxRect)
{
if (newRect == null)
newRect = FlxRect.get();

newRect.set(x, y, width, height);
return newRect.getRotatedBounds(angle, origin, newRect);
}

/**
* 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.
* @return A globally aligned `FlxRect` that fully contains the input sprite.
* @since 4.11.0
*/
public function getScreenBounds(?newRect:FlxRect, ?camera:FlxCamera):FlxRect
{
if (newRect == null)
newRect = FlxRect.get();

if (camera == null)
camera = FlxG.camera;

newRect.setPosition(x, y);
if (pixelPerfectPosition)
newRect.floor();
var scaledOrigin = FlxPoint.weak(origin.x * scale.x, origin.y * scale.y);
newRect.x += -Std.int(camera.scroll.x * scrollFactor.x) - offset.x + origin.x - scaledOrigin.x;
newRect.y += -Std.int(camera.scroll.y * scrollFactor.y) - offset.y + origin.y - scaledOrigin.y;
if (isPixelPerfectRender(camera))
newRect.floor();
newRect.setSize(frameWidth * Math.abs(scale.x), frameHeight * Math.abs(scale.y));
return newRect.getRotatedBounds(angle, scaledOrigin, newRect);
}

/**
* Set how a sprite flips when facing in a particular direction.
*
Expand Down
3 changes: 2 additions & 1 deletion flixel/FlxState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ class FlxState extends FlxGroup
/**
* This function is called after the game engine successfully switches states.
* Override this function, NOT the constructor, to initialize or set up your game state.
* We do NOT recommend overriding the constructor, unless you want some crazy unpredictable things to happen!
* We do NOT recommend initializing any flixel objects or utilizing flixel features in
* the constructor, unless you want some crazy unpredictable things to happen!
*/
public function create():Void {}

Expand Down
72 changes: 64 additions & 8 deletions flixel/animation/FlxAnimationController.hx
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,13 @@ class FlxAnimationController implements IFlxDestroyable
* If assigned, will be called each time the current animation's frame changes.
* A function that has 3 parameters: a string name, a frame number, and a frame index.
*/
#if haxe4
public var callback:(name:String, frameNumber:Int, frameIndex:Int) -> Void;
#else
public var callback:String->Int->Int->Void;
#end

/**
* If assigned, will be called each time the current animation finishes.
* A function that has 1 parameter: a string name - animation name.
*/
#if haxe4
public var finishCallback:(name:String) -> Void;
#else
public var finishCallback:String->Void;
#end

/**
* Internal, reference to owner sprite.
Expand Down Expand Up @@ -778,6 +770,70 @@ class FlxAnimationController implements IFlxDestroyable
return AnimName;
}

/**
* Gets a list with all the animations that are added in a sprite.
* WARNING: Do not confuse with `getNameList`, this function returns the animation instances
* @return an array with all the animations.
* @since 4.11.0
*/
public function getAnimationList():Array<FlxAnimation>
{
var animList:Array<FlxAnimation> = [];

for (anims in _animations)
{
animList.push(anims);
}

return animList;
}

/**
* Gets a list with all the name animations that are added in a sprite
* WARNING: Do not confuse with `getAnimationList`, this function returns the animation names
* @return an array with all the animation names in it.
* @since 4.11.0
*/
public function getNameList():Array<String>
{
var namesList:Array<String> = [];
for (names in _animations.keys())
{
namesList.push(names);
}

return namesList;
}

/**
* Checks if an animation exists by it's name.
* @param name The animation name.
* @since 4.11.0
*/
public function exists(name:String):Bool
{
return _animations.exists(name);
}

/**
* Renames the animation with a new name.
* @param oldName the name that is replaced.
* @param newName the name that replaces the old one.
* @since 4.11.0
*/
public function rename(oldName:String, newName:String)
{
var anim = _animations.get(oldName);
if (anim == null)
{
FlxG.log.warn('No animation called "$oldName"');
return;
}
_animations.set(newName, anim);
anim.name = newName;
_animations.remove(oldName);
}

inline function get_curAnim():FlxAnimation
{
return _curAnim;
Expand Down
Loading

0 comments on commit 30bc3a4

Please sign in to comment.