From 5bdae7e96d8e4bfb0104c1782bacd5a2d79d3178 Mon Sep 17 00:00:00 2001 From: DalekCraft <50336832+DalekCraft2@users.noreply.github.com> Date: Tue, 14 Mar 2023 13:52:55 -0400 Subject: [PATCH 01/69] Correct some mistakes with parameters in doc comments (#376) * Correct some mistakes with parameters in doc comments Also removed redundant instances of "returns" from "@return" tags. * Revert formatting on FlxBackdrop.hx * Add two missing parameter descriptions * Revert formatting on FlxSliceSprite.hx I'm reluctant to revert this one because it's just unnecessary whitespace, but I won't argue. * Update FlxTileSpecial.hx * Use camelCase for function arguments in FlxControlHandler.hx I went overboard. Hopefully, George will not mind. * Add a few more missing parameter/return descriptions --- flixel/addons/api/FlxGameJolt.hx | 6 +- flixel/addons/display/FlxSliceSprite.hx | 2 +- flixel/addons/display/shapes/FlxShape.hx | 2 +- flixel/addons/display/shapes/FlxShapeLine.hx | 4 +- flixel/addons/editors/spine/FlxSpine.hx | 22 +- .../addons/editors/tiled/TiledGroupLayer.hx | 12 +- flixel/addons/effects/FlxClothSprite.hx | 13 +- .../effects/chainable/FlxEffectSprite.hx | 2 +- .../effects/chainable/FlxOutlineEffect.hx | 2 +- .../effects/chainable/FlxTrailEffect.hx | 1 + flixel/addons/nape/FlxNapeSprite.hx | 2 +- flixel/addons/nape/FlxNapeVelocity.hx | 1 + flixel/addons/plugin/FlxScrollingText.hx | 4 +- flixel/addons/plugin/control/FlxControl.hx | 3 +- .../plugin/control/FlxControlHandler.hx | 497 +++++++++--------- .../addons/plugin/screengrab/FlxScreenGrab.hx | 4 +- .../plugin/taskManager/FlxTaskManager.hx | 6 +- flixel/addons/text/FlxTextField.hx | 1 + flixel/addons/text/FlxTypeText.hx | 1 - flixel/addons/tile/FlxCaveGenerator.hx | 4 +- flixel/addons/tile/FlxRayCastTilemap.hx | 2 +- flixel/addons/tile/FlxTileSpecial.hx | 3 +- flixel/addons/tile/FlxTilemapExt.hx | 4 +- flixel/addons/util/FlxFSM.hx | 59 ++- flixel/addons/util/FlxScene.hx | 18 +- flixel/addons/weapon/FlxWeapon.hx | 15 +- include.xml | 4 +- 27 files changed, 350 insertions(+), 344 deletions(-) diff --git a/flixel/addons/api/FlxGameJolt.hx b/flixel/addons/api/FlxGameJolt.hx index e3b61f63..a480353e 100644 --- a/flixel/addons/api/FlxGameJolt.hx +++ b/flixel/addons/api/FlxGameJolt.hx @@ -166,7 +166,7 @@ class FlxGameJolt /** * A string map that contains what is returned from GameJolt servers. - */ + */ static var returnMap:Map = new Map(); /** @@ -431,7 +431,7 @@ class FlxGameJolt * @see https://gamejolt.com/api/doc/game/scores/fetch/ * @param Limit The maximum number of scores to retrieve. If blank to retrieve only this user's scores. * @param TableID The ID of the table you want to pull data from. Leave blank to fetch from the primary score table. - * @param CallBack An optional callback function. Will return a Map whose keys and values are equivalent to the key-value pairs returned by GameJolt. + * @param Callback An optional callback function. Will return a Map whose keys and values are equivalent to the key-value pairs returned by GameJolt. */ public static function fetchScore(?Limit:Int, ?TableID:Int, ?Callback:Dynamic):Void { @@ -714,7 +714,7 @@ class FlxGameJolt * However, if we're getting an image, a second URLRequest is called, and that will be done first. * Or, if we're authenticating the user, the verifyAuthentication function will be called instead. * - * @param The URLLoader complete event. + * @param e The URLLoader complete event. */ static function parseData(e:Event):Void { diff --git a/flixel/addons/display/FlxSliceSprite.hx b/flixel/addons/display/FlxSliceSprite.hx index 8fee1ff9..24dfbe1e 100644 --- a/flixel/addons/display/FlxSliceSprite.hx +++ b/flixel/addons/display/FlxSliceSprite.hx @@ -672,4 +672,4 @@ class FlxSliceSprite extends FlxStrip return _snappedHeight; } -} +} \ No newline at end of file diff --git a/flixel/addons/display/shapes/FlxShape.hx b/flixel/addons/display/shapes/FlxShape.hx index 31b5308a..b2276df3 100644 --- a/flixel/addons/display/shapes/FlxShape.hx +++ b/flixel/addons/display/shapes/FlxShape.hx @@ -32,7 +32,7 @@ class FlxShape extends FlxSprite * @param Y Y location * @param CanvasWidth Width of pixel canvas * @param CanvasHeight Height of pixel canvas - * @param LineStyle_ Drawing style for strokes -- see flixel.util.FlxSpriteUtil.LineStyle + * @param LineStyle_ Drawing style for strokes -- see `flixel.util.FlxSpriteUtil.LineStyle` * @param FillColor Color of the fill. FlxColor.TRANSPARENT means no fill. * @param TrueWidth Width of raw unstyled geometric object, ignoring line thickness, filters, etc * @param TrueHeight Height of raw unstyled geometric object, ignoring line thickness, filters, etc diff --git a/flixel/addons/display/shapes/FlxShapeLine.hx b/flixel/addons/display/shapes/FlxShapeLine.hx index c6d2b699..762d0fa0 100644 --- a/flixel/addons/display/shapes/FlxShapeLine.hx +++ b/flixel/addons/display/shapes/FlxShapeLine.hx @@ -4,8 +4,8 @@ import flash.geom.Matrix; import flixel.math.FlxPoint; import flixel.util.FlxColor; import flixel.util.FlxDestroyUtil; -import flixel.util.FlxSpriteUtil; import flixel.util.FlxSpriteUtil.LineStyle; +import flixel.util.FlxSpriteUtil; class FlxShapeLine extends FlxShape { @@ -20,7 +20,7 @@ class FlxShapeLine extends FlxShape * @param Y y position of the canvas * @param a first point in the line (relative to the sprite's origin) * @param b second point in the line (relative to the sprite's origin) - * @param LineStyle_ + * @param LineStyle_ Drawing style for strokes -- see `flixel.util.FlxSpriteUtil.LineStyle` */ public function new(X:Float, Y:Float, a:FlxPoint, b:FlxPoint, LineStyle_:LineStyle) { diff --git a/flixel/addons/editors/spine/FlxSpine.hx b/flixel/addons/editors/spine/FlxSpine.hx index 3e751aa7..bd95dcd2 100644 --- a/flixel/addons/editors/spine/FlxSpine.hx +++ b/flixel/addons/editors/spine/FlxSpine.hx @@ -1,11 +1,11 @@ package flixel.addons.editors.spine; -import flixel.addons.editors.spine.texture.FlixelTextureLoader; import flixel.FlxCamera; import flixel.FlxG; import flixel.FlxObject; import flixel.FlxSprite; import flixel.FlxStrip; +import flixel.addons.editors.spine.texture.FlixelTextureLoader; import flixel.graphics.FlxGraphic; import flixel.graphics.frames.FlxAtlasFrames; import flixel.graphics.frames.FlxImageFrame; @@ -17,25 +17,25 @@ import flixel.math.FlxRect; import flixel.util.FlxColor; import flixel.util.FlxDestroyUtil; import haxe.ds.ObjectMap; -import openfl.display.Graphics; -import openfl.display.Sprite; import openfl.Assets; +import openfl.Vector; import openfl.display.BitmapData; import openfl.display.BlendMode; -import openfl.Vector; +import openfl.display.Graphics; +import openfl.display.Sprite; +import spinehaxe.Bone; +import spinehaxe.Skeleton; +import spinehaxe.SkeletonData; +import spinehaxe.SkeletonJson; +import spinehaxe.Slot; import spinehaxe.animation.AnimationState; import spinehaxe.animation.AnimationStateData; import spinehaxe.atlas.Atlas; import spinehaxe.atlas.AtlasRegion; +import spinehaxe.attachments.AtlasAttachmentLoader; import spinehaxe.attachments.Attachment; import spinehaxe.attachments.MeshAttachment; import spinehaxe.attachments.RegionAttachment; -import spinehaxe.attachments.AtlasAttachmentLoader; -import spinehaxe.Bone; -import spinehaxe.Skeleton; -import spinehaxe.SkeletonData; -import spinehaxe.SkeletonJson; -import spinehaxe.Slot; /** * A Sprite that can play animations exported by Spine (http://esotericsoftware.com/) @@ -93,6 +93,8 @@ class FlxSpine extends FlxSprite * @param Y The initial Y position of the sprite. * @param Width The maximum width of this sprite (avoid very large sprites since they are performance intensive). * @param Height The maximum height of this sprite (avoid very large sprites since they are performance intensive). + * @param OffsetX The X offset of the sprite. + * @param OffsetY The Y offset of the sprite. * @param renderMeshes If true, then graphic will be rendered with drawTriangles(), if false (by default), then it will be rendered with drawTiles(). */ public function new(skeletonData:SkeletonData, X:Float = 0, Y:Float = 0, Width:Float = 0, Height:Float = 0, OffsetX:Float = 0, OffsetY:Float = 0, diff --git a/flixel/addons/editors/tiled/TiledGroupLayer.hx b/flixel/addons/editors/tiled/TiledGroupLayer.hx index b9ccb83f..c803a04f 100644 --- a/flixel/addons/editors/tiled/TiledGroupLayer.hx +++ b/flixel/addons/editors/tiled/TiledGroupLayer.hx @@ -2,7 +2,6 @@ package flixel.addons.editors.tiled; import flixel.addons.editors.tiled.TiledLayer.TiledLayerType; import flixel.util.FlxColor; - #if haxe4 import haxe.xml.Access; #else @@ -17,8 +16,9 @@ import haxe.xml.Fast as Access; class TiledGroupLayer extends TiledLayer { public var layers:Array = []; + var layerMap:Map = new Map(); - + public function new(source:Access, parent:TiledMap, noLoadHash:Map) { super(source, parent); @@ -29,10 +29,10 @@ class TiledGroupLayer extends TiledLayer function loadLayers(source:Access, parent:TiledMap, noLoadHash:Map):Void { for (el in source.elements) - { + { if (el.has.name && noLoadHash.exists(el.att.name)) continue; - + var layer:TiledLayer = switch (el.name.toLowerCase()) { case "group": new TiledGroupLayer(el, parent, noLoadHash); @@ -41,7 +41,7 @@ class TiledGroupLayer extends TiledLayer case "imagelayer": new TiledImageLayer(el, parent); case _: null; } - + if (layer != null) { layers.push(layer); @@ -51,7 +51,7 @@ class TiledGroupLayer extends TiledLayer } public function getLayer(name:String):TiledLayer - { + { return layerMap.get(name); } } diff --git a/flixel/addons/effects/FlxClothSprite.hx b/flixel/addons/effects/FlxClothSprite.hx index e678d590..6cb07bf8 100644 --- a/flixel/addons/effects/FlxClothSprite.hx +++ b/flixel/addons/effects/FlxClothSprite.hx @@ -109,12 +109,13 @@ class FlxClothSprite extends FlxSprite * Creates a FlxClothSprite at a specified position with a specified one-frame graphic. * If none is provided, a 16x16 image of the HaxeFlixel logo is used. * - * @param X The initial X position of the sprite. - * @param Y The initial Y position of the sprite. - * @param SimpleGraphic The graphic you want to display (OPTIONAL - for simple stuff only, do NOT use for animated images!). - * @param Columns Number of columns of the created mesh. - * @param Rows Number of rows of the created mesh. - * @param PinnedSide The pinned side that points are not affected by wind or velocity. Use UP, DOWN, LEFT, RIGHT, NONE, ANY, etc. + * @param X The initial X position of the sprite. + * @param Y The initial Y position of the sprite. + * @param SimpleGraphic The graphic you want to display (OPTIONAL - for simple stuff only, do NOT use for animated images!). + * @param Columns Number of columns of the created mesh. + * @param Rows Number of rows of the created mesh. + * @param PinnedSide The pinned side that points are not affected by wind or velocity. Use UP, DOWN, LEFT, RIGHT, NONE, ANY, etc. + * @param CrossingConstraints Whether to add two extra constraints crossing the squares to make the mesh more rigid. Defaults to false. */ public function new(?X:Float = 0, ?Y:Float = 0, ?SimpleGraphic:FlxGraphicAsset, Columns:Int = 0, Rows:Int = 0, PinnedSide:FlxDirectionFlags = UP, CrossingConstraints:Bool = false) diff --git a/flixel/addons/effects/chainable/FlxEffectSprite.hx b/flixel/addons/effects/chainable/FlxEffectSprite.hx index a91ec266..72d42d7d 100644 --- a/flixel/addons/effects/chainable/FlxEffectSprite.hx +++ b/flixel/addons/effects/chainable/FlxEffectSprite.hx @@ -76,7 +76,7 @@ class FlxEffectSprite extends FlxSprite /** * Call this function to figure out the on-screen position of the object. * - * @param Point Takes a FlxPoint object and assigns the post-scrolled X and Y values of this object to it. + * @param point Takes a FlxPoint object and assigns the post-scrolled X and Y values of this object to it. * @param Camera Specify which game camera you want. If null getScreenPosition() will just grab the first global camera. * @return The Point you passed in, or a new Point if you didn't pass one, containing the screen X and Y position of this object. */ diff --git a/flixel/addons/effects/chainable/FlxOutlineEffect.hx b/flixel/addons/effects/chainable/FlxOutlineEffect.hx index a948a3ed..e897a477 100644 --- a/flixel/addons/effects/chainable/FlxOutlineEffect.hx +++ b/flixel/addons/effects/chainable/FlxOutlineEffect.hx @@ -77,8 +77,8 @@ class FlxOutlineEffect implements IFlxEffect * @param Mode Which Mode you would like to use for the effect. FAST = Optimized using only 4 draw calls, NORMAL = Outline on all 8 sides, PIXEL_BY_PIXEL = Surround every pixel (can affect performance). * @param Color Color of the outline. * @param Thickness Outline thickness in pixels. - * @param Quality Outline quality - # of iterations to use when drawing. 0:just 1, 1:equal number to Thickness. Not used with PIXEL_BY_PIXEL mode. * @param Threshold Alpha sensitivity, only used with PIXEL_BY_PIXEL mode. + * @param Quality Outline quality - # of iterations to use when drawing. 0:just 1, 1:equal number to Thickness. Not used with PIXEL_BY_PIXEL mode. */ public function new(?Mode:FlxOutlineMode, Color:FlxColor = FlxColor.WHITE, Thickness:Int = 1, Threshold:Int = 0, Quality:Float = 1) { diff --git a/flixel/addons/effects/chainable/FlxTrailEffect.hx b/flixel/addons/effects/chainable/FlxTrailEffect.hx index 89cdce60..583f46d1 100644 --- a/flixel/addons/effects/chainable/FlxTrailEffect.hx +++ b/flixel/addons/effects/chainable/FlxTrailEffect.hx @@ -69,6 +69,7 @@ class FlxTrailEffect implements IFlxEffect /** * Creates a trail effect. * + * @param Target The FlxEffectSprite the trail is attached to. * @param Length The amount of trail images to create. * @param Alpha The alpha value for the first trailsprite. * @param FramesDelay How many frames wait until next trail updated. diff --git a/flixel/addons/nape/FlxNapeSprite.hx b/flixel/addons/nape/FlxNapeSprite.hx index a3264997..8af5d350 100644 --- a/flixel/addons/nape/FlxNapeSprite.hx +++ b/flixel/addons/nape/FlxNapeSprite.hx @@ -1,8 +1,8 @@ package flixel.addons.nape; import flixel.FlxSprite; -import flixel.system.FlxAssets; import flixel.math.FlxAngle; +import flixel.system.FlxAssets; import nape.geom.Vec2; import nape.phys.Body; import nape.phys.BodyType; diff --git a/flixel/addons/nape/FlxNapeVelocity.hx b/flixel/addons/nape/FlxNapeVelocity.hx index aadbc35e..2f2abbf4 100644 --- a/flixel/addons/nape/FlxNapeVelocity.hx +++ b/flixel/addons/nape/FlxNapeVelocity.hx @@ -46,6 +46,7 @@ class FlxNapeVelocity * Timings are approximate due to the way Flash timers work, and irrespective of SWF frame rate. Allow for a variance of +- 50ms. * The source object doesn't stop moving automatically should it ever reach the destination coordinates. * @param Source The FlxNapeSprite to move + * @param Touch The FlxTouch where the source object will move to * @param Speed The speed it will move, in pixels per second (default is 100 pixels/sec) */ public static inline function moveTowardsTouch(Source:FlxNapeSprite, Touch:FlxTouch, Speed:Float = 100):Void diff --git a/flixel/addons/plugin/FlxScrollingText.hx b/flixel/addons/plugin/FlxScrollingText.hx index 39091a1c..068c3c79 100644 --- a/flixel/addons/plugin/FlxScrollingText.hx +++ b/flixel/addons/plugin/FlxScrollingText.hx @@ -241,7 +241,7 @@ class FlxScrollingText extends FlxBasic * Note: If the text is set to only scroll when on-screen, but if off-screen when this is called, it will still return true. * * @param source The FlxSprite to check for scrolling on. - * @return Bool true is the FlxSprite was found and is scrolling, otherwise false + * @return True if the FlxSprite was found and is scrolling, otherwise false */ public static function isScrolling(source:FlxSprite):Bool { @@ -257,7 +257,7 @@ class FlxScrollingText extends FlxBasic * Removes an FlxSprite from the Text Scroller. Note that it doesn't restore the sprite bitmapData. * * @param source The FlxSprite to remove scrolling for. - * @return Bool true if the FlxSprite was removed, otherwise false. + * @return True if the FlxSprite was removed, otherwise false. */ public static function remove(source:FlxSprite):Bool { diff --git a/flixel/addons/plugin/control/FlxControl.hx b/flixel/addons/plugin/control/FlxControl.hx index a53af2c3..c833d222 100644 --- a/flixel/addons/plugin/control/FlxControl.hx +++ b/flixel/addons/plugin/control/FlxControl.hx @@ -30,6 +30,7 @@ class FlxControl extends FlxBasic * @param Sprite The FlxSprite you want this class to control. It can only control one FlxSprite at once. * @param MovementType Set to either MOVEMENT_INSTANT or MOVEMENT_ACCELERATES * @param StoppingType Set to STOPPING_INSTANT, STOPPING_DECELERATES or STOPPING_NEVER + * @param Player An optional ID for the player using these controls; using an ID of 1-4 will allow quick reference via `FlxControl.player{ID}` * @param UpdateFacing If true it sets the FlxSprite.facing value to the direction pressed (default false) * @param EnableArrowKeys If true it will enable all arrow keys (default) - see setCursorControl for more fine-grained control * @return The new FlxControlHandler @@ -77,7 +78,7 @@ class FlxControl extends FlxBasic * Removes a FlxControlHandler * * @param ControlHandler The FlxControlHandler to delete - * @return Boolean true if the FlxControlHandler was removed, otherwise false. + * @return True if the FlxControlHandler was removed, otherwise false. */ public static function remove(ControlHandler:FlxControlHandler):Bool { diff --git a/flixel/addons/plugin/control/FlxControlHandler.hx b/flixel/addons/plugin/control/FlxControlHandler.hx index bb8f7d61..a932c4f6 100644 --- a/flixel/addons/plugin/control/FlxControlHandler.hx +++ b/flixel/addons/plugin/control/FlxControlHandler.hx @@ -4,14 +4,14 @@ package flixel.addons.plugin.control; import flash.geom.Rectangle; import flixel.FlxG; import flixel.FlxSprite; +import flixel.math.FlxMath; +import flixel.math.FlxPoint; +import flixel.math.FlxVelocity; #if (flixel >= "5.3.0") import flixel.sound.FlxSound; #else import flixel.system.FlxSound; #end -import flixel.math.FlxMath; -import flixel.math.FlxPoint; -import flixel.math.FlxVelocity; /** * @@ -218,26 +218,26 @@ class FlxControlHandler * Sets the FlxSprite to be controlled by this class, and defines the initial movement and stopping types. * After creating an instance of this class you should call setMovementSpeed, and one of the enableXControl functions if you need more than basic cursors. * - * @param Sprite The FlxSprite you want this class to control. It can only control one FlxSprite at once. - * @param MovementType Set to either MOVEMENT_INSTANT or MOVEMENT_ACCELERATES + * @param sprite The FlxSprite you want this class to control. It can only control one FlxSprite at once. + * @param movementType Set to either MOVEMENT_INSTANT or MOVEMENT_ACCELERATES * @param StoppingType Set to STOPPING_INSTANT, STOPPING_DECELERATES or STOPPING_NEVER - * @param UpdateFacing If true it sets the FlxSprite.facing value to the direction pressed (default false) - * @param EnableArrowKeys If true it will enable all arrow keys (default) - see setCursorControl for more fine-grained control + * @param updateFacing If true it sets the FlxSprite.facing value to the direction pressed (default false) + * @param enableArrowKeys If true it will enable all arrow keys (default) - see setCursorControl for more fine-grained control */ - public function new(Sprite:FlxSprite, MovementType:Int, StoppingType:Int, UpdateFacing:Bool = false, EnableArrowKeys:Bool = true) + public function new(sprite:FlxSprite, movementType:Int, stoppingType:Int, updateFacing:Bool = false, enableArrowKeys:Bool = true) { - _entity = Sprite; + _entity = sprite; - _movement = MovementType; - _stopping = StoppingType; + _movement = movementType; + _stopping = stoppingType; - _xFacing = UpdateFacing; - _yFacing = UpdateFacing; + _xFacing = updateFacing; + _yFacing = updateFacing; _rotation = ROTATION_INSTANT; _rotationStopping = ROTATION_STOPPING_INSTANT; - if (EnableArrowKeys) + if (enableArrowKeys) { setCursorControl(); } @@ -254,39 +254,39 @@ class FlxControlHandler * * If you need different speed values for left/right or up/down then use setAdvancedMovementSpeed * - * @param SpeedX The speed in pixels per second in which the sprite will move/accelerate horizontally - * @param SpeedY The speed in pixels per second in which the sprite will move/accelerate vertically - * @param SpeedMaxX The maximum speed in pixels per second in which the sprite can move horizontally - * @param SpeedMaxY The maximum speed in pixels per second in which the sprite can move vertically - * @param DecelerationX A deceleration speed in pixels per second to apply to the sprites horizontal movement (default 0) - * @param DecelerationY A deceleration speed in pixels per second to apply to the sprites vertical movement (default 0) + * @param speedX The speed in pixels per second in which the sprite will move/accelerate horizontally + * @param speedY The speed in pixels per second in which the sprite will move/accelerate vertically + * @param speedMaxX The maximum speed in pixels per second in which the sprite can move horizontally + * @param speedMaxY The maximum speed in pixels per second in which the sprite can move vertically + * @param decelerationX A deceleration speed in pixels per second to apply to the sprites horizontal movement (default 0) + * @param decelerationY A deceleration speed in pixels per second to apply to the sprites vertical movement (default 0) */ - public function setMovementSpeed(SpeedX:Int, SpeedY:Int, SpeedMaxX:Int, SpeedMaxY:Int, DecelerationX:Int = 0, DecelerationY:Int = 0):Void + public function setMovementSpeed(speedX:Int, speedY:Int, speedMaxX:Int, speedMaxY:Int, decelerationX:Int = 0, decelerationY:Int = 0):Void { - _leftMoveSpeed = -SpeedX; - _rightMoveSpeed = SpeedX; - _upMoveSpeed = -SpeedY; - _downMoveSpeed = SpeedY; + _leftMoveSpeed = -speedX; + _rightMoveSpeed = speedX; + _upMoveSpeed = -speedY; + _downMoveSpeed = speedY; - setMaximumSpeed(SpeedMaxX, SpeedMaxY); - setDeceleration(DecelerationX, DecelerationY); + setMaximumSpeed(speedMaxX, speedMaxY); + setDeceleration(decelerationX, decelerationY); } /** * If you know you need the same value for the acceleration, maximum speeds and (optionally) deceleration then this is a quick way to set them. * - * @param Speed The speed in pixels per second in which the sprite will move/accelerate/decelerate - * @param Acceleration If true it will set the speed value as the deceleration value (default) false will leave deceleration disabled + * @param speed The speed in pixels per second in which the sprite will move/accelerate/decelerate + * @param acceleration If true it will set the speed value as the deceleration value (default) false will leave deceleration disabled */ - public function setStandardSpeed(Speed:Int, Acceleration:Bool = true):Void + public function setStandardSpeed(speed:Int, acceleration:Bool = true):Void { - if (Acceleration) + if (acceleration) { - setMovementSpeed(Speed, Speed, Speed, Speed, Speed, Speed); + setMovementSpeed(speed, speed, speed, speed, speed, speed); } else { - setMovementSpeed(Speed, Speed, Speed, Speed); + setMovementSpeed(speed, speed, speed, speed); } } @@ -297,25 +297,25 @@ class FlxControlHandler * * If you don't need different speed values for every direction on its own then use setMovementSpeed * - * @param LeftSpeed The speed in pixels per second in which the sprite will move/accelerate to the left - * @param RightSpeed The speed in pixels per second in which the sprite will move/accelerate to the right - * @param UpSpeed The speed in pixels per second in which the sprite will move/accelerate up - * @param DownSpeed The speed in pixels per second in which the sprite will move/accelerate down - * @param SpeedMaxX The maximum speed in pixels per second in which the sprite can move horizontally - * @param SpeedMaxY The maximum speed in pixels per second in which the sprite can move vertically - * @param DecelerationX Deceleration speed in pixels per second to apply to the sprites horizontal movement (default 0) - * @param DecelerationY Deceleration speed in pixels per second to apply to the sprites vertical movement (default 0) + * @param leftSpeed The speed in pixels per second in which the sprite will move/accelerate to the left + * @param rightSpeed The speed in pixels per second in which the sprite will move/accelerate to the right + * @param upSpeed The speed in pixels per second in which the sprite will move/accelerate up + * @param downSpeed The speed in pixels per second in which the sprite will move/accelerate down + * @param speedMaxX The maximum speed in pixels per second in which the sprite can move horizontally + * @param speedMaxY The maximum speed in pixels per second in which the sprite can move vertically + * @param decelerationX Deceleration speed in pixels per second to apply to the sprites horizontal movement (default 0) + * @param decelerationY Deceleration speed in pixels per second to apply to the sprites vertical movement (default 0) */ - public function setAdvancedMovementSpeed(LeftSpeed:Int, RightSpeed:Int, UpSpeed:Int, DownSpeed:Int, SpeedMaxX:Int, SpeedMaxY:Int, DecelerationX:Int = 0, - DecelerationY:Int = 0):Void + public function setAdvancedMovementSpeed(leftSpeed:Int, rightSpeed:Int, upSpeed:Int, downSpeed:Int, speedMaxX:Int, speedMaxY:Int, decelerationX:Int = 0, + decelerationY:Int = 0):Void { - _leftMoveSpeed = -LeftSpeed; - _rightMoveSpeed = RightSpeed; - _upMoveSpeed = -UpSpeed; - _downMoveSpeed = DownSpeed; + _leftMoveSpeed = -leftSpeed; + _rightMoveSpeed = rightSpeed; + _upMoveSpeed = -upSpeed; + _downMoveSpeed = downSpeed; - setMaximumSpeed(SpeedMaxX, SpeedMaxY); - setDeceleration(DecelerationX, DecelerationY); + setMaximumSpeed(speedMaxX, speedMaxY); + setDeceleration(decelerationX, decelerationY); } /** @@ -324,24 +324,26 @@ class FlxControlHandler * All values are given in pixels per second. So an xSpeed of 100 would rotate the sprite 100 pixels in 1 second (1000ms) * Due to the nature of the internal Flash timer this amount is not 100% accurate and will vary above/below the desired distance by a few pixels. */ - public function setRotationSpeed(AntiClockwiseSpeed:Float, ClockwiseSpeed:Float, SpeedMax:Float, Deceleration:Float):Void + public function setRotationSpeed(antiClockwiseSpeed:Float, clockwiseSpeed:Float, speedMax:Float, deceleration:Float):Void { - _antiClockwiseRotationSpeed = -AntiClockwiseSpeed; - _clockwiseRotationSpeed = ClockwiseSpeed; + _antiClockwiseRotationSpeed = -antiClockwiseSpeed; + _clockwiseRotationSpeed = clockwiseSpeed; setRotationKeys(); - setMaximumRotationSpeed(SpeedMax); - setRotationDeceleration(Deceleration); + setMaximumRotationSpeed(speedMax); + setRotationDeceleration(deceleration); } /** - * @param RotationType - * @param StoppingType + * Sets the rotation type and the rotation stopping type. + * + * @param rotationType The rotation type. Must be either `ROTATION_INSTANT` or `ROTATION_ACCELERATES`. + * @param stoppingType The rotation stopping type. Must be `ROTATION_STOPPING_INSTANT`, `ROTATION_STOPPING_DECELERATES`, or `ROTATION_STOPPING_NEVER`. */ - public function setRotationType(RotationType:Int, StoppingType:Int):Void + public function setRotationType(rotationType:Int, stoppingType:Int):Void { - _rotation = RotationType; - _rotationStopping = StoppingType; + _rotation = rotationType; + _rotationStopping = stoppingType; } /** @@ -349,45 +351,45 @@ class FlxControlHandler * When the FlxSprite is accelerating (movement type MOVEMENT_ACCELERATES) its speed won't increase above this value. * However Flixel allows the velocity of an FlxSprite to be set to anything. So if you'd like to check the value and restrain it, then enable "limitVelocity". * - * @param Speed The maximum speed in pixels per second in which the sprite can rotate - * @param LimitVelocity If true the angular velocity of the FlxSprite will be checked and kept within the limit. If false it can be set to anything. + * @param speed The maximum speed in pixels per second in which the sprite can rotate + * @param limitVelocity If true the angular velocity of the FlxSprite will be checked and kept within the limit. If false it can be set to anything. */ - public function setMaximumRotationSpeed(Speed:Float, LimitVelocity:Bool = true):Void + public function setMaximumRotationSpeed(speed:Float, limitVelocity:Bool = true):Void { - _entity.maxAngular = Speed; + _entity.maxAngular = speed; - _capAngularVelocity = LimitVelocity; + _capAngularVelocity = limitVelocity; } /** * Deceleration is a speed (in pixels per second) that is applied to the sprite if stopping type is "DECELERATES" and if no rotation is taking place. * The velocity of the sprite will be reduced until it reaches zero. * - * @param Speed The speed in pixels per second at which the sprite will have its angular rotation speed decreased + * @param speed The speed in pixels per second at which the sprite will have its angular rotation speed decreased */ - public function setRotationDeceleration(Speed:Float):Void + public function setRotationDeceleration(speed:Float):Void { - _entity.angularDrag = Speed; + _entity.angularDrag = speed; } /** * Set minimum and maximum angle limits that the Sprite won't be able to rotate beyond. * Values must be between -180 and +180. 0 is pointing right, 90 down, 180 left, -90 up. * - * @param MinimumAngle Minimum angle below which the sprite cannot rotate (must be -180 or above) - * @param MaximumAngle Maximum angle above which the sprite cannot rotate (must be 180 or below) + * @param minimumAngle Minimum angle below which the sprite cannot rotate (must be -180 or above) + * @param maximumAngle Maximum angle above which the sprite cannot rotate (must be 180 or below) */ - public function setRotationLimits(MinimumAngle:Int, MaximumAngle:Int):Void + public function setRotationLimits(minimumAngle:Int, maximumAngle:Int):Void { - if (MinimumAngle > MaximumAngle || MinimumAngle < -180 || MaximumAngle > 180) + if (minimumAngle > maximumAngle || minimumAngle < -180 || maximumAngle > 180) { throw "FlxControlHandler setRotationLimits: Invalid Minimum / Maximum angle"; } else { _enforceAngleLimits = true; - _minAngle = MinimumAngle; - _maxAngle = MaximumAngle; + _minAngle = minimumAngle; + _maxAngle = maximumAngle; } } @@ -402,12 +404,12 @@ class FlxControlHandler /** * Set which keys will rotate the sprite. The speed of rotation is set in setRotationSpeed. * - * @param LeftRight Use the LEFT and RIGHT arrow keys for anti-clockwise and clockwise rotation respectively. - * @param UpDown Use the UP and DOWN arrow keys for anti-clockwise and clockwise rotation respectively. - * @param CustomAntiClockwise The String value of your own key to use for anti-clockwise rotation (as taken from flixel.system.input.Keyboard) - * @param CustomClockwise The String value of your own key to use for clockwise rotation (as taken from flixel.system.input.Keyboard) + * @param leftRight Use the LEFT and RIGHT arrow keys for anti-clockwise and clockwise rotation respectively. + * @param upDown Use the UP and DOWN arrow keys for anti-clockwise and clockwise rotation respectively. + * @param customAntiClockwise The String value of your own key to use for anti-clockwise rotation (as taken from flixel.system.input.Keyboard) + * @param customClockwise The String value of your own key to use for clockwise rotation (as taken from flixel.system.input.Keyboard) */ - public function setRotationKeys(LeftRight:Bool = true, UpDown:Bool = false, CustomAntiClockwise:String = "", CustomClockwise:String = ""):Void + public function setRotationKeys(leftRight:Bool = true, upDown:Bool = false, customAntiClockwise:String = "", customClockwise:String = ""):Void { _isRotating = true; _rotateAntiClockwise = true; @@ -415,16 +417,16 @@ class FlxControlHandler _antiClockwiseKey = "LEFT"; _clockwiseKey = "RIGHT"; - if (UpDown) + if (upDown) { _antiClockwiseKey = "UP"; _clockwiseKey = "DOWN"; } - if (CustomAntiClockwise != "" && CustomClockwise != "") + if (customAntiClockwise != "" && customClockwise != "") { - _antiClockwiseKey = CustomAntiClockwise; - _clockwiseKey = CustomClockwise; + _antiClockwiseKey = customAntiClockwise; + _clockwiseKey = customClockwise; } } @@ -432,27 +434,27 @@ class FlxControlHandler * If you want to enable a Thrust like motion for your sprite use this to set the speed and keys. * This is usually used in conjunction with Rotation and it will over-ride anything already defined in setMovementSpeed. * - * @param ThrustKey Specify the key String (as taken from flixel.system.input.Keyboard) to use for the Thrust action - * @param ThrustSpeed The speed in pixels per second which the sprite will move. Acceleration or Instant movement is determined by the Movement Type. - * @param ReverseKey If you want to be able to reverse, set the key string as taken from flixel.system.input.Keyboard (defaults to null). - * @param ReverseSpeed The speed in pixels per second which the sprite will reverse. Acceleration or Instant movement is determined by the Movement Type. + * @param thrustKey Specify the key String (as taken from flixel.system.input.Keyboard) to use for the Thrust action + * @param thrustSpeed The speed in pixels per second which the sprite will move. Acceleration or Instant movement is determined by the Movement Type. + * @param reverseKey If you want to be able to reverse, set the key string as taken from flixel.system.input.Keyboard (defaults to null). + * @param reverseSpeed The speed in pixels per second which the sprite will reverse. Acceleration or Instant movement is determined by the Movement Type. */ - public function setThrust(ThrustKey:String, ThrustSpeed:Float, ?ReverseKey:String, ReverseSpeed:Float = 0):Void + public function setThrust(thrustKey:String, thrustSpeed:Float, ?reverseKey:String, reverseSpeed:Float = 0):Void { _thrustEnabled = false; _reverseEnabled = false; - if (ThrustKey != "") + if (thrustKey != "") { - _thrustKey = ThrustKey; - _thrustSpeed = Math.floor(ThrustSpeed); + _thrustKey = thrustKey; + _thrustSpeed = Math.floor(thrustSpeed); _thrustEnabled = true; } - if (ReverseKey != null) + if (reverseKey != null) { - _reverseKey = ReverseKey; - _reverseSpeed = Math.floor(ReverseSpeed); + _reverseKey = reverseKey; + _reverseSpeed = Math.floor(reverseSpeed); _reverseEnabled = true; } } @@ -462,29 +464,29 @@ class FlxControlHandler * When the FlxSprite is accelerating (movement type MOVEMENT_ACCELERATES) its speed won't increase above this value. * However Flixel allows the velocity of an FlxSprite to be set to anything. So if you'd like to check the value and restrain it, then enable "limitVelocity". * - * @param SpeedX The maximum speed in pixels per second in which the sprite can move horizontally - * @param SpeedY The maximum speed in pixels per second in which the sprite can move vertically - * @param LimitVelocity If true the velocity of the FlxSprite will be checked and kept within the limit. If false it can be set to anything. + * @param speedX The maximum speed in pixels per second in which the sprite can move horizontally + * @param speedY The maximum speed in pixels per second in which the sprite can move vertically + * @param limitVelocity If true the velocity of the FlxSprite will be checked and kept within the limit. If false it can be set to anything. */ - public function setMaximumSpeed(SpeedX:Int, SpeedY:Int, LimitVelocity:Bool = true):Void + public function setMaximumSpeed(speedX:Int, speedY:Int, limitVelocity:Bool = true):Void { - _entity.maxVelocity.x = SpeedX; - _entity.maxVelocity.y = SpeedY; + _entity.maxVelocity.x = speedX; + _entity.maxVelocity.y = speedY; - _capVelocity = LimitVelocity; + _capVelocity = limitVelocity; } /** * Deceleration is a speed (in pixels per second) that is applied to the sprite if stopping type is "DECELERATES" and if no acceleration is taking place. * The velocity of the sprite will be reduced until it reaches zero, and can be configured separately per axis. * - * @param SpeedX The speed in pixels per second at which the sprite will have its horizontal speed decreased - * @param SpeedY The speed in pixels per second at which the sprite will have its vertical speed decreased + * @param speedX The speed in pixels per second at which the sprite will have its horizontal speed decreased + * @param speedY The speed in pixels per second at which the sprite will have its vertical speed decreased */ - public function setDeceleration(SpeedX:Int, SpeedY:Int):Void + public function setDeceleration(speedX:Int, speedY:Int):Void { - _entity.drag.x = SpeedX; - _entity.drag.y = SpeedY; + _entity.drag.x = speedX; + _entity.drag.y = speedY; } /** @@ -492,13 +494,13 @@ class FlxControlHandler * Gravity is given in pixels per second and is applied as acceleration. The speed the sprite reaches under gravity will never exceed the Maximum Movement Speeds set. * If you don't want gravity for a specific direction pass a value of zero. * - * @param ForceX A positive value applies gravity dragging the sprite to the right. A negative value drags the sprite to the left. Zero disables horizontal gravity. - * @param ForceY A positive value applies gravity dragging the sprite down. A negative value drags the sprite up. Zero disables vertical gravity. + * @param forceX A positive value applies gravity dragging the sprite to the right. A negative value drags the sprite to the left. Zero disables horizontal gravity. + * @param forceY A positive value applies gravity dragging the sprite down. A negative value drags the sprite up. Zero disables vertical gravity. */ - public function setGravity(ForceX:Int, ForceY:Int):Void + public function setGravity(forceX:Int, forceY:Int):Void { - _gravityX = ForceX; - _gravityY = ForceY; + _gravityX = forceX; + _gravityY = forceY; _entity.acceleration.x = _gravityX; _entity.acceleration.y = _gravityY; @@ -525,18 +527,19 @@ class FlxControlHandler /** * TODO + * Resets the X and Y speeds. Not yet implemented. * - * @param ResetX - * @param ResetY + * @param resetX Whether to reset the X speed. Defaults to `true`. + * @param resetY Whether to reset the Y speed. Defaults to `true`. */ - public function resetSpeeds(ResetX:Bool = true, ResetY:Bool = true):Void + public function resetSpeeds(resetX:Bool = true, resetY:Bool = true):Void { - if (ResetX) + if (resetX) { _xSpeedAdjust = 0; } - if (ResetY) + if (resetY) { _ySpeedAdjust = 0; } @@ -545,53 +548,53 @@ class FlxControlHandler /** * Set sound effects for the movement events jumping, firing, walking and thrust. * - * @param Jump The FlxSound to play when the user jumps - * @param Fire The FlxSound to play when the user fires - * @param Walk The FlxSound to play when the user walks - * @param Thrust The FlxSound to play when the user thrusts + * @param jump The FlxSound to play when the user jumps + * @param fire The FlxSound to play when the user fires + * @param walk The FlxSound to play when the user walks + * @param thrust The FlxSound to play when the user thrusts */ - public function setSounds(?Jump:FlxSound, ?Fire:FlxSound, ?Walk:FlxSound, ?Thrust:FlxSound):Void + public function setSounds(?jump:FlxSound, ?fire:FlxSound, ?walk:FlxSound, ?thrust:FlxSound):Void { - if (Jump != null) + if (jump != null) { - _jumpSound = Jump; + _jumpSound = jump; } - if (Fire != null) + if (fire != null) { - _fireSound = Fire; + _fireSound = fire; } - if (Walk != null) + if (walk != null) { - _walkSound = Walk; + _walkSound = walk; } - if (Thrust != null) + if (thrust != null) { - _thrustSound = Thrust; + _thrustSound = thrust; } } /** * Enable a fire button * - * @param Key The key to use as the fire button (String from flixel.system.input.Keyboard, i.e. "SPACE", "CONTROL") - * @param Keymode The FlxControlHandler KEYMODE value (KEYMODE_PRESSED, KEYMODE_JUST_DOWN, KEYMODE_RELEASED) - * @param RepeatDelay Time delay in ms between which the fire action can repeat (0 means instant, 250 would allow it to fire approx. 4 times per second) - * @param Callback A user defined function to call when it fires - * @param AltKey Specify an alternative fire key that works AS WELL AS the primary fire key (TODO) + * @param key The key to use as the fire button (String from flixel.system.input.Keyboard, i.e. "SPACE", "CONTROL") + * @param keymode The FlxControlHandler KEYMODE value (KEYMODE_PRESSED, KEYMODE_JUST_DOWN, KEYMODE_RELEASED) + * @param repeatDelay Time delay in ms between which the fire action can repeat (0 means instant, 250 would allow it to fire approx. 4 times per second) + * @param callback A user defined function to call when it fires + * @param altKey Specify an alternative fire key that works AS WELL AS the primary fire key (TODO) */ - public function setFireButton(Key:String, Keymode:Int, RepeatDelay:Int, Callback:Void->Void, AltKey:String = ""):Void + public function setFireButton(key:String, keymode:Int, repeatDelay:Int, callback:Void->Void, altKey:String = ""):Void { - _fireKey = Key; - _fireKeyMode = Keymode; - _fireRate = RepeatDelay; - _fireCallback = Callback; + _fireKey = key; + _fireKeyMode = keymode; + _fireRate = repeatDelay; + _fireCallback = callback; - if (AltKey != "") + if (altKey != "") { - _altFireKey = AltKey; + _altFireKey = altKey; } _fire = true; @@ -600,29 +603,29 @@ class FlxControlHandler /** * Enable a jump button * - * @param Key The key to use as the jump button (String from flixel.system.input.Keyboard, i.e. "SPACE", "CONTROL") - * @param Keymode The FlxControlHandler KEYMODE value (KEYMODE_PRESSED, KEYMODE_JUST_DOWN, KEYMODE_RELEASED) - * @param Height The height in pixels/sec that the Sprite will attempt to jump (gravity and acceleration can influence this actual height obtained) - * @param Surface A bitwise combination of all valid surfaces the Sprite can jump off (such as FLOOR) - * @param RepeatDelay Time delay in ms between which the jumping can repeat (250 would be 4 times per second) - * @param JumpFromFall A time in ms that allows the Sprite to still jump even if it's just fallen off a platform, if still within ths time limit - * @param Callback A user defined function to call when the Sprite jumps - * @param AltKey Specify an alternative jump key that works AS WELL AS the primary jump key (TODO) + * @param key The key to use as the jump button (String from flixel.system.input.Keyboard, i.e. "SPACE", "CONTROL") + * @param keymode The FlxControlHandler KEYMODE value (KEYMODE_PRESSED, KEYMODE_JUST_DOWN, KEYMODE_RELEASED) + * @param height The height in pixels/sec that the Sprite will attempt to jump (gravity and acceleration can influence this actual height obtained) + * @param surface A bitwise combination of all valid surfaces the Sprite can jump off (such as FLOOR) + * @param repeatDelay Time delay in ms between which the jumping can repeat (250 would be 4 times per second) + * @param jumpFromFall A time in ms that allows the Sprite to still jump even if it's just fallen off a platform, if still within ths time limit + * @param callback A user defined function to call when the Sprite jumps + * @param altKey Specify an alternative jump key that works AS WELL AS the primary jump key (TODO) */ - public function setJumpButton(Key:String, Keymode:Int, Height:Int, Surface:Int, RepeatDelay:Int = 250, JumpFromFall:Int = 0, ?Callback:Void->Void, - AltKey:String = ""):Void + public function setJumpButton(key:String, keymode:Int, height:Int, surface:Int, repeatDelay:Int = 250, jumpFromFall:Int = 0, ?callback:Void->Void, + altKey:String = ""):Void { - _jumpKey = Key; - _jumpKeyMode = Keymode; - _jumpHeight = Height; - _jumpSurface = Surface; - _jumpRate = RepeatDelay; - _jumpFromFallTime = JumpFromFall; - _jumpCallback = Callback; - - if (AltKey != "") + _jumpKey = key; + _jumpKeyMode = keymode; + _jumpHeight = height; + _jumpSurface = surface; + _jumpRate = repeatDelay; + _jumpFromFallTime = jumpFromFall; + _jumpCallback = callback; + + if (altKey != "") { - _altJumpKey = AltKey; + _altJumpKey = altKey; } _jump = true; @@ -632,14 +635,14 @@ class FlxControlHandler * Limits the sprite to only be allowed within this rectangle. If its x/y coordinates go outside it will be repositioned back inside. * Coordinates should be given in GAME WORLD pixel values (not screen value, although often they are the two same things) * - * @param X The x coordinate of the top left corner of the area (in game world pixels) - * @param Y The y coordinate of the top left corner of the area (in game world pixels) - * @param Width The width of the area (in pixels) - * @param Height The height of the area (in pixels) + * @param x The x coordinate of the top left corner of the area (in game world pixels) + * @param y The y coordinate of the top left corner of the area (in game world pixels) + * @param width The width of the area (in pixels) + * @param height The height of the area (in pixels) */ - public function setBounds(X:Int, Y:Int, Width:Int, Height:Int):Void + public function setBounds(x:Int, y:Int, width:Int, height:Int):Void { - _bounds = new Rectangle(X, Y, Width, Height); + _bounds = new Rectangle(x, y, width, height); } /** @@ -1209,35 +1212,35 @@ class FlxControlHandler * Sets Custom Key controls. Useful if none of the pre-defined sets work. All String values should be taken from flixel.system.input.Keyboard * Pass a blank (empty) String to disable that key from being checked. * - * @param CustomUpKey The String to use for the Up key. - * @param CustomDownKey The String to use for the Down key. - * @param CustomLeftKey The String to use for the Left key. - * @param CustomRightKey The String to use for the Right key. + * @param customUpKey The String to use for the Up key. + * @param customDownKey The String to use for the Down key. + * @param customLeftKey The String to use for the Left key. + * @param customRightKey The String to use for the Right key. */ - public function setCustomKeys(CustomUpKey:String, CustomDownKey:String, CustomLeftKey:String, CustomRightKey:String):Void + public function setCustomKeys(customUpKey:String, customDownKey:String, customLeftKey:String, customRightKey:String):Void { - if (CustomUpKey != "") + if (customUpKey != "") { _up = true; - _upKey = CustomUpKey; + _upKey = customUpKey; } - if (CustomDownKey != "") + if (customDownKey != "") { _down = true; - _downKey = CustomDownKey; + _downKey = customDownKey; } - if (CustomLeftKey != "") + if (customLeftKey != "") { _left = true; - _leftKey = CustomLeftKey; + _leftKey = customLeftKey; } - if (CustomRightKey != "") + if (customRightKey != "") { _right = true; - _rightKey = CustomRightKey; + _rightKey = customRightKey; } } @@ -1245,17 +1248,17 @@ class FlxControlHandler * Enables Cursor/Arrow Key controls. Can be set on a per-key basis. Useful if you only want to allow a few keys. * For example in a Space Invaders game you'd only enable LEFT and RIGHT. * - * @param AllowUp Enable the UP key - * @param AllowDown Enable the DOWN key - * @param AllowLeft Enable the LEFT key - * @param AllowRight Enable the RIGHT key + * @param allowUp Enable the UP key + * @param allowDown Enable the DOWN key + * @param allowLeft Enable the LEFT key + * @param allowRight Enable the RIGHT key */ - public function setCursorControl(AllowUp:Bool = true, AllowDown:Bool = true, AllowLeft:Bool = true, AllowRight:Bool = true):Void + public function setCursorControl(allowUp:Bool = true, allowDown:Bool = true, allowLeft:Bool = true, allowRight:Bool = true):Void { - _up = AllowUp; - _down = AllowDown; - _left = AllowLeft; - _right = AllowRight; + _up = allowUp; + _down = allowDown; + _left = allowLeft; + _right = allowRight; _upKey = "UP"; _downKey = "DOWN"; @@ -1272,12 +1275,12 @@ class FlxControlHandler * @param allowLeft Enable the left (A) key * @param allowRight Enable the right (D) key */ - public function setWASDControl(AllowUp:Bool = true, AllowDown:Bool = true, AllowLeft:Bool = true, AllowRight:Bool = true):Void + public function setWASDControl(allowUp:Bool = true, allowDown:Bool = true, allowLeft:Bool = true, allowRight:Bool = true):Void { - _up = AllowUp; - _down = AllowDown; - _left = AllowLeft; - _right = AllowRight; + _up = allowUp; + _down = allowDown; + _left = allowLeft; + _right = allowRight; _upKey = "W"; _downKey = "S"; @@ -1289,17 +1292,17 @@ class FlxControlHandler * Enables ESDF (home row) controls. Can be set on a per-key basis. Useful if you only want to allow a few keys. * For example in a Space Invaders game you'd only enable LEFT and RIGHT. * - * @param AllowUp Enable the up (E) key - * @param AllowDown Enable the down (D) key - * @param AllowLeft Enable the left (S) key - * @param AllowRight Enable the right (F) key + * @param allowUp Enable the up (E) key + * @param allowDown Enable the down (D) key + * @param allowLeft Enable the left (S) key + * @param allowRight Enable the right (F) key */ - public function setESDFControl(AllowUp:Bool = true, AllowDown:Bool = true, AllowLeft:Bool = true, AllowRight:Bool = true):Void + public function setESDFControl(allowUp:Bool = true, allowDown:Bool = true, allowLeft:Bool = true, allowRight:Bool = true):Void { - _up = AllowUp; - _down = AllowDown; - _left = AllowLeft; - _right = AllowRight; + _up = allowUp; + _down = allowDown; + _left = allowLeft; + _right = allowRight; _upKey = "E"; _downKey = "D"; @@ -1311,17 +1314,17 @@ class FlxControlHandler * Enables IJKL (right-sided or secondary player) controls. Can be set on a per-key basis. Useful if you only want to allow a few keys. * For example in a Space Invaders game you'd only enable LEFT and RIGHT. * - * @param AllowUp Enable the up (I) key - * @param AllowDown Enable the down (K) key - * @param AllowLeft Enable the left (J) key - * @param AllowRight Enable the right (L) key + * @param allowUp Enable the up (I) key + * @param allowDown Enable the down (K) key + * @param allowLeft Enable the left (J) key + * @param allowRight Enable the right (L) key */ - public function setIJKLControl(AllowUp:Bool = true, AllowDown:Bool = true, AllowLeft:Bool = true, AllowRight:Bool = true):Void + public function setIJKLControl(allowUp:Bool = true, allowDown:Bool = true, allowLeft:Bool = true, allowRight:Bool = true):Void { - _up = AllowUp; - _down = AllowDown; - _left = AllowLeft; - _right = AllowRight; + _up = allowUp; + _down = allowDown; + _left = allowLeft; + _right = allowRight; _upKey = "I"; _downKey = "K"; @@ -1333,17 +1336,17 @@ class FlxControlHandler * Enables HJKL (Rogue / Net-Hack) controls. Can be set on a per-key basis. Useful if you only want to allow a few keys. * For example in a Space Invaders game you'd only enable LEFT and RIGHT. * - * @param AllowUp Enable the up (K) key - * @param AllowDown Enable the down (J) key - * @param AllowLeft Enable the left (H) key - * @param AllowRight Enable the right (L) key + * @param allowUp Enable the up (K) key + * @param allowDown Enable the down (J) key + * @param allowLeft Enable the left (H) key + * @param allowRight Enable the right (L) key */ - public function setHJKLControl(AllowUp:Bool = true, AllowDown:Bool = true, AllowLeft:Bool = true, AllowRight:Bool = true):Void + public function setHJKLControl(allowUp:Bool = true, allowDown:Bool = true, allowLeft:Bool = true, allowRight:Bool = true):Void { - _up = AllowUp; - _down = AllowDown; - _left = AllowLeft; - _right = AllowRight; + _up = allowUp; + _down = allowDown; + _left = allowLeft; + _right = allowRight; _upKey = "K"; _downKey = "J"; @@ -1355,17 +1358,17 @@ class FlxControlHandler * Enables ZQSD (Azerty keyboard) controls. Can be set on a per-key basis. Useful if you only want to allow a few keys. * For example in a Space Invaders game you'd only enable LEFT and RIGHT. * - * @param AllowUp Enable the up (Z) key - * @param AllowDown Enable the down (Q) key - * @param AllowLeft Enable the left (S) key - * @param AllowRight Enable the right (D) key + * @param allowUp Enable the up (Z) key + * @param allowDown Enable the down (Q) key + * @param allowLeft Enable the left (S) key + * @param allowRight Enable the right (D) key */ - public function setZQSDControl(AllowUp:Bool = true, AllowDown:Bool = true, AllowLeft:Bool = true, AllowRight:Bool = true):Void + public function setZQSDControl(allowUp:Bool = true, allowDown:Bool = true, allowLeft:Bool = true, allowRight:Bool = true):Void { - _up = AllowUp; - _down = AllowDown; - _left = AllowLeft; - _right = AllowRight; + _up = allowUp; + _down = allowDown; + _left = allowLeft; + _right = allowRight; _upKey = "Z"; _downKey = "S"; @@ -1377,17 +1380,17 @@ class FlxControlHandler * Enables Dvoark Simplified Controls. Can be set on a per-key basis. Useful if you only want to allow a few keys. * For example in a Space Invaders game you'd only enable LEFT and RIGHT. * - * @param AllowUp Enable the up (COMMA) key - * @param AllowDown Enable the down (A) key - * @param AllowLeft Enable the left (O) key - * @param AllowRight Enable the right (E) key + * @param allowUp Enable the up (COMMA) key + * @param allowDown Enable the down (A) key + * @param allowLeft Enable the left (O) key + * @param allowRight Enable the right (E) key */ - public function setDvorakSimplifiedControl(AllowUp:Bool = true, AllowDown:Bool = true, AllowLeft:Bool = true, AllowRight:Bool = true):Void + public function setDvorakSimplifiedControl(allowUp:Bool = true, allowDown:Bool = true, allowLeft:Bool = true, allowRight:Bool = true):Void { - _up = AllowUp; - _down = AllowDown; - _left = AllowLeft; - _right = AllowRight; + _up = allowUp; + _down = allowDown; + _left = allowLeft; + _right = allowRight; _upKey = "COMMA"; _downKey = "O"; @@ -1399,17 +1402,17 @@ class FlxControlHandler * Enables Numpad (left-handed) Controls. Can be set on a per-key basis. Useful if you only want to allow a few keys. * For example in a Space Invaders game you'd only enable LEFT and RIGHT. * - * @param AllowUp Enable the up (NUMPADEIGHT) key - * @param AllowDown Enable the down (NUMPADTWO) key - * @param AllowLeft Enable the left (NUMPADFOUR) key - * @param AllowRight Enable the right (NUMPADSIX) key + * @param allowUp Enable the up (NUMPADEIGHT) key + * @param allowDown Enable the down (NUMPADTWO) key + * @param allowLeft Enable the left (NUMPADFOUR) key + * @param allowRight Enable the right (NUMPADSIX) key */ - public function setNumpadControl(AllowUp:Bool = true, AllowDown:Bool = true, AllowLeft:Bool = true, AllowRight:Bool = true):Void + public function setNumpadControl(allowUp:Bool = true, allowDown:Bool = true, allowLeft:Bool = true, allowRight:Bool = true):Void { - _up = AllowUp; - _down = AllowDown; - _left = AllowLeft; - _right = AllowRight; + _up = allowUp; + _down = allowDown; + _left = allowLeft; + _right = allowRight; _upKey = "NUMPADEIGHT"; _downKey = "NUMPADTWO"; diff --git a/flixel/addons/plugin/screengrab/FlxScreenGrab.hx b/flixel/addons/plugin/screengrab/FlxScreenGrab.hx index ef039f81..30237337 100644 --- a/flixel/addons/plugin/screengrab/FlxScreenGrab.hx +++ b/flixel/addons/plugin/screengrab/FlxScreenGrab.hx @@ -61,7 +61,7 @@ class FlxScreenGrab extends FlxBasic * Specify which key will capture a screen shot. Use the String value of the key in the same way FlxG.keys does (so "F1" for example) * Optionally save the image to a file immediately. This uses the file systems "Save as" dialog window and pauses your game during the process. * - * @param Key The key(s) you press to capture the screen (i.e. [F1, SPACE]) + * @param Keys The key(s) you press to capture the screen (i.e. [F1, SPACE]) * @param SaveToFile If true it will immediately encodes the grab to a PNG and open a "Save As" dialog window when the hotkey is pressed * @param HideMouse If true the mouse will be hidden before capture and displayed afterwards when the hotkey is pressed */ @@ -88,7 +88,7 @@ class FlxScreenGrab extends FlxBasic * @param CaptureRegion A Rectangle area to capture. This over-rides that set by "defineCaptureRegion". If neither are set the full SWF size is used. * @param SaveToFile Boolean If set to true it will immediately encode the grab to a PNG and open a "Save As" dialog window * @param HideMouse Boolean If set to true the mouse will be hidden before capture and displayed again afterwards - * @return Bitmap The screen grab as a Flash Bitmap image + * @return The screen grab as a Flash Bitmap image */ public static function grab(?CaptureRegion:Rectangle, ?SaveToFile:Bool = false, HideMouse:Bool = false):Bitmap { diff --git a/flixel/addons/plugin/taskManager/FlxTaskManager.hx b/flixel/addons/plugin/taskManager/FlxTaskManager.hx index 81811e2b..f23ca404 100644 --- a/flixel/addons/plugin/taskManager/FlxTaskManager.hx +++ b/flixel/addons/plugin/taskManager/FlxTaskManager.hx @@ -167,7 +167,7 @@ class FlxTaskManager extends FlxBasic * Method-task for a pause between tasks * * @param Delay Delay - * @return Returns true when the task is completed + * @return True if the task completed successfully, false otherwise */ function taskPause(Delay:Float):Bool { @@ -186,7 +186,7 @@ class FlxTaskManager extends FlxBasic * Adds the specified object to the end of the list * * @param Task The FlxTask to be added. - * @return Returns a pointer to the added FlxTask. + * @return A pointer to the added FlxTask. */ function push(Task:FlxTask):FlxTask { @@ -218,7 +218,7 @@ class FlxTaskManager extends FlxBasic * Adds task to the top of task list * * @param Task The FlxTask to be added. - * @return Returns a pointer to the added FlxTask + * @return A pointer to the added FlxTask. */ function unshift(Task:FlxTask):FlxTask { diff --git a/flixel/addons/text/FlxTextField.hx b/flixel/addons/text/FlxTextField.hx index eb282d8c..3fde9433 100644 --- a/flixel/addons/text/FlxTextField.hx +++ b/flixel/addons/text/FlxTextField.hx @@ -22,6 +22,7 @@ class FlxTextField extends FlxText * @param Y The Y position of the text. * @param Width The width of the text object (height is determined automatically). * @param Text The actual text you would like to display initially. + * @param Size The font size for this text object. * @param EmbeddedFont Whether this text field uses embedded fonts or not */ public function new(X:Float, Y:Float, Width:Int, ?Text:String, Size:Int = 8, EmbeddedFont:Bool = true) diff --git a/flixel/addons/text/FlxTypeText.hx b/flixel/addons/text/FlxTypeText.hx index d82e8757..b1c889dc 100644 --- a/flixel/addons/text/FlxTypeText.hx +++ b/flixel/addons/text/FlxTypeText.hx @@ -283,7 +283,6 @@ class FlxTypeText extends FlxText * @param ForceRestart Whether or not to start this animation over if currently animating; false by default. * @param SkipKeys An array of keys as string values (e.g. `[FlxKey.SPACE, FlxKey.L]`) that will advance the text. Can also be set separately. * @param Callback An optional callback function, to be called when the erasing animation is complete. - * @param Params Optional parameters to pass to the callback function. */ public function erase(?Delay:Float, ForceRestart:Bool = false, ?SkipKeys:Array, ?Callback:Void->Void):Void { diff --git a/flixel/addons/tile/FlxCaveGenerator.hx b/flixel/addons/tile/FlxCaveGenerator.hx index 70fa952e..43d04053 100644 --- a/flixel/addons/tile/FlxCaveGenerator.hx +++ b/flixel/addons/tile/FlxCaveGenerator.hx @@ -40,7 +40,7 @@ class FlxCaveGenerator * @param Rows Number of rows for the matrix * @param SmoothingIterations How many times do you want to "smooth" the caev - the higher the smoother, but slower * @param WallRatio Chance for a tile to become a wall - the closer the value is to 1.0, the more walls there are - * @return Returns a matrix of a cave! + * @return A matrix of a cave! */ public static function generateCaveMatrix(Columns:Int, Rows:Int, SmoothingIterations:Int = 6, WallRatio:Float = 0.5):Array> { @@ -92,7 +92,7 @@ class FlxCaveGenerator * * @param Columns Number of columns for the matrix * @param Rows Number of rows for the matrix - * @return Spits out a matrix that is columns * rows big, initiated with zeros + * @return A matrix that is columns * rows big, initiated with zeros */ static function generateInitialMatrix(Columns:Int, Rows:Int):Array> { diff --git a/flixel/addons/tile/FlxRayCastTilemap.hx b/flixel/addons/tile/FlxRayCastTilemap.hx index d2586e33..3d5e5b13 100644 --- a/flixel/addons/tile/FlxRayCastTilemap.hx +++ b/flixel/addons/tile/FlxRayCastTilemap.hx @@ -27,7 +27,7 @@ class FlxRayCastTilemap extends FlxTilemap * @param Result Where the resulting point is stored, in (x,y) coordinates * @param ResultInTiles A point containing the tile that was hit, in tile coordinates (optional) * @param MaxTilesToCheck The maximum number of tiles you want the ray to pass. -1 means go across the entire tilemap. Only change this if you know what you're doing! - * @return true if hit a filled tile, false if it hit the end of the tilemap + * @return True if hit a filled tile, false if it hit the end of the tilemap * */ public function rayCast(Start:FlxPoint, Direction:FlxPoint, ?Result:FlxPoint, ?ResultInTiles:FlxPoint, MaxTilesToCheck:Int = -1):Bool diff --git a/flixel/addons/tile/FlxTileSpecial.hx b/flixel/addons/tile/FlxTileSpecial.hx index 395d2c6a..a64925e3 100644 --- a/flixel/addons/tile/FlxTileSpecial.hx +++ b/flixel/addons/tile/FlxTileSpecial.hx @@ -159,6 +159,7 @@ class FlxTileSpecial extends FlxBasic * Add an animation to this special tile * @param tiles An array with the tilesetID of each frame * @param frameRate The speed of the animation in frames per second (Default: 30) + * @param framesData An optional array of animation parameters for each frame */ public function addAnimation(tiles:Array, frameRate:Float = 30, ?framesData:Array):Void { @@ -176,8 +177,6 @@ class FlxTileSpecial extends FlxBasic /** * Calculates and return the matrix - * @param width the tile width - * @param height the tile height * @return The matrix calculated */ public function getMatrix():FlxMatrix diff --git a/flixel/addons/tile/FlxTilemapExt.hx b/flixel/addons/tile/FlxTilemapExt.hx index e9e8192e..0f4d7271 100644 --- a/flixel/addons/tile/FlxTilemapExt.hx +++ b/flixel/addons/tile/FlxTilemapExt.hx @@ -508,7 +508,7 @@ class FlxTilemapExt extends FlxTilemap * Internal helper functions for comparing a tile to the slope arrays to see if a tile should be treated as STEEP or GENTLE slope. * * @param TileIndex The Tile Index number of the Tile you want to check. - * @return Returns true if the tile is listed in one of the slope arrays. Otherwise returns false. + * @return True if the tile is listed in one of the slope arrays. Otherwise false. */ function checkThickGentle(TileIndex:Int):Bool { @@ -874,7 +874,7 @@ class FlxTilemapExt extends FlxTilemap * Internal helper function for comparing a tile to the slope arrays to see if a tile should be treated as a slope. * * @param TileIndex The Tile Index number of the Tile you want to check. - * @return Returns true if the tile is listed in one of the slope arrays. Otherwise returns false. + * @return True if the tile is listed in one of the slope arrays. Otherwise false. */ function checkArrays(TileIndex:Int):Bool { diff --git a/flixel/addons/util/FlxFSM.hx b/flixel/addons/util/FlxFSM.hx index a3974683..b5cc74ee 100644 --- a/flixel/addons/util/FlxFSM.hx +++ b/flixel/addons/util/FlxFSM.hx @@ -1,8 +1,8 @@ package flixel.addons.util; -import flixel.util.FlxDestroyUtil; -import flixel.math.FlxRandom; import flixel.FlxG; +import flixel.math.FlxRandom; +import flixel.util.FlxDestroyUtil; import flixel.util.FlxPool; import flixel.util.FlxSignal.FlxTypedSignal; @@ -16,23 +16,23 @@ class FlxFSMState implements IFlxDestroyable /** * Called when state becomes active. * - * @param Owner The object the state controls - * @param FSM The FSM instance this state belongs to. Used for changing the state to another. + * @param owner The object the state controls + * @param fsm The FSM instance this state belongs to. Used for changing the state to another. */ public function enter(owner:T, fsm:FlxFSM):Void {} /** * Called every update loop. * - * @param Owner The object the state controls - * @param FSM The FSM instance this state belongs to. Used for changing the state to another. + * @param owner The object the state controls + * @param fsm The FSM instance this state belongs to. Used for changing the state to another. */ public function update(elapsed:Float, owner:T, fsm:FlxFSM):Void {} /** * Called when the state becomes inactive. * - * @param Owner The object the state controls + * @param owner The object the state controls */ public function exit(owner:T):Void {} @@ -42,7 +42,7 @@ class FlxFSMState implements IFlxDestroyable /** * Helper typedef for FlxExtendedFSM's pools */ -typedef StatePool = Map>> +typedef StatePool = Map>>; /** * A generic Finite-state machine implementation. @@ -264,7 +264,7 @@ class FlxFSMStack extends FlxFSMStackSignal implements IFlxDestroyable /** * Locks the specified FSM for the duration of the update loop - * @param name + * @param name The name of the FSM to lock */ public function lock(name:String):Void { @@ -296,7 +296,7 @@ class FlxFSMStack extends FlxFSMStackSignal implements IFlxDestroyable /** * Adds the FSM to the front of the stack - * @param FSM + * @param FSM The FSM to add */ public function unshift(FSM:FlxFSM) { @@ -325,7 +325,7 @@ class FlxFSMStack extends FlxFSMStackSignal implements IFlxDestroyable /** * Adds the FSM to the end of the stack - * @param FSM + * @param FSM The FSM to add */ public function push(FSM:FlxFSM) { @@ -355,7 +355,7 @@ class FlxFSMStack extends FlxFSMStackSignal implements IFlxDestroyable /** * Removes the FSM from the stack and destroys it - * @param The removed FSM + * @param FSM The FSM to remove */ public function remove(FSM:FlxFSM) { @@ -372,7 +372,7 @@ class FlxFSMStack extends FlxFSMStackSignal implements IFlxDestroyable /** * Removes the FSM with given name from the stack and destroys it - * @param The removed FSM + * @param name The name of the FSM to remove */ public function removeByName(name:String) { @@ -448,7 +448,8 @@ class FlxFSMTransitionTable /** * Polls the transition table for active states - * @param FSM The FlxFSMState the table belongs to + * @param currentState The class of the current FlxFSMState + * @param owner The FlxFSMState the table belongs to * @return The state that should become or remain active. */ public function poll(currentState:Class>, owner:T):Class> @@ -498,9 +499,9 @@ class FlxFSMTransitionTable /** * Adds a transition condition to the table. - * @param From The state the condition applies to - * @param To The state to transition - * @param Condition Function that returns true if the transition conditions are met + * @param from The state the condition applies to + * @param to The state to transition + * @param condition Function that returns true if the transition conditions are met */ public function add(from:Class>, to:Class>, condition:T->Bool) { @@ -517,8 +518,8 @@ class FlxFSMTransitionTable /** * Adds a global transition condition to the table. - * @param To The state to transition - * @param Condition Function that returns true if the transition conditions are met + * @param to The state to transition + * @param condition Function that returns true if the transition conditions are met */ public function addGlobal(to:Class>, condition:T->Bool) { @@ -534,7 +535,7 @@ class FlxFSMTransitionTable /** * Add a transition directly - * @param transition + * @param transition The transition to add */ public function addTransition(transition:Transition) { @@ -546,7 +547,7 @@ class FlxFSMTransitionTable /** * Sets the starting State - * @param With + * @param with The class of the starting State */ public function start(with:Class>) { @@ -556,8 +557,8 @@ class FlxFSMTransitionTable /** * Replaces given state class with another. - * @param Target State class to replace - * @param Replacement State class to replace with + * @param target State class to replace + * @param replacement State class to replace with */ public function replace(target:Class>, replacement:Class>) { @@ -587,9 +588,9 @@ class FlxFSMTransitionTable /** * Removes a transition condition from the table - * @param From From State - * @param To To State - * @param Condition Condition function + * @param from From State + * @param to To State + * @param condition Condition function * @return True when removed, false if not in table */ public function remove(?from:Class>, ?to:Class>, ?condition:NullBool>) @@ -637,9 +638,9 @@ class FlxFSMTransitionTable /** * Tells if the table contains specific transition or transitions. - * @param From From State - * @param To To State - * @param Condition Condition function + * @param from From State + * @param to To State + * @param condition Condition function * @return True if match found */ public function hasTransition(?from:Class>, ?to:Class>, ?condition:NullBool>):Bool diff --git a/flixel/addons/util/FlxScene.hx b/flixel/addons/util/FlxScene.hx index 251a2d14..36aaa391 100644 --- a/flixel/addons/util/FlxScene.hx +++ b/flixel/addons/util/FlxScene.hx @@ -3,15 +3,15 @@ package flixel.addons.util; import flixel.FlxG; import flixel.FlxObject; import flixel.FlxSprite; +import flixel.addons.display.FlxBackdrop; import flixel.group.FlxGroup; import flixel.text.FlxText; -import flixel.ui.FlxButton; import flixel.tile.FlxTilemap; +import flixel.ui.FlxButton; import flixel.util.FlxAxes; import flixel.util.FlxColor; -import flixel.addons.display.FlxBackdrop; -import openfl.Assets; import haxe.xml.Parser; +import openfl.Assets; using haxe.EnumTools; @@ -458,10 +458,10 @@ class FlxScene } /** - * Gets a specific constant by id. + * Gets a specific constant by ID. * * @param id Constant name. - * @return Bool, Int, Float or String. + * @return Bool, Int, Float or String associated with the ID. */ public function const(id:String):Dynamic { @@ -474,10 +474,10 @@ class FlxScene } /** - * Gets a specific object by id. + * Gets a specific object by ID. * - * @param Id Constant name. - * @return + * @param id Constant name. + * @return The object associated with the ID. */ public function object(id:String):Dynamic { @@ -492,7 +492,7 @@ class FlxScene /** * Helper function to parse Booleans from String to Bool * - * @param Value String value + * @param value String value */ function parseBool(value:String):Bool { diff --git a/flixel/addons/weapon/FlxWeapon.hx b/flixel/addons/weapon/FlxWeapon.hx index 36a664f2..8e2a7099 100644 --- a/flixel/addons/weapon/FlxWeapon.hx +++ b/flixel/addons/weapon/FlxWeapon.hx @@ -38,7 +38,7 @@ import flixel.util.helpers.FlxRange; * TODO: Bullet trails - blur FX style and Missile Command "draw lines" style? (could be another FX plugin) * TODO: Homing Missiles * TODO: Bullet uses random sprite from sprite sheet (for rainbow style bullets), or cycles through them in sequence? - * TODO: Some Weapon base classes like shotgun, lazer, etc? + * TODO: Some Weapon base classes like shotgun, laser, etc? */ typedef FlxWeapon = FlxTypedWeapon; @@ -151,8 +151,8 @@ class FlxTypedWeapon * You should call one of the makeBullet functions to visually create the bullets. * Then either use setDirection with fire() or one of the fireAt functions to launch them. * - * @param Name The name of your weapon (i.e. "lazer" or "shotgun"). For your internal reference really, but could be displayed in-game. - * @param BulletFactory FlxWeapon uses this factory function to actually create a bullet + * @param name The name of your weapon (i.e. "laser" or "shotgun"). For your internal reference really, but could be displayed in-game. + * @param bulletFactory FlxWeapon uses this factory function to actually create a bullet * @param fireFrom enum that describes the weapon firing position, for Example Parent, Position. * @param speedMode enum that describes the bullets speed mode, for Example Velocity, Acceleration. */ @@ -171,10 +171,7 @@ class FlxTypedWeapon /** * Internal function that handles the actual firing of the bullets * - * @param Method - * @param X - * @param Y - * @param Target + * @param Mode Mode to use for firing the bullet * @return True if a bullet was fired or false if one wasn't available. The bullet last fired is stored in FlxWeapon.prevBullet */ function runFire(Mode:FlxWeaponFireMode):Bool @@ -292,7 +289,7 @@ class FlxTypedWeapon * * @param point The to be rotated point * @param origin The to be rotated around point. usually the origin of the parent flxsprite - * @param point the current angle from of the origin. usually the parent angle. + * @param angle the current angle from of the origin. usually the parent angle. * @return The new rotated Point */ public function rotatePoints(point:FlxPoint, origin:FlxPoint, angle:Float):FlxPoint @@ -373,7 +370,7 @@ class FlxTypedWeapon /** * Fires a bullet (if one is available) based on the given angle * - * @param Angle The angle (in degrees) calculated in clockwise positive direction (down = 90 degrees positive, right = 0 degrees positive, up = 90 degrees negative) + * @param angle The angle (in degrees) calculated in clockwise positive direction (down = 90 degrees positive, right = 0 degrees positive, up = 90 degrees negative) * @return True if a bullet was fired or false if one wasn't available. A reference to the bullet fired is stored in FlxWeapon.currentBullet. */ public inline function fireFromAngle(angle:FlxBounds):Bool diff --git a/include.xml b/include.xml index e01219d3..ede498f9 100644 --- a/include.xml +++ b/include.xml @@ -1,6 +1,6 @@ - + From fd87d3c7542d751ba15cf2ac61da5eb5594f5115 Mon Sep 17 00:00:00 2001 From: George Kurelic Date: Fri, 31 Mar 2023 12:50:32 -0500 Subject: [PATCH 02/69] Update README.md shields --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index dca602ce..ea60016a 100644 --- a/README.md +++ b/README.md @@ -2,10 +2,14 @@ [flixel](https://github.com/HaxeFlixel/flixel) | [addons](https://github.com/HaxeFlixel/flixel-addons) | [ui](https://github.com/HaxeFlixel/flixel-ui) | [demos](https://github.com/HaxeFlixel/flixel-demos) | [tools](https://github.com/HaxeFlixel/flixel-tools) | [templates](https://github.com/HaxeFlixel/flixel-templates) | [docs](https://github.com/HaxeFlixel/flixel-docs) | [haxeflixel.com](https://github.com/HaxeFlixel/haxeflixel.com) -[![CI](https://img.shields.io/github/workflow/status/HaxeFlixel/flixel-addons/CI.svg?logo=github)](https://github.com/HaxeFlixel/flixel-addons/actions?query=workflow%3ACI) +[![CI](https://img.shields.io/github/actions/workflow/status/HaxeFlixel/flixel-addons/main.yml?branch=dev&logo=github)](https://github.com/HaxeFlixel/flixel/actions?query=workflow%3ACI) +[![Discord](https://img.shields.io/discord/162395145352904705.svg?logo=discord)](https://discordapp.com/invite/rqEBAgF) [![Haxelib Version](https://badgen.net/haxelib/v/flixel-addons)](https://lib.haxe.org/p/flixel-addons) [![Haxelib Downloads](https://badgen.net/haxelib/d/flixel-addons?color=blue)](https://lib.haxe.org/p/flixel-addons) [![Haxelib License](https://badgen.net/haxelib/license/flixel-addons)](LICENSE.md) +[![Patreon](https://img.shields.io/badge/donate-patreon-blue.svg)](https://www.patreon.com/haxeflixel) + + ## About From ef9599cff362e2e04368cbef165b508bc7efbc8c Mon Sep 17 00:00:00 2001 From: George Kurelic Date: Thu, 13 Apr 2023 12:38:27 -0700 Subject: [PATCH 03/69] flixel 5.3.0 compat (#382) * flixel 5.3.0 compat * use new sound package * ditto --- .../effects/chainable/FlxEffectSprite.hx | 2 +- flixel/addons/text/FlxTypeText.hx | 4 -- .../transition/FlxTransitionableState.hx | 37 +++++++------------ flixel/addons/weapon/FlxWeapon.hx | 4 -- 4 files changed, 15 insertions(+), 32 deletions(-) diff --git a/flixel/addons/effects/chainable/FlxEffectSprite.hx b/flixel/addons/effects/chainable/FlxEffectSprite.hx index 72d42d7d..37d64ba3 100644 --- a/flixel/addons/effects/chainable/FlxEffectSprite.hx +++ b/flixel/addons/effects/chainable/FlxEffectSprite.hx @@ -134,7 +134,7 @@ class FlxEffectSprite extends FlxSprite */ override public function update(elapsed:Float):Void { - if (updateTargetAnimation && target.animation.frames > 1) + if (updateTargetAnimation && target.animation.numFrames > 1) { target.updateAnimation(elapsed); } diff --git a/flixel/addons/text/FlxTypeText.hx b/flixel/addons/text/FlxTypeText.hx index b1c889dc..97bb4389 100644 --- a/flixel/addons/text/FlxTypeText.hx +++ b/flixel/addons/text/FlxTypeText.hx @@ -5,11 +5,7 @@ import flixel.input.keyboard.FlxKey; import flixel.math.FlxMath; import flixel.system.FlxAssets; import flixel.text.FlxText; -#if (flixel >= "5.3.0") import flixel.sound.FlxSound; -#else -import flixel.system.FlxSound; -#end import flixel.math.FlxRandom; import flash.media.Sound; diff --git a/flixel/addons/transition/FlxTransitionableState.hx b/flixel/addons/transition/FlxTransitionableState.hx index f66a53ca..f298cc68 100644 --- a/flixel/addons/transition/FlxTransitionableState.hx +++ b/flixel/addons/transition/FlxTransitionableState.hx @@ -64,7 +64,7 @@ class FlxTransitionableState extends FlxState super(); } - override public function destroy():Void + override function destroy():Void { super.destroy(); transIn = null; @@ -72,36 +72,27 @@ class FlxTransitionableState extends FlxState _onExit = null; } - override public function create():Void + override function create():Void { super.create(); transitionIn(); } - override public function switchTo(nextState:FlxState):Bool + override function startOutro(onOutroComplete:() -> Void) { if (!hasTransOut) - return true; - - if (!_exiting) - transitionToState(nextState); - - return transOutFinished; - } - - function transitionToState(nextState:FlxState):Void - { - // play the exit transition, and when it's done call FlxG.switchState - _exiting = true; - transitionOut(function() - { - FlxG.switchState(nextState); - }); - - if (skipNextTransOut) + onOutroComplete(); + else if (!_exiting) { - skipNextTransOut = false; - finishTransOut(); + // play the exit transition, and when it's done call FlxG.switchState + _exiting = true; + transitionOut(onOutroComplete); + + if (skipNextTransOut) + { + skipNextTransOut = false; + finishTransOut(); + } } } diff --git a/flixel/addons/weapon/FlxWeapon.hx b/flixel/addons/weapon/FlxWeapon.hx index 8e2a7099..289786fe 100644 --- a/flixel/addons/weapon/FlxWeapon.hx +++ b/flixel/addons/weapon/FlxWeapon.hx @@ -12,11 +12,7 @@ import flixel.math.FlxPoint; import flixel.math.FlxRandom; import flixel.math.FlxRect; import flixel.math.FlxVelocity; -#if (flixel >= "5.3.0") import flixel.sound.FlxSound; -#else -import flixel.system.FlxSound; -#end import flixel.tile.FlxTilemap; import flixel.util.helpers.FlxBounds; import flixel.util.helpers.FlxRange; From 65b32d6569b69dec2dec86e9b23e7dcbc780a55d Mon Sep 17 00:00:00 2001 From: DalekCraft <50336832+DalekCraft2@users.noreply.github.com> Date: Mon, 17 Apr 2023 14:00:31 -0400 Subject: [PATCH 04/69] Implement scaling for `FlxTilemapExt` (#384) * Implement scaling for FlxTilemapExt * Change FlxTilemapExt function arguments to start with lowercase characters * Fix small typos in FlxTilemapExt's doc comments * switch to for loop * define vars where they are used * remove mapIndex bounds check * simplify tile range loop vars * add comment back * move comment, add another * fix comment --------- Co-authored-by: George FunBook --- flixel/addons/tile/FlxTilemapExt.hx | 509 +++++++++++++++------------- 1 file changed, 264 insertions(+), 245 deletions(-) diff --git a/flixel/addons/tile/FlxTilemapExt.hx b/flixel/addons/tile/FlxTilemapExt.hx index 0f4d7271..783349ef 100644 --- a/flixel/addons/tile/FlxTilemapExt.hx +++ b/flixel/addons/tile/FlxTilemapExt.hx @@ -5,7 +5,6 @@ import flixel.FlxCamera; import flixel.FlxG; import flixel.FlxObject; import flixel.addons.tile.FlxTileSpecial; -import flixel.addons.tile.FlxTilemapExt; import flixel.graphics.frames.FlxFrame; import flixel.graphics.frames.FlxFramesCollection; import flixel.math.FlxMath; @@ -17,7 +16,14 @@ import flixel.tile.FlxTilemapBuffer; import flixel.util.FlxDestroyUtil; import flixel.util.FlxDirectionFlags; -// TODO: add support for tilemap scaling +using flixel.util.FlxColorTransformUtil; + +#if (haxe_ver >= 4.2) +import Std.isOfType; +#else +import Std.is as isOfType; +#end + // TODO: try to make it cleaner (i mean rendering and animated tiles) /** @@ -100,48 +106,57 @@ class FlxTilemapExt extends FlxTilemap /** * THIS IS A COPY FROM FlxTilemap BUT IT DEALS WITH FLIPPED AND ROTATED TILES - * Internal function that actually renders the tilemap to the tilemap buffer. Called by draw(). - * @param Buffer The FlxTilemapBuffer you are rendering to. - * @param Camera The related FlxCamera, mainly for scroll values. + * Internal function that actually renders the tilemap to the tilemap buffer. Called by draw(). + * + * @param buffer The FlxTilemapBuffer you are rendering to. + * @param camera The related FlxCamera, mainly for scroll values. */ @:access(flixel.FlxCamera) - override function drawTilemap(Buffer:FlxTilemapBuffer, Camera:FlxCamera):Void + override function drawTilemap(buffer:FlxTilemapBuffer, camera:FlxCamera):Void { - var isColored:Bool = ((alpha != 1) || (color != 0xffffff)); + var isColored:Bool = (alpha != 1) || (color != 0xffffff); + // only used for renderTile var drawX:Float = 0; var drawY:Float = 0; - var scaledWidth:Float = tileWidth; - var scaledHeight:Float = tileHeight; + var scaledWidth:Float = 0; + var scaledHeight:Float = 0; + var drawItem = null; var _tileTransformMatrix:FlxMatrix = null; var matrixToUse:FlxMatrix; if (FlxG.renderBlit) { - Buffer.fill(); + buffer.fill(); } else { - getScreenPosition(_point, Camera).copyToFlash(_helperPoint); + getScreenPosition(_point, camera).subtractPoint(offset).copyToFlash(_helperPoint); + + _helperPoint.x = isPixelPerfectRender(camera) ? Math.floor(_helperPoint.x) : _helperPoint.x; + _helperPoint.y = isPixelPerfectRender(camera) ? Math.floor(_helperPoint.y) : _helperPoint.y; + + scaledWidth = scaledTileWidth; + scaledHeight = scaledTileHeight; - _helperPoint.x = isPixelPerfectRender(Camera) ? Math.floor(_helperPoint.x) : _helperPoint.x; - _helperPoint.y = isPixelPerfectRender(Camera) ? Math.floor(_helperPoint.y) : _helperPoint.y; + var hasColorOffsets:Bool = (colorTransform != null && colorTransform.hasRGBAOffsets()); + drawItem = camera.startQuadBatch(graphic, isColored, hasColorOffsets, blend, antialiasing, shader); } // Copy tile images into the tile buffer #if (flixel < "5.2.0") - _point.x = (Camera.scroll.x * scrollFactor.x) - x - offset.x + Camera.viewOffsetX; // modified from getScreenPosition() - _point.y = (Camera.scroll.y * scrollFactor.y) - y - offset.y + Camera.viewOffsetY; + _point.x = (camera.scroll.x * scrollFactor.x) - x - offset.x + camera.viewOffsetX; // modified from getScreenPosition() + _point.y = (camera.scroll.y * scrollFactor.y) - y - offset.y + camera.viewOffsetY; #else - _point.x = (Camera.scroll.x * scrollFactor.x) - x - offset.x + Camera.viewMarginX; // modified from getScreenPosition() - _point.y = (Camera.scroll.y * scrollFactor.y) - y - offset.y + Camera.viewMarginY; + _point.x = (camera.scroll.x * scrollFactor.x) - x - offset.x + camera.viewMarginX; // modified from getScreenPosition() + _point.y = (camera.scroll.y * scrollFactor.y) - y - offset.y + camera.viewMarginY; #end - var screenXInTiles:Int = Math.floor(_point.x / tileWidth); - var screenYInTiles:Int = Math.floor(_point.y / tileHeight); - var screenRows:Int = Buffer.rows; - var screenColumns:Int = Buffer.columns; + var screenXInTiles:Int = Math.floor(_point.x / scaledTileWidth); + var screenYInTiles:Int = Math.floor(_point.y / scaledTileHeight); + var screenRows:Int = buffer.rows; + var screenColumns:Int = buffer.columns; // Bound the upper left corner screenXInTiles = Std.int(FlxMath.bound(screenXInTiles, 0, widthInTiles - screenColumns)); @@ -181,12 +196,12 @@ class FlxTilemapExt extends FlxTilemap { if (isSpecial) { - special.paint(Buffer.pixels, _flashPoint); - Buffer.dirty = (special.dirty || Buffer.dirty); + special.paint(buffer.pixels, _flashPoint); + buffer.dirty = (special.dirty || buffer.dirty); } else if (tile != null && tile.visible && tile.frame.type != FlxFrameType.EMPTY) { - tile.frame.paint(Buffer.pixels, _flashPoint, true); + tile.frame.paint(buffer.pixels, _flashPoint, true); } #if FLX_DEBUG @@ -208,7 +223,7 @@ class FlxTilemapExt extends FlxTilemap } offset.addToFlash(_flashPoint); - Buffer.pixels.copyPixels(debugTile, _debugRect, _flashPoint, null, null, true); + buffer.pixels.copyPixels(debugTile, _debugRect, _flashPoint, null, null, true); offset.subtractFromFlash(_flashPoint); } } @@ -223,6 +238,8 @@ class FlxTilemapExt extends FlxTilemap drawX = _helperPoint.x + (columnIndex % widthInTiles) * scaledWidth; drawY = _helperPoint.y + Math.floor(columnIndex / widthInTiles) * scaledHeight; + _matrix.identity(); + if (isSpecial) { _tileTransformMatrix = special.getMatrix(); @@ -234,8 +251,14 @@ class FlxTilemapExt extends FlxTilemap matrixToUse = _matrix; } + var scaleX:Float = scale.x; + var scaleY:Float = scale.y; + + matrixToUse.scale(scaleX, scaleY); matrixToUse.translate(drawX, drawY); - Camera.drawPixels(frame, matrixToUse, colorTransform, blend); + camera.drawPixels(frame, matrixToUse, colorTransform, blend); + + drawItem.addQuad(frame, matrixToUse, colorTransform); } } @@ -246,24 +269,24 @@ class FlxTilemapExt extends FlxTilemap columnIndex++; } - rowIndex += widthInTiles; if (FlxG.renderBlit) { _flashPoint.y += tileHeight; } + rowIndex += widthInTiles; } - Buffer.x = screenXInTiles * tileWidth; - Buffer.y = screenYInTiles * tileHeight; + buffer.x = screenXInTiles * scaledTileWidth; + buffer.y = screenYInTiles * scaledTileHeight; if (FlxG.renderBlit) { if (isColored) - Buffer.colorTransform(colorTransform); - Buffer.blend = blend; + buffer.colorTransform(colorTransform); + buffer.blend = blend; } - Buffer.dirty = false; + buffer.dirty = false; } /** @@ -311,103 +334,99 @@ class FlxTilemapExt extends FlxTilemap * and calls the specified callback function (if there is one). * Also calls the tile's registered callback if the filter matches. * - * @param Object The FlxObject you are checking for overlaps against. - * @param Callback An optional function that takes the form "myCallback(Object1:FlxObject,Object2:FlxObject)", where Object1 is a FlxTile object, and Object2 is the object passed in in the first parameter of this method. - * @param FlipCallbackParams Used to preserve A-B list ordering from FlxObject.separate() - returns the FlxTile object as the second parameter instead. - * @param Position Optional, specify a custom position for the tilemap (useful for overlapsAt()-type funcitonality). - * - * @return Whether there were overlaps, or if a callback was specified, whatever the return value of the callback was. + * @param object The FlxObject you are checking for overlaps against. + * @param callback An optional function that takes the form "myCallback(Object1:FlxObject,Object2:FlxObject)", where Object1 is a FlxTile object, and Object2 is the object passed in in the first parameter of this method. + * @param flipCallbackParams Used to preserve A-B list ordering from FlxObject.separate() - returns the FlxTile object as the second parameter instead. + * @param position Optional, specify a custom position for the tilemap (useful for overlapsAt()-type functionality). + * @return Whether there were overlaps, or if a callback was specified, whatever the return value of the callback was. */ - override public function overlapsWithCallback(Object:FlxObject, ?Callback:FlxObject->FlxObject->Bool, FlipCallbackParams:Bool = false, - ?Position:FlxPoint):Bool + override public function overlapsWithCallback(object:FlxObject, ?callback:FlxObject->FlxObject->Bool, flipCallbackParams:Bool = false, + ?position:FlxPoint):Bool { var results:Bool = false; - var X:Float = x; - var Y:Float = y; + var xPos:Float = x; + var yPos:Float = y; - if (Position != null) + if (position != null) { - X = Position.x; - Y = Position.y; + xPos = position.x; + yPos = position.y; + position.putWeak(); + } + + inline function bindInt(value:Int, min:Int, max:Int) + { + return Std.int(FlxMath.bound(value, min, max)); } - // Figure out what tiles we need to check against - var selectionX:Int = Math.floor((Object.x - X) / tileWidth); - var selectionY:Int = Math.floor((Object.y - Y) / tileHeight); - var selectionWidth:Int = selectionX + (Math.ceil(Object.width / tileWidth)) + 1; - var selectionHeight:Int = selectionY + Math.ceil(Object.height / tileHeight) + 1; + // Figure out what tiles we need to check against, and bind them by the map edges + final minTileX:Int = bindInt(Math.floor((object.x - xPos) / scaledTileWidth), 0, widthInTiles); + final minTileY:Int = bindInt(Math.floor((object.y - yPos) / scaledTileHeight), 0, heightInTiles); + final maxTileX:Int = bindInt(Math.ceil((object.x + object.width - xPos) / scaledTileWidth), 0, widthInTiles); + final maxTileY:Int = bindInt(Math.ceil((object.y + object.height - yPos) / scaledTileHeight), 0, heightInTiles); - // Then bound these coordinates by the map edges - selectionX = FlxMath.maxInt(selectionX, 0); - selectionY = FlxMath.maxInt(selectionY, 0); - selectionWidth = FlxMath.minInt(selectionWidth, widthInTiles); - selectionHeight = FlxMath.minInt(selectionHeight, heightInTiles); + // Cache tilemap movement + final deltaX:Float = xPos - last.x; + final deltaY:Float = yPos - last.y; - // Then loop through this selection of tiles and call FlxObject.separate() accordingly - var rowStart:Int = selectionY * widthInTiles; - var row:Int = selectionY; - var column:Int; - var tile:FlxTile; - var overlapFound:Bool; - var deltaX:Float = X - last.x; - var deltaY:Float = Y - last.y; - - while (row < selectionHeight) + // Loop through the range of tiles and call the callback on them, accordingly + for (row in minTileY...maxTileY) { - column = selectionX; - - while (column < selectionWidth) + for (column in minTileX...maxTileX) { - overlapFound = false; - tile = _tileObjects[_data[rowStart + column]]; + final mapIndex:Int = (row * widthInTiles) + column; + final dataIndex:Int = _data[mapIndex]; + if (dataIndex < 0) + continue; - if (tile.allowCollisions != 0) + final tile = _tileObjects[dataIndex]; + + if (tile.allowCollisions != NONE) { - tile.x = X + column * tileWidth; - tile.y = Y + row * tileHeight; + var overlapFound = false; + + tile.width = scaledTileWidth; + tile.height = scaledTileHeight; + tile.x = xPos + column * tile.width; + tile.y = yPos + row * tile.height; tile.last.x = tile.x - deltaX; tile.last.y = tile.y - deltaY; - if (Callback != null) + if (callback != null) { - if (FlipCallbackParams) + if (flipCallbackParams) { - overlapFound = Callback(Object, tile); + overlapFound = callback(object, tile); } else { - overlapFound = Callback(tile, Object); + overlapFound = callback(tile, object); } } else { - overlapFound = (Object.x + Object.width > tile.x) && (Object.x < tile.x + tile.width) && (Object.y + Object.height > tile.y) - && (Object.y < tile.y + tile.height); + overlapFound = (object.x + object.width > tile.x) && (object.x < tile.x + tile.width) && (object.y + object.height > tile.y) + && (object.y < tile.y + tile.height); } // New generalized slope collisions if (overlapFound || (!overlapFound && checkArrays(tile.index))) { - if ((tile.callbackFunction != null) - && ((tile.filter == null) || #if (haxe_ver >= 4.2) Std.isOfType #else Std.is #end (Object, tile.filter))) + if ((tile.callbackFunction != null) && ((tile.filter == null) || isOfType(object, tile.filter))) { - tile.mapIndex = rowStart + column; - tile.callbackFunction(tile, Object); + tile.mapIndex = mapIndex; + tile.callbackFunction(tile, object); } results = true; } } - else if ((tile.callbackFunction != null) - && ((tile.filter == null) || #if (haxe_ver >= 4.2) Std.isOfType #else Std.is #end (Object, tile.filter))) + else if ((tile.callbackFunction != null) && ((tile.filter == null) || isOfType(object, tile.filter))) { - tile.mapIndex = rowStart + column; - tile.callbackFunction(tile, Object); + tile.mapIndex = mapIndex; + tile.callbackFunction(tile, object); } - column++; } - rowStart += widthInTiles; - row++; } return results; @@ -416,7 +435,7 @@ class FlxTilemapExt extends FlxTilemap /** * Set glue to force contact with slopes and a slow down factor while climbing * - * @param downwardsGlue Activate/Deactivate glue on slopes on the + * @param downwardsGlue Activate/Deactivate glue on slopes * @param slopeSlowDownFactor A slowing down factor while climbing slopes, from 0.0 to 1.0, By default 0.0, no slow down. * @param velocityYDownSlope The maximum velocity Y down a slope, it should be high enough to be able to use downwardsGlue. Default to 200. * @@ -432,28 +451,28 @@ class FlxTilemapExt extends FlxTilemap /** * Sets the slope arrays, which define which tiles are treated as slopes. * - * @param Northwest An array containing the numbers of the tiles facing Northwest to be treated as floor tiles with a slope on the left. - * @param Northeast An array containing the numbers of the tiles facing Northeast to be treated as floor tiles with a slope on the right. - * @param Southwest An array containing the numbers of the tiles facing Southwest to be treated as ceiling tiles with a slope on the left. - * @param Southeast An array containing the numbers of the tiles facing Southeast to be treated as ceiling tiles with a slope on the right. + * @param northwest An array containing the numbers of the tiles facing northwest to be treated as floor tiles with a slope on the left. + * @param northeast An array containing the numbers of the tiles facing northeast to be treated as floor tiles with a slope on the right. + * @param southwest An array containing the numbers of the tiles facing southwest to be treated as ceiling tiles with a slope on the left. + * @param southeast An array containing the numbers of the tiles facing southeast to be treated as ceiling tiles with a slope on the right. */ - public function setSlopes(?Northwest:Array, ?Northeast:Array, ?Southwest:Array, ?Southeast:Array):Void + public function setSlopes(?northwest:Array, ?northeast:Array, ?southwest:Array, ?southeast:Array):Void { - if (Northwest != null) + if (northwest != null) { - _slopeNorthwest = Northwest; + _slopeNorthwest = northwest; } - if (Northeast != null) + if (northeast != null) { - _slopeNortheast = Northeast; + _slopeNortheast = northeast; } - if (Southwest != null) + if (southwest != null) { - _slopeSouthwest = Southwest; + _slopeSouthwest = southwest; } - if (Southeast != null) + if (southeast != null) { - _slopeSoutheast = Southeast; + _slopeSoutheast = southeast; } setSlopeProperties(); } @@ -461,19 +480,19 @@ class FlxTilemapExt extends FlxTilemap /** * Sets the gentle slopes. About 26.5 degrees. * - * @param ThickTiles An array containing the numbers of the tiles to be treated as thick slope. - * @param ThinTiles An array containing the numbers of the tiles to be treated as thin slope. + * @param thickTiles An array containing the numbers of the tiles to be treated as thick slope. + * @param thinTiles An array containing the numbers of the tiles to be treated as thin slope. */ - public function setGentle(ThickTiles:Array, ThinTiles:Array) + public function setGentle(thickTiles:Array, thinTiles:Array) { - if (ThickTiles != null) + if (thickTiles != null) { - _slopeThickGentle = ThickTiles; + _slopeThickGentle = thickTiles; } - if (ThinTiles != null) + if (thinTiles != null) { - _slopeThinGentle = ThinTiles; + _slopeThinGentle = thinTiles; for (tile in _slopeThinGentle) { _tileObjects[tile].allowCollisions = (_slopeSouthwest.indexOf(tile) >= 0 || _slopeSoutheast.indexOf(tile) >= 0) ? CEILING : FLOOR; @@ -484,19 +503,19 @@ class FlxTilemapExt extends FlxTilemap /** * Sets the steep slopes. About 63.5 degrees. * - * @param ThickTiles An array containing the numbers of the tiles to be treated as thick slope. - * @param ThinTiles An array containing the numbers of the tiles to be treated as thin slope. + * @param thickTiles An array containing the numbers of the tiles to be treated as thick slope. + * @param thinTiles An array containing the numbers of the tiles to be treated as thin slope. */ - public function setSteep(ThickTiles:Array, ThinTiles:Array) + public function setSteep(thickTiles:Array, thinTiles:Array) { - if (ThickTiles != null) + if (thickTiles != null) { - _slopeThickSteep = ThickTiles; + _slopeThickSteep = thickTiles; } - if (ThinTiles != null) + if (thinTiles != null) { - _slopeThinSteep = ThinTiles; + _slopeThinSteep = thinTiles; for (tile in _slopeThinSteep) { _tileObjects[tile].allowCollisions = (_slopeSouthwest.indexOf(tile) >= 0 || _slopeNorthwest.indexOf(tile) >= 0) ? RIGHT : LEFT; @@ -507,342 +526,342 @@ class FlxTilemapExt extends FlxTilemap /** * Internal helper functions for comparing a tile to the slope arrays to see if a tile should be treated as STEEP or GENTLE slope. * - * @param TileIndex The Tile Index number of the Tile you want to check. + * @param tileIndex The Tile Index number of the Tile you want to check. * @return True if the tile is listed in one of the slope arrays. Otherwise false. */ - function checkThickGentle(TileIndex:Int):Bool + function checkThickGentle(tileIndex:Int):Bool { - return _slopeThickGentle.indexOf(TileIndex) >= 0; + return _slopeThickGentle.indexOf(tileIndex) >= 0; } - function checkThinGentle(TileIndex:Int):Bool + function checkThinGentle(tileIndex:Int):Bool { - return _slopeThinGentle.indexOf(TileIndex) >= 0; + return _slopeThinGentle.indexOf(tileIndex) >= 0; } - function checkThickSteep(TileIndex:Int):Bool + function checkThickSteep(tileIndex:Int):Bool { - return _slopeThickSteep.indexOf(TileIndex) >= 0; + return _slopeThickSteep.indexOf(tileIndex) >= 0; } - function checkThinSteep(TileIndex:Int):Bool + function checkThinSteep(tileIndex:Int):Bool { - return _slopeThinSteep.indexOf(TileIndex) >= 0; + return _slopeThinSteep.indexOf(tileIndex) >= 0; } /** * Bounds the slope point to the slope * - * @param Slope The slope to fix the slopePoint for + * @param slope The slope to fix the slopePoint for */ - function fixSlopePoint(Slope:FlxTile):Void + function fixSlopePoint(slope:FlxTile):Void { - _slopePoint.x = FlxMath.bound(_slopePoint.x, Slope.x, Slope.x + tileWidth); - _slopePoint.y = FlxMath.bound(_slopePoint.y, Slope.y, Slope.y + tileHeight); + _slopePoint.x = FlxMath.bound(_slopePoint.x, slope.x, slope.x + scaledTileWidth); + _slopePoint.y = FlxMath.bound(_slopePoint.y, slope.y, slope.y + scaledTileHeight); } /** - * Ss called if an object collides with a floor slope + * Is called if an object collides with a floor slope * - * @param Slope The floor slope - * @param Object The object that collides with that slope + * @param slope The floor slope + * @param object The object that collides with that slope */ - function onCollideFloorSlope(Slope:FlxObject, Object:FlxObject):Void + function onCollideFloorSlope(slope:FlxObject, object:FlxObject):Void { // Set the object's touching flag - Object.touching = FLOOR; + object.touching = FLOOR; // Adjust the object's velocity if (_downwardsGlue) - Object.velocity.y = _velocityYDownSlope; + object.velocity.y = _velocityYDownSlope; else - Object.velocity.y = Math.min(Object.velocity.y, 0); + object.velocity.y = Math.min(object.velocity.y, 0); // Reposition the object - Object.y = _slopePoint.y - Object.height; + object.y = _slopePoint.y - object.height; - if (Object.y < Slope.y - Object.height) + if (object.y < slope.y - object.height) { - Object.y = Slope.y - Object.height; + object.y = slope.y - object.height; } } /** * Is called if an object collides with a ceiling slope * - * @param Slope The ceiling slope - * @param Object The object that collides with that slope + * @param slope The ceiling slope + * @param object The object that collides with that slope */ - function onCollideCeilSlope(Slope:FlxObject, Object:FlxObject):Void + function onCollideCeilSlope(slope:FlxObject, object:FlxObject):Void { // Set the object's touching flag - Object.touching = CEILING; + object.touching = CEILING; // Adjust the object's velocity - Object.velocity.y = Math.max(Object.velocity.y, 0); + object.velocity.y = Math.max(object.velocity.y, 0); // Reposition the object - Object.y = _slopePoint.y; + object.y = _slopePoint.y; - if (Object.y > Slope.y + tileHeight) + if (object.y > slope.y + scaledTileHeight) { - Object.y = Slope.y + tileHeight; + object.y = slope.y + scaledTileHeight; } } /** * Solves collision against a left-sided floor slope * - * @param Slope The slope to check against - * @param Object The object that collides with the slope + * @param slope The slope to check against + * @param object The object that collides with the slope */ - function solveCollisionSlopeNorthwest(Slope:FlxObject, Object:FlxObject):Void + function solveCollisionSlopeNorthwest(slope:FlxObject, object:FlxObject):Void { - if (Object.x + Object.width > Slope.x + Slope.width + _snapping) + if (object.x + object.width > slope.x + slope.width + _snapping) { return; } // Calculate the corner point of the object - _objPoint.x = Math.floor(Object.x + Object.width + _snapping); - _objPoint.y = Math.floor(Object.y + Object.height); + _objPoint.x = Math.floor(object.x + object.width + _snapping); + _objPoint.y = Math.floor(object.y + object.height); // Calculate position of the point on the slope that the object might overlap // this would be one side of the object projected onto the slope's surface _slopePoint.x = _objPoint.x; - _slopePoint.y = (Slope.y + tileHeight) - (_slopePoint.x - Slope.x); + _slopePoint.y = (slope.y + scaledTileHeight) - (_slopePoint.x - slope.x); - var tileId:Int = cast(Slope, FlxTile).index; + var tileId:Int = cast(slope, FlxTile).index; if (checkThinSteep(tileId)) { - if (_slopePoint.x - Slope.x <= tileWidth / 2) + if (_slopePoint.x - slope.x <= scaledTileWidth / 2) { return; } else { - _slopePoint.y = Slope.y + tileHeight * (2 - (2 * (_slopePoint.x - Slope.x) / tileWidth)) + _snapping; - if (_downwardsGlue && Object.velocity.x > 0) - Object.velocity.x *= 1 - (1 - _slopeSlowDownFactor) * 3; + _slopePoint.y = slope.y + scaledTileHeight * (2 - (2 * (_slopePoint.x - slope.x) / scaledTileWidth)) + _snapping; + if (_downwardsGlue && object.velocity.x > 0) + object.velocity.x *= 1 - (1 - _slopeSlowDownFactor) * 3; } } else if (checkThickSteep(tileId)) { - _slopePoint.y = Slope.y + tileHeight * (1 - (2 * ((_slopePoint.x - Slope.x) / tileWidth))) + _snapping; - if (_downwardsGlue && Object.velocity.x > 0) - Object.velocity.x *= 1 - (1 - _slopeSlowDownFactor) * 3; + _slopePoint.y = slope.y + scaledTileHeight * (1 - (2 * ((_slopePoint.x - slope.x) / scaledTileWidth))) + _snapping; + if (_downwardsGlue && object.velocity.x > 0) + object.velocity.x *= 1 - (1 - _slopeSlowDownFactor) * 3; } else if (checkThickGentle(tileId)) { - _slopePoint.y = Slope.y + (tileHeight - _slopePoint.x + Slope.x) / 2; - if (_downwardsGlue && Object.velocity.x > 0) - Object.velocity.x *= _slopeSlowDownFactor; + _slopePoint.y = slope.y + (scaledTileHeight - _slopePoint.x + slope.x) / 2; + if (_downwardsGlue && object.velocity.x > 0) + object.velocity.x *= _slopeSlowDownFactor; } else if (checkThinGentle(tileId)) { - _slopePoint.y = Slope.y + tileHeight - (_slopePoint.x - Slope.x) / 2; - if (_downwardsGlue && Object.velocity.x > 0) - Object.velocity.x *= _slopeSlowDownFactor; + _slopePoint.y = slope.y + scaledTileHeight - (_slopePoint.x - slope.x) / 2; + if (_downwardsGlue && object.velocity.x > 0) + object.velocity.x *= _slopeSlowDownFactor; } else { - if (_downwardsGlue && Object.velocity.x > 0) - Object.velocity.x *= _slopeSlowDownFactor; + if (_downwardsGlue && object.velocity.x > 0) + object.velocity.x *= _slopeSlowDownFactor; } // Fix the slope point to the slope tile - fixSlopePoint(cast(Slope, FlxTile)); + fixSlopePoint(cast(slope, FlxTile)); // Check if the object is inside the slope - if (_objPoint.x > Slope.x + _snapping - && _objPoint.x < Slope.x + tileWidth + Object.width + _snapping + if (_objPoint.x > slope.x + _snapping + && _objPoint.x < slope.x + scaledTileWidth + object.width + _snapping && _objPoint.y >= _slopePoint.y - && _objPoint.y <= Slope.y + tileHeight) + && _objPoint.y <= slope.y + scaledTileHeight) { // Call the collide function for the floor slope - onCollideFloorSlope(Slope, Object); + onCollideFloorSlope(slope, object); } } /** * Solves collision against a right-sided floor slope * - * @param Slope The slope to check against - * @param Object The object that collides with the slope + * @param slope The slope to check against + * @param object The object that collides with the slope */ - function solveCollisionSlopeNortheast(Slope:FlxObject, Object:FlxObject):Void + function solveCollisionSlopeNortheast(slope:FlxObject, object:FlxObject):Void { - if (Object.x < Slope.x - _snapping) + if (object.x < slope.x - _snapping) { return; } // Calculate the corner point of the object - _objPoint.x = Math.floor(Object.x - _snapping); - _objPoint.y = Math.floor(Object.y + Object.height); + _objPoint.x = Math.floor(object.x - _snapping); + _objPoint.y = Math.floor(object.y + object.height); // Calculate position of the point on the slope that the object might overlap // this would be one side of the object projected onto the slope's surface _slopePoint.x = _objPoint.x; - _slopePoint.y = (Slope.y + tileHeight) - (Slope.x - _slopePoint.x + tileWidth); + _slopePoint.y = (slope.y + scaledTileHeight) - (slope.x - _slopePoint.x + scaledTileWidth); - var tileId:Int = cast(Slope, FlxTile).index; + var tileId:Int = cast(slope, FlxTile).index; if (checkThinSteep(tileId)) { - if (_slopePoint.x - Slope.x >= tileWidth / 2) + if (_slopePoint.x - slope.x >= scaledTileWidth / 2) { return; } else { - _slopePoint.y = Slope.y + tileHeight * 2 * ((_slopePoint.x - Slope.x) / tileWidth) + _snapping; + _slopePoint.y = slope.y + scaledTileHeight * 2 * ((_slopePoint.x - slope.x) / scaledTileWidth) + _snapping; } - if (_downwardsGlue && Object.velocity.x < 0) - Object.velocity.x *= 1 - (1 - _slopeSlowDownFactor) * 3; + if (_downwardsGlue && object.velocity.x < 0) + object.velocity.x *= 1 - (1 - _slopeSlowDownFactor) * 3; } else if (checkThickSteep(tileId)) { - _slopePoint.y = Slope.y - tileHeight * (1 + (2 * ((Slope.x - _slopePoint.x) / tileWidth))) + _snapping; - if (_downwardsGlue && Object.velocity.x < 0) - Object.velocity.x *= 1 - (1 - _slopeSlowDownFactor) * 3; + _slopePoint.y = slope.y - scaledTileHeight * (1 + (2 * ((slope.x - _slopePoint.x) / scaledTileWidth))) + _snapping; + if (_downwardsGlue && object.velocity.x < 0) + object.velocity.x *= 1 - (1 - _slopeSlowDownFactor) * 3; } else if (checkThickGentle(tileId)) { - _slopePoint.y = Slope.y + (tileHeight - Slope.x + _slopePoint.x - tileWidth) / 2; - if (_downwardsGlue && Object.velocity.x < 0) - Object.velocity.x *= _slopeSlowDownFactor; + _slopePoint.y = slope.y + (scaledTileHeight - slope.x + _slopePoint.x - scaledTileWidth) / 2; + if (_downwardsGlue && object.velocity.x < 0) + object.velocity.x *= _slopeSlowDownFactor; } else if (checkThinGentle(tileId)) { - _slopePoint.y = Slope.y + tileHeight - (Slope.x - _slopePoint.x + tileWidth) / 2; - if (_downwardsGlue && Object.velocity.x < 0) - Object.velocity.x *= _slopeSlowDownFactor; + _slopePoint.y = slope.y + scaledTileHeight - (slope.x - _slopePoint.x + scaledTileWidth) / 2; + if (_downwardsGlue && object.velocity.x < 0) + object.velocity.x *= _slopeSlowDownFactor; } else { - if (_downwardsGlue && Object.velocity.x < 0) - Object.velocity.x *= _slopeSlowDownFactor; + if (_downwardsGlue && object.velocity.x < 0) + object.velocity.x *= _slopeSlowDownFactor; } // Fix the slope point to the slope tile - fixSlopePoint(cast(Slope, FlxTile)); + fixSlopePoint(cast(slope, FlxTile)); // Check if the object is inside the slope - if (_objPoint.x > Slope.x - Object.width - _snapping - && _objPoint.x < Slope.x + tileWidth + _snapping + if (_objPoint.x > slope.x - object.width - _snapping + && _objPoint.x < slope.x + scaledTileWidth + _snapping && _objPoint.y >= _slopePoint.y - && _objPoint.y <= Slope.y + tileHeight) + && _objPoint.y <= slope.y + scaledTileHeight) { // Call the collide function for the floor slope - onCollideFloorSlope(Slope, Object); + onCollideFloorSlope(slope, object); } } /** * Solves collision against a left-sided ceiling slope * - * @param Slope The slope to check against - * @param Object The object that collides with the slope + * @param slope The slope to check against + * @param object The object that collides with the slope */ - function solveCollisionSlopeSouthwest(Slope:FlxObject, Object:FlxObject):Void + function solveCollisionSlopeSouthwest(slope:FlxObject, object:FlxObject):Void { // Calculate the corner point of the object - _objPoint.x = Math.floor(Object.x + Object.width + _snapping); - _objPoint.y = Math.ceil(Object.y); + _objPoint.x = Math.floor(object.x + object.width + _snapping); + _objPoint.y = Math.ceil(object.y); // Calculate position of the point on the slope that the object might overlap // this would be one side of the object projected onto the slope's surface _slopePoint.x = _objPoint.x; - _slopePoint.y = Slope.y + (_slopePoint.x - Slope.x); + _slopePoint.y = slope.y + (_slopePoint.x - slope.x); - var tileId:Int = cast(Slope, FlxTile).index; + var tileId:Int = cast(slope, FlxTile).index; if (checkThinSteep(tileId)) { - if (_slopePoint.x - Slope.x <= tileWidth / 2) + if (_slopePoint.x - slope.x <= scaledTileWidth / 2) { return; } else { - _slopePoint.y = Slope.y - tileHeight * (1 + (2 * ((Slope.x - _slopePoint.x) / tileWidth))) - _snapping; + _slopePoint.y = slope.y - scaledTileHeight * (1 + (2 * ((slope.x - _slopePoint.x) / scaledTileWidth))) - _snapping; } } else if (checkThickSteep(tileId)) { - _slopePoint.y = Slope.y + tileHeight * 2 * ((_slopePoint.x - Slope.x) / tileWidth) - _snapping; + _slopePoint.y = slope.y + scaledTileHeight * 2 * ((_slopePoint.x - slope.x) / scaledTileWidth) - _snapping; } else if (checkThickGentle(tileId)) { - _slopePoint.y = Slope.y + tileHeight - (Slope.x - _slopePoint.x + tileWidth) / 2; + _slopePoint.y = slope.y + scaledTileHeight - (slope.x - _slopePoint.x + scaledTileWidth) / 2; } else if (checkThinGentle(tileId)) { - _slopePoint.y = Slope.y + (tileHeight - Slope.x + _slopePoint.x - tileWidth) / 2; + _slopePoint.y = slope.y + (scaledTileHeight - slope.x + _slopePoint.x - scaledTileWidth) / 2; } // Fix the slope point to the slope tile - fixSlopePoint(cast(Slope, FlxTile)); + fixSlopePoint(cast(slope, FlxTile)); // Check if the object is inside the slope - if (_objPoint.x > Slope.x + _snapping - && _objPoint.x < Slope.x + tileWidth + Object.width + _snapping + if (_objPoint.x > slope.x + _snapping + && _objPoint.x < slope.x + scaledTileWidth + object.width + _snapping && _objPoint.y <= _slopePoint.y - && _objPoint.y >= Slope.y) + && _objPoint.y >= slope.y) { // Call the collide function for the floor slope - onCollideCeilSlope(Slope, Object); + onCollideCeilSlope(slope, object); } } /** * Solves collision against a right-sided ceiling slope * - * @param Slope The slope to check against - * @param Object The object that collides with the slope + * @param slope The slope to check against + * @param object The object that collides with the slope */ - function solveCollisionSlopeSoutheast(Slope:FlxObject, Object:FlxObject):Void + function solveCollisionSlopeSoutheast(slope:FlxObject, object:FlxObject):Void { // Calculate the corner point of the object - _objPoint.x = Math.floor(Object.x - _snapping); - _objPoint.y = Math.ceil(Object.y); + _objPoint.x = Math.floor(object.x - _snapping); + _objPoint.y = Math.ceil(object.y); // Calculate position of the point on the slope that the object might overlap // this would be one side of the object projected onto the slope's surface _slopePoint.x = _objPoint.x; - _slopePoint.y = (Slope.y) + (Slope.x - _slopePoint.x + tileWidth); + _slopePoint.y = (slope.y) + (slope.x - _slopePoint.x + scaledTileWidth); - var tileId:Int = cast(Slope, FlxTile).index; + var tileId:Int = cast(slope, FlxTile).index; if (checkThinSteep(tileId)) { - if (_slopePoint.x - Slope.x >= tileWidth / 2) + if (_slopePoint.x - slope.x >= scaledTileWidth / 2) { return; } else { - _slopePoint.y = Slope.y + tileHeight * (1 - (2 * ((_slopePoint.x - Slope.x) / tileWidth))) - _snapping; + _slopePoint.y = slope.y + scaledTileHeight * (1 - (2 * ((_slopePoint.x - slope.x) / scaledTileWidth))) - _snapping; } } else if (checkThickSteep(tileId)) { - _slopePoint.y = Slope.y + tileHeight * (2 - (2 * (_slopePoint.x - Slope.x) / tileWidth)) - _snapping; + _slopePoint.y = slope.y + scaledTileHeight * (2 - (2 * (_slopePoint.x - slope.x) / scaledTileWidth)) - _snapping; } else if (checkThickGentle(tileId)) { - _slopePoint.y = Slope.y + tileHeight - (_slopePoint.x - Slope.x) / 2; + _slopePoint.y = slope.y + scaledTileHeight - (_slopePoint.x - slope.x) / 2; } else if (checkThinGentle(tileId)) { - _slopePoint.y = Slope.y + (tileHeight - _slopePoint.x + Slope.x) / 2; + _slopePoint.y = slope.y + (scaledTileHeight - _slopePoint.x + slope.x) / 2; } // Fix the slope point to the slope tile - fixSlopePoint(cast(Slope, FlxTile)); + fixSlopePoint(cast(slope, FlxTile)); // Check if the object is inside the slope - if (_objPoint.x > Slope.x - Object.width - _snapping - && _objPoint.x < Slope.x + tileWidth + _snapping + if (_objPoint.x > slope.x - object.width - _snapping + && _objPoint.x < slope.x + scaledTileWidth + _snapping && _objPoint.y <= _slopePoint.y - && _objPoint.y >= Slope.y) + && _objPoint.y >= slope.y) { // Call the collide function for the floor slope - onCollideCeilSlope(Slope, Object); + onCollideCeilSlope(slope, object); } } @@ -873,15 +892,15 @@ class FlxTilemapExt extends FlxTilemap /** * Internal helper function for comparing a tile to the slope arrays to see if a tile should be treated as a slope. * - * @param TileIndex The Tile Index number of the Tile you want to check. + * @param tileIndex The Tile Index number of the Tile you want to check. * @return True if the tile is listed in one of the slope arrays. Otherwise false. */ - function checkArrays(TileIndex:Int):Bool + function checkArrays(tileIndex:Int):Bool { - return _slopeNorthwest.indexOf(TileIndex) >= 0 - || _slopeNortheast.indexOf(TileIndex) >= 0 - || _slopeSouthwest.indexOf(TileIndex) >= 0 - || _slopeSoutheast.indexOf(TileIndex) >= 0; + return _slopeNorthwest.indexOf(tileIndex) >= 0 + || _slopeNortheast.indexOf(tileIndex) >= 0 + || _slopeSouthwest.indexOf(tileIndex) >= 0 + || _slopeSoutheast.indexOf(tileIndex) >= 0; } override function set_frames(value:FlxFramesCollection):FlxFramesCollection From a798138394c9b3c2c41e35f67d0b776dfc082bab Mon Sep 17 00:00:00 2001 From: George Kurelic Date: Wed, 19 Apr 2023 14:03:40 -0700 Subject: [PATCH 05/69] Haxe ver 4.2.5 (#386) * min haxe version 4.2.5 * update github action --- .github/workflows/main.yml | 2 +- flixel/addons/editors/ogmo/FlxOgmoLoader.hx | 4 ---- flixel/addons/editors/pex/FlxPexParser.hx | 4 ---- flixel/addons/editors/tiled/TiledGroupLayer.hx | 4 ---- flixel/addons/editors/tiled/TiledImageLayer.hx | 4 ---- flixel/addons/editors/tiled/TiledImageTile.hx | 4 ---- flixel/addons/editors/tiled/TiledLayer.hx | 4 ---- flixel/addons/editors/tiled/TiledMap.hx | 4 ---- flixel/addons/editors/tiled/TiledObject.hx | 4 ---- flixel/addons/editors/tiled/TiledObjectLayer.hx | 4 ---- flixel/addons/editors/tiled/TiledPropertySet.hx | 6 +----- flixel/addons/editors/tiled/TiledTileLayer.hx | 4 ---- flixel/addons/editors/tiled/TiledTileSet.hx | 6 +----- flixel/addons/tile/FlxTilemapExt.hx | 10 ++-------- flixel/addons/util/FlxScene.hx | 4 ---- 15 files changed, 5 insertions(+), 63 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index dcedf6a5..5ecc4c6c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -6,7 +6,7 @@ jobs: build: strategy: matrix: - haxe-version: ["4.0.5", stable, nightly] + haxe-version: ["4.2.5", stable, nightly] target: [html5, hl, neko, flash, cpp] fail-fast: false runs-on: ubuntu-latest diff --git a/flixel/addons/editors/ogmo/FlxOgmoLoader.hx b/flixel/addons/editors/ogmo/FlxOgmoLoader.hx index 2c1ea6fc..96453d54 100644 --- a/flixel/addons/editors/ogmo/FlxOgmoLoader.hx +++ b/flixel/addons/editors/ogmo/FlxOgmoLoader.hx @@ -6,11 +6,7 @@ import flixel.system.FlxAssets.FlxTilemapGraphicAsset; import flixel.tile.FlxTilemap; import haxe.xml.Parser; import openfl.Assets; -#if haxe4 import haxe.xml.Access; -#else -import haxe.xml.Fast as Access; -#end /** * This is for loading maps made with OGMO Editor 2. For loading maps made with OGMO Editor 3, use `FlxOgmo3Loader` diff --git a/flixel/addons/editors/pex/FlxPexParser.hx b/flixel/addons/editors/pex/FlxPexParser.hx index f5751c91..daba70e4 100644 --- a/flixel/addons/editors/pex/FlxPexParser.hx +++ b/flixel/addons/editors/pex/FlxPexParser.hx @@ -8,11 +8,7 @@ import flixel.util.FlxColor; import haxe.xml.Parser; import openfl.Assets; import openfl.display.BlendMode; -#if haxe4 import haxe.xml.Access; -#else -import haxe.xml.Fast as Access; -#end /** * Parser for particle files created with "Starling Particle Editor" or "Particle Designer". diff --git a/flixel/addons/editors/tiled/TiledGroupLayer.hx b/flixel/addons/editors/tiled/TiledGroupLayer.hx index c803a04f..96085663 100644 --- a/flixel/addons/editors/tiled/TiledGroupLayer.hx +++ b/flixel/addons/editors/tiled/TiledGroupLayer.hx @@ -2,11 +2,7 @@ package flixel.addons.editors.tiled; import flixel.addons.editors.tiled.TiledLayer.TiledLayerType; import flixel.util.FlxColor; -#if haxe4 import haxe.xml.Access; -#else -import haxe.xml.Fast as Access; -#end /** * Copyright (c) 2013 by Samuel Batista diff --git a/flixel/addons/editors/tiled/TiledImageLayer.hx b/flixel/addons/editors/tiled/TiledImageLayer.hx index 1d300d27..5e5720c7 100644 --- a/flixel/addons/editors/tiled/TiledImageLayer.hx +++ b/flixel/addons/editors/tiled/TiledImageLayer.hx @@ -1,10 +1,6 @@ package flixel.addons.editors.tiled; -#if haxe4 import haxe.xml.Access; -#else -import haxe.xml.Fast as Access; -#end class TiledImageLayer extends TiledLayer { diff --git a/flixel/addons/editors/tiled/TiledImageTile.hx b/flixel/addons/editors/tiled/TiledImageTile.hx index 4bfd6184..6b109c6a 100644 --- a/flixel/addons/editors/tiled/TiledImageTile.hx +++ b/flixel/addons/editors/tiled/TiledImageTile.hx @@ -1,10 +1,6 @@ package flixel.addons.editors.tiled; -#if haxe4 import haxe.xml.Access; -#else -import haxe.xml.Fast as Access; -#end /** * Copyright (c) 2013 by Samuel Batista diff --git a/flixel/addons/editors/tiled/TiledLayer.hx b/flixel/addons/editors/tiled/TiledLayer.hx index 9da4d249..6fc41945 100644 --- a/flixel/addons/editors/tiled/TiledLayer.hx +++ b/flixel/addons/editors/tiled/TiledLayer.hx @@ -1,11 +1,7 @@ package flixel.addons.editors.tiled; import flash.utils.ByteArray; -#if haxe4 import haxe.xml.Access; -#else -import haxe.xml.Fast as Access; -#end /** * Base class for Tiled object and tile layers diff --git a/flixel/addons/editors/tiled/TiledMap.hx b/flixel/addons/editors/tiled/TiledMap.hx index f723333d..eec8b01c 100644 --- a/flixel/addons/editors/tiled/TiledMap.hx +++ b/flixel/addons/editors/tiled/TiledMap.hx @@ -7,11 +7,7 @@ import openfl.Assets; using StringTools; -#if haxe4 import haxe.xml.Access; -#else -import haxe.xml.Fast as Access; -#end /** * Copyright (c) 2013 by Samuel Batista diff --git a/flixel/addons/editors/tiled/TiledObject.hx b/flixel/addons/editors/tiled/TiledObject.hx index 6c53dd67..d0abac4b 100644 --- a/flixel/addons/editors/tiled/TiledObject.hx +++ b/flixel/addons/editors/tiled/TiledObject.hx @@ -2,11 +2,7 @@ package flixel.addons.editors.tiled; import haxe.Int64; import flixel.math.FlxPoint; -#if haxe4 import haxe.xml.Access; -#else -import haxe.xml.Fast as Access; -#end /** * (original by Matt Tuttle based on Thomas Jahn's. Haxe port by Adrien Fischer) diff --git a/flixel/addons/editors/tiled/TiledObjectLayer.hx b/flixel/addons/editors/tiled/TiledObjectLayer.hx index 00d766f7..8f6f24ca 100644 --- a/flixel/addons/editors/tiled/TiledObjectLayer.hx +++ b/flixel/addons/editors/tiled/TiledObjectLayer.hx @@ -2,11 +2,7 @@ package flixel.addons.editors.tiled; import flixel.addons.editors.tiled.TiledLayer.TiledLayerType; import flixel.util.FlxColor; -#if haxe4 import haxe.xml.Access; -#else -import haxe.xml.Fast as Access; -#end /** * Copyright (c) 2013 by Samuel Batista diff --git a/flixel/addons/editors/tiled/TiledPropertySet.hx b/flixel/addons/editors/tiled/TiledPropertySet.hx index fd6afeed..c5364137 100644 --- a/flixel/addons/editors/tiled/TiledPropertySet.hx +++ b/flixel/addons/editors/tiled/TiledPropertySet.hx @@ -1,17 +1,13 @@ package flixel.addons.editors.tiled; -#if haxe4 import haxe.xml.Access; -#else -import haxe.xml.Fast as Access; -#end /** * Copyright (c) 2013 by Samuel Batista * (original by Matt Tuttle based on Thomas Jahn's. Haxe port by Adrien Fischer) * This content is released under the MIT License. */ -class TiledPropertySet #if (haxe_ver < 4) implements Dynamic #end +class TiledPropertySet { public var keys:Map; diff --git a/flixel/addons/editors/tiled/TiledTileLayer.hx b/flixel/addons/editors/tiled/TiledTileLayer.hx index 7ed33a6f..870012bc 100644 --- a/flixel/addons/editors/tiled/TiledTileLayer.hx +++ b/flixel/addons/editors/tiled/TiledTileLayer.hx @@ -3,11 +3,7 @@ package flixel.addons.editors.tiled; import flash.utils.Endian; import flixel.addons.editors.tiled.TiledLayer.TiledLayerType; import openfl.utils.ByteArray; -#if haxe4 import haxe.xml.Access; -#else -import haxe.xml.Fast as Access; -#end class TiledTileLayer extends TiledLayer { diff --git a/flixel/addons/editors/tiled/TiledTileSet.hx b/flixel/addons/editors/tiled/TiledTileSet.hx index a0ed4deb..8ad61c65 100644 --- a/flixel/addons/editors/tiled/TiledTileSet.hx +++ b/flixel/addons/editors/tiled/TiledTileSet.hx @@ -5,11 +5,7 @@ import flixel.util.typeLimit.OneOfTwo; import openfl.Assets; import openfl.utils.ByteArray; import haxe.io.Path; -#if haxe4 import haxe.xml.Access; -#else -import haxe.xml.Fast as Access; -#end /** * Copyright (c) 2013 by Samuel Batista @@ -48,7 +44,7 @@ class TiledTileSet numRows = numCols = 1; // Use the correct data format - if ((data is #if (haxe_ver < "4.0.0") Access #else Xml #end)) + if (data is Xml) { source = data; } diff --git a/flixel/addons/tile/FlxTilemapExt.hx b/flixel/addons/tile/FlxTilemapExt.hx index 783349ef..fb7e9b8d 100644 --- a/flixel/addons/tile/FlxTilemapExt.hx +++ b/flixel/addons/tile/FlxTilemapExt.hx @@ -18,12 +18,6 @@ import flixel.util.FlxDirectionFlags; using flixel.util.FlxColorTransformUtil; -#if (haxe_ver >= 4.2) -import Std.isOfType; -#else -import Std.is as isOfType; -#end - // TODO: try to make it cleaner (i mean rendering and animated tiles) /** @@ -413,7 +407,7 @@ class FlxTilemapExt extends FlxTilemap // New generalized slope collisions if (overlapFound || (!overlapFound && checkArrays(tile.index))) { - if ((tile.callbackFunction != null) && ((tile.filter == null) || isOfType(object, tile.filter))) + if ((tile.callbackFunction != null) && ((tile.filter == null) || Std.isOfType(object, tile.filter))) { tile.mapIndex = mapIndex; tile.callbackFunction(tile, object); @@ -421,7 +415,7 @@ class FlxTilemapExt extends FlxTilemap results = true; } } - else if ((tile.callbackFunction != null) && ((tile.filter == null) || isOfType(object, tile.filter))) + else if ((tile.callbackFunction != null) && ((tile.filter == null) || Std.isOfType(object, tile.filter))) { tile.mapIndex = mapIndex; tile.callbackFunction(tile, object); diff --git a/flixel/addons/util/FlxScene.hx b/flixel/addons/util/FlxScene.hx index 36aaa391..c4e6151b 100644 --- a/flixel/addons/util/FlxScene.hx +++ b/flixel/addons/util/FlxScene.hx @@ -15,11 +15,7 @@ import openfl.Assets; using haxe.EnumTools; -#if haxe4 import haxe.xml.Access; -#else -import haxe.xml.Fast as Access; -#end /** * Loads a scene from XML file. Scenes contain layers of entities (custom FlxSprite), From 97e98d73bd9ae4c6c9e58c5899cae6c5f634ee05 Mon Sep 17 00:00:00 2001 From: George FunBook Date: Wed, 26 Apr 2023 10:54:46 -0400 Subject: [PATCH 06/69] 3.1.0 --- CHANGELOG.md | 11 +++++++++++ haxelib.json | 6 +++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c2a9ea29..37a92f3b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,14 @@ +3.1.0 (April 25, 2023) +------------------------------ +#### Dependencies: +- Dropped support for haxe 4.0 and 4.1, use 4.2.5 or higher +- Flixel 5.3.0 compatibility, flixel-addons 3.1.0 will not work with flixel 5.2 or lower. + +#### Changes and improvements: +- `FlxTilemapExt`: Implement scaling ([#384](https://github.com/HaxeFlixel/flixel-addons/pull/384)) +- Improve docs ([#376](https://github.com/HaxeFlixel/flixel-addons/pull/376)) +- `FlxTransitionableState`: Use `startOutro` instead of `switchTo` ([#382](https://github.com/HaxeFlixel/flixel-addons/pull/382)) + 3.0.2 (January 18, 2023) ------------------------------ * Fix haxelib caching issue from reuploading 3.0.1 diff --git a/haxelib.json b/haxelib.json index 5cc2e672..f89f306f 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.0.2", - "releasenote": "Fix haxelib caching issue from reuploading 3.0.1", - "contributors": ["haxeflixel", "Gama11"] + "version": "3.1.0", + "releasenote": "Flixel 5.3.0 compatibility", + "contributors": ["haxeflixel", "Gama11", "GeoKureli"] } From ea739f6b22a675395c0138c64b047ba7fa5b1da5 Mon Sep 17 00:00:00 2001 From: George Kurelic Date: Fri, 28 Apr 2023 19:25:26 -0500 Subject: [PATCH 07/69] link demo --- flixel/addons/text/FlxTypeText.hx | 1 + 1 file changed, 1 insertion(+) diff --git a/flixel/addons/text/FlxTypeText.hx b/flixel/addons/text/FlxTypeText.hx index 97bb4389..727e235c 100644 --- a/flixel/addons/text/FlxTypeText.hx +++ b/flixel/addons/text/FlxTypeText.hx @@ -23,6 +23,7 @@ class TypeSound extends Sound {} * This is loosely based on the TypeText class by Noel Berry, who wrote it for his Ludum Dare 22 game - Abandoned * http://www.ludumdare.com/compo/ludum-dare-22/?action=preview&uid=1527 * @author Noel Berry + * @see [Flixel Demos - FlxTypeText](https://haxeflixel.com/demos/FlxTypeText/) */ class FlxTypeText extends FlxText { From ea4b2be1eeaccf0e5018cb98c6be938a3818c3c5 Mon Sep 17 00:00:00 2001 From: George Kurelic Date: Fri, 19 May 2023 11:31:03 -0700 Subject: [PATCH 08/69] use enum over @:enum (#387) --- flixel/addons/transition/FlxTransitionSprite.hx | 3 +-- flixel/addons/transition/TransitionData.hx | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/flixel/addons/transition/FlxTransitionSprite.hx b/flixel/addons/transition/FlxTransitionSprite.hx index 86f1aa02..67780982 100644 --- a/flixel/addons/transition/FlxTransitionSprite.hx +++ b/flixel/addons/transition/FlxTransitionSprite.hx @@ -132,8 +132,7 @@ class FlxTransitionSprite extends FlxSprite } } -@:enum -abstract TransitionStatus(Int) +enum abstract TransitionStatus(Int) { var IN = 0; var OUT = 1; diff --git a/flixel/addons/transition/TransitionData.hx b/flixel/addons/transition/TransitionData.hx index ab9097df..09190f8e 100644 --- a/flixel/addons/transition/TransitionData.hx +++ b/flixel/addons/transition/TransitionData.hx @@ -8,8 +8,7 @@ import flixel.util.FlxColor; import flixel.system.FlxAssets.FlxGraphicAsset; import flixel.util.FlxDestroyUtil.IFlxDestroyable; -@:enum -abstract TransitionType(String) +enum abstract TransitionType(String) { var NONE = "none"; var TILES = "tiles"; From 8e49bbdd9b469165b840511889af698362d26d7a Mon Sep 17 00:00:00 2001 From: George FunBook Date: Fri, 19 May 2023 13:35:00 -0500 Subject: [PATCH 09/69] @:enum to enum --- flixel/addons/editors/pex/FlxPexParser.hx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/flixel/addons/editors/pex/FlxPexParser.hx b/flixel/addons/editors/pex/FlxPexParser.hx index daba70e4..e8d14ee3 100644 --- a/flixel/addons/editors/pex/FlxPexParser.hx +++ b/flixel/addons/editors/pex/FlxPexParser.hx @@ -244,8 +244,7 @@ class FlxPexParser } } -@:enum -abstract PexEmitterType(Int) from Int +enum abstract PexEmitterType(Int) from Int { var GRAVITY = 0; var RADIAL = 1; From 95296191b4a583d3ce1e61383f4cde63dbda729c Mon Sep 17 00:00:00 2001 From: George FunBook Date: Fri, 19 May 2023 13:44:25 -0500 Subject: [PATCH 10/69] release 3.1.1 --- CHANGELOG.md | 5 +++++ haxelib.json | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 37a92f3b..9062d643 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +3.1.1 (May 19, 2023) +------------------------------ +#### Changes and improvements: +- Fix `@:enum` deprecation warnings in haxe 4.3.1 + 3.1.0 (April 25, 2023) ------------------------------ #### Dependencies: diff --git a/haxelib.json b/haxelib.json index f89f306f..dd5ed5b3 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.1.0", - "releasenote": "Flixel 5.3.0 compatibility", + "version": "3.1.1", + "releasenote": "Fix enum deprecation warnings in haxe 4.3.1", "contributors": ["haxeflixel", "Gama11", "GeoKureli"] } From dae67f5a4ce215202048a0210c75fa4a0d640427 Mon Sep 17 00:00:00 2001 From: NeeEoo Date: Mon, 12 Jun 2023 19:01:10 +0200 Subject: [PATCH 11/69] Fix shaders on skewed sprite (#390) --- flixel/addons/effects/FlxSkewedSprite.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flixel/addons/effects/FlxSkewedSprite.hx b/flixel/addons/effects/FlxSkewedSprite.hx index 7c753e10..7d7d4d9c 100644 --- a/flixel/addons/effects/FlxSkewedSprite.hx +++ b/flixel/addons/effects/FlxSkewedSprite.hx @@ -77,7 +77,7 @@ class FlxSkewedSprite extends FlxSprite _point.floor(); _matrix.translate(_point.x, _point.y); - camera.drawPixels(_frame, framePixels, _matrix, colorTransform, blend, antialiasing); + camera.drawPixels(_frame, framePixels, _matrix, colorTransform, blend, antialiasing, shader); } function updateSkewMatrix():Void From c76c18d669acfee8d489420d5d36548e50935380 Mon Sep 17 00:00:00 2001 From: Sword352 <99792114+Sword352@users.noreply.github.com> Date: Mon, 26 Jun 2023 18:50:00 +0200 Subject: [PATCH 12/69] Little FlxBackdrop optimization (#394) * Update FlxBackdrop.hx * Fix Typo * Update flixel/addons/display/FlxBackdrop.hx Co-authored-by: George Kurelic --------- Co-authored-by: George Kurelic --- flixel/addons/display/FlxBackdrop.hx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flixel/addons/display/FlxBackdrop.hx b/flixel/addons/display/FlxBackdrop.hx index 3df0a58b..9dc2b13f 100644 --- a/flixel/addons/display/FlxBackdrop.hx +++ b/flixel/addons/display/FlxBackdrop.hx @@ -30,7 +30,7 @@ class FlxBackdrop extends FlxSprite /** * The gap between repeated tiles, defaults to (0, 0), or no gap. */ - public var spacing(default, null):FlxPoint = new FlxPoint(); + public var spacing(default, null):FlxPoint = FlxPoint.get(); /** * If true, tiles are pre-rendered to a intermediary bitmap whenever `loadGraphic` is called @@ -68,7 +68,7 @@ class FlxBackdrop extends FlxSprite * Creates an instance of the FlxBackdrop class, used to create infinitely scrolling backgrounds. * * @param graphic The image you want to use for the backdrop. - * @param repeatAxes If the backdrop should repeat on the X axis. + * @param repeatAxes The axes on which to repeat. The default, `XY` will tile the entire camera. * @param spacingX Amount of spacing between tiles on the X axis * @param spacingY Amount of spacing between tiles on the Y axis */ @@ -569,4 +569,4 @@ typedef BackdropDrawParams = { spacingY:Float, repeatAxes:FlxAxes, angle:Float -}; \ No newline at end of file +}; From ced7e6b67ec8f420d0e86ced202d5b3da67bb449 Mon Sep 17 00:00:00 2001 From: George Kurelic Date: Wed, 26 Jul 2023 11:21:58 -0500 Subject: [PATCH 13/69] Deprecate FlxMouseControl.hx --- flixel/addons/plugin/FlxMouseControl.hx | 1 + 1 file changed, 1 insertion(+) diff --git a/flixel/addons/plugin/FlxMouseControl.hx b/flixel/addons/plugin/FlxMouseControl.hx index 42dc16ee..7a5e1d3e 100644 --- a/flixel/addons/plugin/FlxMouseControl.hx +++ b/flixel/addons/plugin/FlxMouseControl.hx @@ -15,6 +15,7 @@ import flixel.util.FlxDestroyUtil; * @link http://www.photonstorm.com * @author Richard Davey / Photon Storm */ +@:deprecated("FlxMouseControl is deprecated, use flixel.input.mouse.FlxMouseEvent") // since 5.4.0 class FlxMouseControl extends FlxBasic { /** From c7561613dce6d969b962fd40df75ee5e573a1739 Mon Sep 17 00:00:00 2001 From: George Kurelic Date: Wed, 26 Jul 2023 11:24:50 -0500 Subject: [PATCH 14/69] Update FlxMouseControl deprecation doc --- flixel/addons/plugin/FlxMouseControl.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flixel/addons/plugin/FlxMouseControl.hx b/flixel/addons/plugin/FlxMouseControl.hx index 7a5e1d3e..3b3c22d6 100644 --- a/flixel/addons/plugin/FlxMouseControl.hx +++ b/flixel/addons/plugin/FlxMouseControl.hx @@ -15,7 +15,7 @@ import flixel.util.FlxDestroyUtil; * @link http://www.photonstorm.com * @author Richard Davey / Photon Storm */ -@:deprecated("FlxMouseControl is deprecated, use flixel.input.mouse.FlxMouseEvent") // since 5.4.0 +@:deprecated("FlxMouseControl is deprecated, use flixel.input.mouse.FlxMouseEvent") // since 3.1.2 class FlxMouseControl extends FlxBasic { /** From ceb267097a4e4d4a682757064ed34b06f5e265eb Mon Sep 17 00:00:00 2001 From: George Kurelic Date: Thu, 27 Jul 2023 09:44:34 -0700 Subject: [PATCH 15/69] fix transition sprite graphic classes on html5 (#396) * fix transition sprite graphic classes on html5 * include transition sprites * keep onLoad arg * prevent crash on invalid transition asset * reduce memory used for diagonal fade * prevent double fade transition effect updates --- assets/images/transitions/circle.png | Bin 16201 -> 824 bytes .../images/transitions/diagonal_gradient.png | Bin 18812 -> 3812 bytes assets/images/transitions/diamond.png | Bin 1657 -> 788 bytes assets/images/transitions/square.png | Bin 15583 -> 383 bytes .../addons/transition/FlxTransitionSprite.hx | 55 +++- flixel/addons/transition/Transition.hx | 7 - flixel/addons/transition/TransitionFade.hx | 252 ++++++++---------- include.xml | 2 + 8 files changed, 174 insertions(+), 142 deletions(-) diff --git a/assets/images/transitions/circle.png b/assets/images/transitions/circle.png index 93b03c6de6236074bd74f4750754f394a74c1e5e..a9645ed8479bbc9fb86575ee728f998522fc0aa7 100644 GIT binary patch delta 801 zcmV++1K#|}ez*pZB!2;OQb$4nuFf3k0008=NklNv73QnbziiVbaIvRNbDQAU?_U4Hq8Q2_R5I>l<~H>BCD)Kkh+@?ZE_s6aomei<&@us`afA zrVlS8--8fQd#?upfGPdSZU72de?BkRM_)fvFZvoiH>9I$M{I_BH6k}+n?C%QfKXH9 z1maV@BUk##IDZ0h1QFkZ1(<1>fKW;F1mbng=;!v>lx%dsPy`UpS~njN^?E$E_jRgl z{Fz4(8L!d0`7=Y6pAG0j0HM`h;OH4d&Rnli(VpA$ zS^$qAfYh`N9uYw#;|PQpjzEBL0?0Md6Np#MGheGH>wg}MteZebyO#!_8v*3J?F8b< zM%lyxc!=r&Bx3^cs{767BI=%b3;?969zXzqf~p6Q<)`0ozdWk@&F3QOo_P!aq^cf3 zGA%oQf1)$r-_u_c04@+fuF06de5&`fP5+MXXO!^tw0|3bO9YUbw!tSN2(?__W_wQ7 zF<#~|W`E|-il0+RB!JWwJ%P!%2j$B3vYy-XS^$qAfY53$^z;lvqa33|=-GGG*93SV z0fe)b%|}GN9*^yPohqAt<|NG#5KKq_p^~Gp(<2OJ9OJkN7I?g6UH#%r_|ms;mb*6l zyWX5F{q$ZCKJ^l{82#2m^g{UFL)Id^B-REK5PxV8J%PzM0?NDxCG#k6w41r%@k~IV zhSoRg)lKg1g<*s#%ux>}F!4RufF>q@Ks|eJ+PnW}opA(ockR|596`nQU;~<%00JC2 zyGV>Og%N=M8!-Txz)VU20a_d_7(MQ9m@NQh9YOW1ebj>^s0j%mKqUfDyD9-_#v`bV f+8XaYqy~V$DG=5Gqx!;;00000NkvXXu0mjf=WTVM literal 16201 zcmeI3ZEzFE8OPVMV~i=mNhdC0aB|2=2b!MmPVYKoA^8n^CIZK}u_4pMr@NDUMbZh~ z*_I77wrQBsmypnzHuVr{8X5@DkWBhAEl@B_%Vg4)&H#l_GHpuZ6cR!vh2TJmyQg=r zrL8~YLuY!Lv31Wr`}}wJx6eMO`*2%YS1g}fzMvccFt??-p$z~70k4U&QuzO&%Hvk} zH9Ok8S^;3r=e55gFtU9<04`c;?^HW|53{@+uHgjPFV@7vQP>;$mc^qSzgAQUzZjGv zwZ^Llj~EF_s5N$2eY7uHFLq1K12J*cz>0Q$U@h+yjLY2Rt~d(?!lKF%@o*@ju<=@B zLYIZtS~F!N5?$1_wMMTtAkpb-CF!X_`oVjP7!H<%$UbwymKlH5{~RjoqpmWhtt!udk-hTqDPV6ytO{DcVGtOeE|< zD*X|ai<1$hIw_LYX%H1YCPh_Aju4tI=a+lbTBA`LDDz3JD;&)X6j4&_AVn(9MJc9+ zrV0f4eE6_%IB%q)wu#x5Vl2V9fAk^3^M%27g z0-w=|_QXO7&;n11Au$X?6i9)|yOwCTtjbEaTmWFkT@a%x1q!gxJO#tVxKtoa^CZI( zIhEXM7ffWfJ|=Ri9BY^5kUN>Kt?Ahl_4SGLBo=o_5kc-#mbfT1B%3%{HL-zHMYopN zB<&z+TRUTBtxnc#BWWv4?;Me2Pej8f3sRteiUwnCXKbvQW@#vy)yV0IYQTdia4I(= zmE68lb$mXyC8DTYgcn;H+;HtRk|eMJkz;t#Vk0?!z)uDQi=T7|0fD5=4x3q|t)k!W zOe}J0_%!JTneWjO2}&m`h#>P&K9e4-MX(5>pRti93lGZ!BU(tOllGH-o5f+HX$NBx z&FO)1#HJ4<#-v_RXo|_<#Ho*RF-6o4Q>`(5nlfb~l^TiT$V$@}Z#FkId1;H2aWv8l z(`a!zz4p4sMvL8Ha@uSTyNj9@nw<|6cO~6$sp++ASOvK5l(P4~Dd&V{l`|N!OGPpr zZpO-(1PeVE%3*~JUSD`{*fYOG&Lon3nk5CEsQ#SswRLOdc9pnpYHQjNl4iIuneBl^ zj^%i*kh>KQZmz~Xr!70FWP~7SR$Q9kfXx9RWXY6F9-) z@cYyHIpKxJ=<60EnF5gK@Fr)H=v7!mkppTU7Zbffct&PYo06(i!wSpu-CQIn3T`UB zvUCF);-a*z3rYWrJ2$gZG;QP2C1$hZ|6u2m`#JR}rpw3lqw5lQHXz5soa&asTu`K< zk)VspHfB+}vW2@|4#_cicM{#OKId!B8TH+5WiK8RPxg#f{uIxajP#H-^%fZ$CX7oHE|)o~#} z@TQIn&j<19xDX(CQ^$qpgLrjZ2oSufbUTH5U-940fIMmTzEc+SI30_!J9fR zJRiiX<3fPoO)ReR>}$Yc1it&*2Ve4aeDua*_<}IOH@Eo!7bkIeid>{R5@9eL4{CmeR zIM(PDHs5j3U=7}SeAAsCuye_^3-@mB9Vq=tHJeI3yaP?aJI8{;?UlA z%F0SAI*r#h-2CK&MUM=PY_59ccf;<@Pi~(*tLirY()d8f$I6Z2*0J-G@9kW_Xn)t0 zBkO7K%~y*JSIKkFFQvCskN(5F`1KbKy?NjG=69(*y`HYwS3lkPsB-wBTfbWS$llhs zsyCh+@`9r8&#gYwzWZX;lV1YP;mcRXz}+5DbN_cz>% diff --git a/assets/images/transitions/diagonal_gradient.png b/assets/images/transitions/diagonal_gradient.png index 289bb6f0f883f9b718571cacc98d44c65cb7e579..9555ea7d1f3e964097e65ad71352654633cd1272 100644 GIT binary patch literal 3812 zcmW-kc|6nq1IITxw$PBHlns4dNnsT~<=hxjxyqd@$DFyTkuMW-Bv(Y_h*Dbagdt~g z<(6_xu8EAW`3k?!XaDT++H=o6AMd>%pMOR&zJcRCDtZ(Gf$$pWV@)9ts0OejVVuBg zYBI;a5XezAJO*QI?Cu-r8{qDHPuu{55x?i}>x%bsfk5<0xlcpP&Bujf2Ph%;3;GlV z!gG1kz?qK6%vJP{JL0nA?+wh&csKO6_W8Wkq)1bPsH=v9Ry8G z!qAns0~Z!3nVB;vw{XuF6o$IndiYp9EbzH0th%R#XHZn5I7SG~=BYtFPx?v}Y+ z&1-tLHubMRkGa;4jp;3Ry4nk^H2WM}Cp~D;e;=jE;3?b=uh`G9zpoBSv@-DyCRB8+ zbL2atA)AcmiHis}ak&+ny%q~b0clCfK>Tw#TB*Cg|MH^0W#?SfLBS!7uCg`CNbH~; z$Reh4(^>>ejxNvDR}7gA#}Mwja;9|@oZ1hIJM^2if6=B$OlzSAgcio#8%*~LBNYb! znXrYbe#56q4qI!?T(Rvni#5!HZtlqo$C&1ah**N80Sg9-#_RUg?ORC!2H&PZVXf@3GTZ8qbcWTR+*G&gnao{%j9 z75$ycO%GyTzRIQ<>&73+$1hs==!67MJ1-ntn8Hp>F2ls97`{Z}wdH|B@eMTg13^?qC9Zh`96huCg|5U-IcB3-jTJKz5FwSq-C!_ z{(6C_I3J9?&Wv7i(Ts!Q2~j;R=je@2tYfN@r($u|e%9^YuwHRj9&|#7lTbOQC6|}@ zQ<9KFLivM=uJWaF%!J>n&1wEu@#wCwxkA6IwotM_h+v4Y3Nfdp?`JXHI`j%bJTGaW zBa?cHZpVcFRgK6Kzy4K1m9G`nO-v%5)#0WJP$j5BDf;FzlLFBs+c{1rp$*lIqkiek z$Nyl4WIm=i>FW#y4>=Bn4XF>wD?cl{9xRPZB!*-Y7=<~+AzS1{L0o*Fk7?U=dU zb-AnH(&iFy*Yobc=f_|9vM=|=J~fmt%FUlDpk$go4M_R<**ncM2D9eJ!Emz z#JVU@zw{>lww3O;YyZQ9z2DSbzzb!^R~c3s#(c5Lkh>NCrs%9ijn4M-6?FZ%shB*& z_l1nFZX@XedwNfJwDU{z;qaE7dYV^Ff5b&A{v+=X7wGudShbW z)%WfTr-vgE{-yn<{X>t6osX>?Gm2G<<;T@KKmV!S#V>P7ro@ageB6!Ktu~2L{ zT4j$?rUh?B_+$Wdgn`l$MG^&EA##zgv6i8{>?ny%3HTXcM%74S9apy3=NiAI28W z7Q&%%bO>%Ow&koSttwk5&BVu9=||}M%1T|lyyd=}qc~n(S zv+TBXUF}v4w8j1ytV8r_xvB?To|cKQ|I5>pR1>@Xe65%4aMSO!>cVppdn|F2*o}>C zw&Wr zBweX;(r5ekD4L)d;Vhm0QMt-YOK9I{8y*ys6H{dM*y@s%Z&h2>%|-nsy8nOv+W{XI zZp?=*hBt85JgOPvnJ?Qe$d9R`f<;)3$~g~pFG=Al88xiryibFRFJ(8 zN|AFivncSVK5DJ#yOWcX@J~Ebx6Nkt!-$Wr_kz#bjBADWdhN}Q)j3b85~&O+l%ZAe zc$3mz$x2Sl8vOfSPg&2g)t1%SwYsWd{8EZPZL@K+!VcOnDZeb#A@n|^>vxki-pZ;W zwj5XI_VP>fn}GL=(_#-a&1G)Qkp14_r(RY2esB7?zq*g%dXA_bIXnJzq)GF$dgzD# zw`9tlhNexvMdPu8SG-hS%8YW8w}-jcIsD(ytdP)o{m&_R(m5q1MTWSZY^tl{pOK0z zXO*UaLvmHe>tb@on6>}u(;~=+JK;YVAvc)0%NpIP-!`Mi5POrd-W_Yk4}A8FaHd`Q zZstp~ax-RAb~|?7nxcoH%<4&6HoDU7OTR$BaGsrNW{A%Yp>vnUO%my>cWyx0CN_q? zm8pAmm^xD|pQ(Pqel>`u9@0VmLVFu*ansJ(_E()xIE6Cs=KY$?+ZU7nz1#cF<;AJy zJ2Aa1YO59+{29O8dYzGz>AU-*KH|Z*wNF=i)_;gSK8gI;({v^5!uE8}o)u#W zM^US<#PU40Qn5^j3v2X|qD&ZS^`%&zL?Ji|#qu0kBVR19032mxu{ZkiHN*m0H_0o9|)p} z2qX&tMg$1bh=|`H5Ce>05NHz-J}jWmoOK4lCn92c958YL!y5z!M8q8y0E~wq=q4f# z#sI?(Fg^r_V%H^Gxn^qG&fFIf&{&SeZJn1Utdhl$gYtYD!JwA`Lp68+Jf4^=25K&? zT|VFyKw+pWcz|I_&AmLdR81|R?h)*1X-yWBy67lt|m7A{K=62ZcEpujo< zx)o=01}&S^1h3#I1_)G%bicPCXoI0Xus}L}BZURvsCDp%s>aYa zSmzjqq29AV27QCo7>1)Bvd%%IZX1K%z*L3idK87seRz6Shz Og&64Gz>;+wqW%wRQEsFF literal 18812 zcmeI43p7;g`^UG)U38I3YS2Y8=3*E##<+}YNEpZHrZF?d7=iqo(lRLq)rqb=LZw|N5`rS~F{zndf=l@AK~W^SKP9>JWX zW%}9*YOCV4bDpWYU7KlZE2DWcJ6?LluuhPn)%0$x|-To9fp=Mic3NOHTm;&ZSIJ! z6!1QZKv=0$C07ARg*{M`2dZ2$s*nqJjj8rnr>&O~?3AkFC7C+O3+4cp5&Nu90+x1C zg3Q!q9zeDXu&JKr+YYRO1DlpdzkUD+GT*0dlLFQq)K-_uP6A-F8SyrNzZr0*@t57U z00jxm@pG!d0Z-uo($UM$0XTaJsA^DCDhA}00i;`e>zP+)M?aoOT+5$wE5^5jOrf)cK{$e zNgW*Rz(`objKYQnlYJ#KeBeEmvST{FzU`x(jrk##0PucKF>rP>QEFQf{L}`T^xsa))hN8GwqXExSH`~f zP)}Z3;J@QlBY&*lV#GdsDIoB3JP-;18*P>tl5d~4sFMc(o9r0y(T$b_wxN!pC=MYb;zpjd2&WIfk?yJ>(=K?4HS}T_2+cXDCgHMIQz>P>9T|& zTH`ss%&ZvODg_f6zBP=x$jX7@Oj-TZ;S_A)63oo!3Rnf{oo?03b&^jxU08Ny=7*Yj zzG&1gii3gf<5`Kb5o+7wNj2Cdvl2+?<)!1Vy3TU=<)X+ZF=svH?NxCsn&_39$Iy1*&$7R1o?E{$-I|&N}dCr_2k6U8$BWm?L3V<+D|JyJe=>Dm$|0b zL(_wK+U(S>Jmx7j+2VMV_eg@Q_jTv%uB78`+2?%P%WGjuwE5@5473AO^5eF|7}qR2 zclX(^TlLFQN3_cJnCG3&!I6ws8F`&|A2{e|A=jQ7`u+%SwL+I(ZpuK^?w51=SG29r zJc)5GMKRU~>Q*gZzucag*f2e_%j22H zi(JLrxi04Tp+dvFfD@WIWj6fE;M~5{tcs0-EN6D^%kZmR!iABD5%NfoFn7panId~$ zd5LVZa>G2r4dYNYK?_mW{FfVP!*xs23F;wg%B!78rA>rmkL-T4Q{Bs|UEjW>J*YOQ z_SiDnW!lS}TzXvk(%oH3Pp&v==4|F%clXZSqjw*t8E2TIo}jxjx-y<*v|ie@Hf*gy z$*Gdd49DV*wI{v%O3H&{*W$cSP(0UeIB!>wS+MkRSwUIu%-qt|$*c3T9y70>{j20w z$>~e;&vrhQZ7wVcDv6{reKnYuZWLbcOTL;Mc_s3<5py|}UC(CZYpvCa;$Gm)!T*AP znci@u&m!{1;Ndq2CZ$oW@u^XJ$?W=#+ra!!BQ!vbV7_(%(`hG-$(qaUAfN!-^}>C_}N>lz1gK!>Q;%{ z3$}M&E7118`RD!u?cuJ}hNK48jMz0%-H-3dQD0N{T#r&-9=j{nE6!qHNIYdh6Dq}+ z-_%0lw%Q174%@uUV4_@cMetR|`ouiL&4lOJE0`-5wT6D)cOFqPDUN|o3vq_}g(ks) z6|JA%4(w{nY*T9Arjd%cxgjJxr=fZq0RAEQ9BMK?GLri({@QNVfHXz`)#d1!-y>&y%D_U5@OLIxmy9}_n(>W4Oc9& zKG{uPtM^1-u9(U2@~ga?a2t0xKWpXPw|CCpZr+bQ(*OI|+ga7KUL7bo5$EIu*P^_> zdS)}Om=GG?tk|wTeP!G)vS$dFcbDh~J#x)|>y=U%b#+;UOF+!VYqz&wyC@aVtK_NJ z85`N#^5pFXR|>+r^&(Xmm#IlqPuN{Jr&%LKJ^HC$OIWAoF81xpw3dSxPUqK@(i{Em z`@MPn5}vhg#^Jn_*C{iCRh~V+pwjxwg||b0+cqOo?&>v{?I^tKcjAO#b{x9;6`=9S!o#ap$QT8Pco>F?6*GCa~huJc`Y#q|!c>2c4? zh)?#-i&c+c2;SkV2FSNq&);l+kj#A7xHt1qW@MD%hn7vvM@zPK(HdGetFrsAsPSIi zw;kKlWmaz1u>Rd;-n-)F&e>jQqy1J}B;BW3A@rRxJq`y#Gh+~zm@ zMl%cB@M7?4_+N9!9zV*$nZLL?5Wyb4F+9{d_eB(E`A9>3*)#s~zJhYsa-TuVw^q+c zFLph$SU1}8w7(^Ka}_^(psB@vST=S?<7m=QqAF>6Vp?K-oJw48mMIa3YqQ{ty!n(% zYNR(V%hDJYZQITw7hcsNz-3jZ>cCiZa~&^Z7o^M11TcHs38cHArkQu zk&BCXSy0dqm0X_fR`5tZkL-sXa>?N#41_y_%ihAFF>JRof_b_>ItV)LYo3rToWOBD zbQ*#Y$Or-@T=3vgKRkqxFLxkc<=-5}*YHnA&tv&bPR=)4QRJsGMi}cSGErngHog=l zW{3c;KRk)Upz_!pGMgPpoLFU(_fO#MlW0}J^t@QXbT*&6f`EWZCg*!H8^eamV-Q73 zIMNhcjAWDv9%F(>8^e*t;HsRGWTGV`hYPs&=~N!|yDV5xj5k6~&GJoKXdX75dZHmO+K1Pz(&*lx9qY z({Kz^5D^LumXa?WO-c4$N3I+eSeK}QQ`(5eLI*qZGom6-RO~q2-R5}I=z8N#% zSd5Vg&eX`)gibg4(!~$beAkr&iwmx%@F}YdTx;W%$Ac02t@leHkTqUGLZ}=rL$oo? zb-wJ(uO;VeMG zDcp!*;tR(aWBlM$KVMTg9chBaGH@nTBo6gun*YnEVR9AI{HeiA2AzobGO{m@|E8Jy zXZ7$u*+7uW|Npmv{G~_c>=6i)baWZYQFP9+fzjKK5)x;dn_6Wz7QzU`)BFYFjVR-UOF`ll};)>gIPQx z`g3m(_Y{@r8VWxS)dRfTXAr@mL0!<+Ygl27K#C0uJj-)MXDbxi^s@*W`JvMLr^+dj z&&r7fHRZB=yv9#>!Ha(IegpCKhU2^P|Me{SZ+@8^(!ZG%l1tJF1c-Q3f=fIfNK}Fg z0z|wi!6lv#Br3rL0V3X%;1bUV5|!YB01r2mv}yqs00@Th~D-khnC&ie!N~;$~n+N z#cL0FSDt|>;y_?r(ZC0Sdf@$Tyic9pV({2ANl#=DzJ^YeA zjdG%rQ1pmhFkfgr5}u_JnK1gEMDjW6!P=1rP9FxY7d`?w*1KrWi%xm%n>~g5Nf_8h!l^cvMWD0F~Q!WZGrCo!P*2cVf0F1kRRFH0yeD#<c&&|%~SM_nfNQiKn zClc@B1Hv{?yk|mz(6s9A1zkcj>fjBLd+FW^j>0j-BCGC|_7iziKzD2Xn!!UUIoKTQ-p#O`Rj+NRKY)As)b D_lFmm diff --git a/assets/images/transitions/diamond.png b/assets/images/transitions/diamond.png index 80b800afe6adc9a9aad2b8c847a9f552668ff18b..4abb5cc8869a3ffa7fe7d12fb5a015137da0f007 100644 GIT binary patch literal 788 zcmeAS@N?(olHy`uVBq!ia0y~yU{V0G6*$;{q_)^$Qy|4y9OUlAuvy~=E{XS9eSYFTf&JBe%k>}aKW`YtQ0J@1USKjm`x*0_dh7WW zeN$ySpRY(MvpF7e>`J!9SGikH>t7U#2r!7+-LLuo(KB6umBm7wZIRjJ8@CJ7rt`2Vo&WK4KQk9cff|p?`5dF}#)$K23UM7wOji;W zvWz?T%BGi{Oi=i==ijIMjI1mx4mx}}qqbS1<7*BZQ~%7c`t!k@`9tSq4t9rJFch%s-R zch-S{e{sVcUgp5ro^Re-Z1!ejo_PFe|8<}kH}gf~*=Ldzu5Fg&c#x{0@I3+9MLYg9 zCW=h3LUJ{O&8e5HEsZPAs(dS(b5pgs@x~ZH_va&ER$eeh|`sDTb>qqWQoo~Bw zyAj0uJu9ylyt3VL`oBPfcwrUe%qOpBzn_2S_vHJk-|x-zP4k_*ce3eM^Ep-g{$hfv z91<>!JK33o;qIL5{*$3C(BWKb<4d4oLxa~hd3Zh;iA>m>m;evCgijjs6}DU)s|*Zm zH=opDOS7Hb$SCK=cu-bi20Y+q*qmZN7U)o*#p45xg2?k}2_LLP1m^Id+Sb6tB$Aj= zl{Pt&=S-CubMx^)hXyMipIo(#+aI6NljQM{dz#EFBJjXRVg@*LH_tnJU=Jk1m%$@k z?fmQ0$4fO87_yL@B%SCs$& literal 1657 zcmaJ>eM}Q)7=K&pC@yLtaZVTXIOB#g`b8=9q(beL6-Eh`V%ZdDZ4bC%?~dz1OVJ6s z42Z^$%|_;MfB40W0#maw#u{LLO@_?DoQ@%GbGmeZ6^CPqM)wvenhbWi+&%A`-}8HZ z@9%l;YO*q4n>BO6OaQ>FG(BzvfRDf!5k3c>F)y5nhp+jZE|<%u^Es!5C4k08Zy=B~ zyQP3I5*Axo@kJsDfDn{4<#M@(49rT~#g+g@?6Na38-S!_7h|y&5gf9CC?F{{>ThjB z5z?kc&G81Qfzc9$q~6UE+3rk})m>y&+0f(_NRkVK1a^Y6ATIkx%7MAm=r}J1D%X&OXla%};>B^XR;f&eD3xNFB3`MKy^6@CGPy(wZ)L1ZfyFB^c>*$V zp|Bcj%g2m(>O?KLQlo_&$6ykP)9DmD(aruh_r5H@h5*ChTO*FkR=wenO&C!lRnnASLN+jA$Qa0M@ zSUQe37_c~4}&~=?crP3s<)aeuniE@=vnV1mF z#c6AaouIg2uI*{AcG}#)DA*ZT87Ek>l(40;v>h2gGDc3XMKvwoM6PXmEt+X_B~Xkc z(AZ}h9o&M`69^~A7A__SpP=Bhvv90W4z;lG8yil;H6~Zz(6tWg79zsGmp*>{-A?q< z%cnb|&#!In_MEEeIy7UJ>B^UlgCStu`L=miF@^tvw&bB-=be42+#Kml&KSJ>RdT~k zUzICz|JX}g`mNxd5&hb#+v?)Vw-Pr0b=JBma(}b2obWI6uBrV1@R$cPN+I&%>-YOc zhr4fJ@t>b6^$Z-VJ5VQ#N~v&e2VwXbwYg_o`mo1)e3ZH~B1x$L{<(|ludg}hUEN zAyJe-$PCUvD+|B)Bi)^K%zMh|8Myz?Hqa40Qrzdw=`T9xHJ@MoV`I;9&uQ(u6`-SG zUbW!huOG+wG)MmK9LRBBy*Y<3ICS;`IkvjEY3|s%`D@;2P4}C+XNU9og64HdMD=^+ zjfX=$eKF-`U*4|dl!_e@Q;ANgm_jt*$)^+zc_Yw#FH)_hZ+-rN~ z_U3~-?_aL%q)%vI_3K~P0pafO6WV<~j62q3xN+xUL$)=h$m~1N`BT(Zz_;xc?rB%_ zY>O<>ufIJi9^r`)SIhRj?V}fh4hVRHZ=%D|O7d{%@;`UCclq*u3qexuvh$W!`gS#( zfKD$fs1ovdTUVhtzgIt}^oOX*4|`kBh6+W$+!7o4y^AL85kTAUYQfPx3x__@^5g2A zHFHEr`?qK`r4{0L4Kw`Vv#^tv9DDhma%2B;UXS?M?_Ra zZL0gzL$kxW>IRmq5Q>1rxhJCb(Y4OL9Ctli$_A+Je)N3CGpbZ0Bj@Tt2>AWVgQS5d R@G~?Ir0Fv8#+B>0{tKxNceVfk diff --git a/assets/images/transitions/square.png b/assets/images/transitions/square.png index 866f064adfa7c86c3e04eb5afd225cb3d3507cfb..a6667f2c76b07cdfd9cf702f8b6b70fc53df780a 100644 GIT binary patch delta 356 zcmca#`JZWmNGZx^prw85kHXJzX3_D(1YsYbkWdK)}^;!H)k^eOs8Bk9{&T z4*Sl!|?EXn|2rw8~XfyTH z3o)@YY+tN=;D@o00>e%jQO0BQLs&QtEZ++hI^4p*xapQQQ+X^&_&#E9xCAui2tUJYP5~`J zdj@gESce43kIWmC8JT`|%0DP#;V^Lj!_Y3E;1KqRUC*b1p+?BQz<`lyLidk_+(7S` we>|MY!oeWfG5;LUn^o#{OhBsRa_*l!42Szfnw?#RXD|SPr>mdKI;Vst0P`4t2LJ#7 literal 15583 zcmeI3&u`mg7{}jsg@#UrOq<38hgq4BK$~Mbv6I*&*|H{GE0IyUqIIXuvEQUt6Fak= zCGBMqy9_Z9LL3I#5w1v_Kp>5w0ped67f^R$41wS<4TLDKonP*ok6C+Z95902z2_x>ip z`!@~&@Z!3$vg)oDUs5!y7FBht1f#859rXqveY{mywRPw+C0H@cOyt+kzlbn~o{5~5 zihQv?2iJ^+O&gxsJiVfAu4}R$Ii8(Kw-h8$gRaW7YE{!wTA7HitDt+YnTs%f7k51q z$$0}ZtHmW|&axpRMI~0_V*-XwaSkpPu5$WmVp`+PG z-8C$e@pRRa)o?SBh&NFG*UhU|?+;`;U3Q2f*HY`85aqcsLB%3DtX3Nt>A1^qklDxq zot2F`=nzZW;@$; zsW*FOZqDDH%=2drQ@5JV3uz7y8El+^8qBLM%z7J}BkMrUn=DS(JO!Fm$B^WkHi6 z&#K9?%9cx_%$77=WTBKuX{sjaaar<{+!;P3owu}xw~>%^r-JB~hUEL(LxC_Emr|)R z8xu8D9t0?|vdov*QbJ56cs?b>V7xa_Kx}v*Xd9QHK5tt!|J2u2+kxI;%0zmnsb40# zTf;w&iZPsgJU&04<3(9W6?j1?h_akZo-7o^WGW^n5~*aG8wwrF2Z^UUZj@>-cMq$M z^6o0<{!KX$I#BLo7^I5rbhH>R+XgE1YBj(L8+>m3;Hc+liNGW}eHIJ{ov4k#_+H*# zxjh3f?riNjs>UuCroTL>$SJDk74od3qQ&*N2igXc>O^=0bvle#Qz@>-<7!f5OMm&)ZbO!f2w;p4|>u0azk06PwEXC{8H@gj~@cAKgVa}{((c2k== zsyoBR%WG?@S%G?%>t)t!z(dlUw{%tGzqoR{D@8*KkEb};9sh%s>#XO_qu47S!$&u* zYf9O&YpRhq}PK$Q1H_bLUOo^_fN)n^y38Y+6@i5@z8VR(4ZR+9Ynrr8g4e$9Sv&^M0u|riVx!qdew&6 zge1k$qY-b$BbJO7tghw_^l)^%0w;-LHwgEPj664pjH5aFqxpdWM>nvu7Xoj^{vq$Q zqIYiey3h6B_lM4Zzp_5cn?Xj8QWevpgJ3|&CdEbOgLx?~3<%kzxX64kFU5rcA)6Ez znGfcrxG*4Olj0)t!Mqd~283)JkWGq<%m?#QTo@3tNpX?+U|xy~141?_ zE;1j?OL1X9$R@=_=7V`DE({3Sq`1g@FfYZ00U?_d7nu*{rMNI4WRv0|^TE6n7Y2lE zQe0#{n3v+hfRIg!i_8b}Qd}4ivPp4~`Cwj(3j;znDK0V}%u8`$K*%P=MdpKfDJ~2M z*`&D0d@wJ?g#jU(6c?Ef=B2nWAY_w>Yi95TEi}<*vrY7U?3?>v@xHBPw1wp&0GrPN z(7pn|AKU2vJpdX!06$#-K)DXU)7CrZzn({Ze_71uR$AZveCNyAHgn*yob=%P-#^)N zceYVcz?0Vg2k+eh?HeCX)IYlnzAfCk`R5OlQ(#~C+3jSQ0q;g`J=_}xrF|Fv+Q)#8 zL;T;NaC>#?(B&|5;@IT1W8Xn%0^FbFeS(_kvpyG%@OO`m9k?gdR{3+bZE tRH%1B3R~0OErMkVn2i$(^z?JLmqZg4077M5IADz7L+CTO;*|7is diff --git a/flixel/addons/transition/FlxTransitionSprite.hx b/flixel/addons/transition/FlxTransitionSprite.hx index 67780982..f75b4120 100644 --- a/flixel/addons/transition/FlxTransitionSprite.hx +++ b/flixel/addons/transition/FlxTransitionSprite.hx @@ -1,14 +1,63 @@ package flixel.addons.transition; -import flixel.addons.transition.FlxTransitionSprite.TransitionStatus; import flixel.FlxG; import flixel.FlxSprite; +import flixel.addons.transition.FlxTransitionSprite; import flixel.graphics.FlxGraphic; import flixel.math.FlxPoint; import flixel.system.FlxAssets.FlxGraphicAsset; import flixel.util.FlxTimer; import openfl.display.BitmapData; +#if html5 +@:keep @:bitmap("assets/images/transitions/circle.png") +private class RawGraphicTransTileCircle extends BitmapData {} +class GraphicTransTileCircle extends RawGraphicTransTileCircle +{ + static inline var WIDTH = 544; + static inline var HEIGHT = 32; + + public function new(?onLoad) + { + super(WIDTH, HEIGHT, true, 0xFFffffff, onLoad); + // Set properties because `@:bitmap` constructors ignore width/height + this.width = WIDTH; + this.height = HEIGHT; + } +} + +@:keep @:bitmap("assets/images/transitions/diamond.png") +private class RawGraphicTransTileDiamond extends BitmapData {} +class GraphicTransTileDiamond extends RawGraphicTransTileDiamond +{ + static inline var WIDTH = 544; + static inline var HEIGHT = 32; + + public function new(?onLoad) + { + super(WIDTH, HEIGHT, true, 0xFFffffff, onLoad); + // Set properties because `@:bitmap` constructors ignore width/height + this.width = WIDTH; + this.height = HEIGHT; + } +} + +@:keep @:bitmap("assets/images/transitions/square.png") +class RawGraphicTransTileSquare extends BitmapData {} +class GraphicTransTileSquare extends RawGraphicTransTileSquare +{ + static inline var WIDTH = 544; + static inline var HEIGHT = 32; + + public function new(?onLoad) + { + super(WIDTH, HEIGHT, true, 0xFFffffff, onLoad); + // Set properties because `@:bitmap` constructors ignore width/height + this.width = WIDTH; + this.height = HEIGHT; + } +} +#else @:keep @:bitmap("assets/images/transitions/circle.png") class GraphicTransTileCircle extends BitmapData {} @@ -17,6 +66,7 @@ class GraphicTransTileDiamond extends BitmapData {} @:keep @:bitmap("assets/images/transitions/square.png") class GraphicTransTileSquare extends BitmapData {} +#end /** * @@ -45,6 +95,9 @@ class FlxTransitionSprite extends FlxSprite } _delay = Delay; loadGraphic(Graphic, true, GraphicWidth, GraphicHeight); + + if (graphic == null) + return; graphic.persist = true; graphic.destroyOnNoUse = false; diff --git a/flixel/addons/transition/Transition.hx b/flixel/addons/transition/Transition.hx index 989f1485..3802bfc0 100644 --- a/flixel/addons/transition/Transition.hx +++ b/flixel/addons/transition/Transition.hx @@ -34,17 +34,10 @@ class Transition extends FlxSubState add(_effect); } - override public function update(elapsed:Float):Void - { - super.update(elapsed); - _effect.update(elapsed); - } - public override function destroy():Void { super.destroy(); finishCallback = null; - _effect.destroy(); _effect = null; } diff --git a/flixel/addons/transition/TransitionFade.hx b/flixel/addons/transition/TransitionFade.hx index cf05b8e6..37e7b923 100644 --- a/flixel/addons/transition/TransitionFade.hx +++ b/flixel/addons/transition/TransitionFade.hx @@ -4,6 +4,7 @@ import flash.display.BitmapData; import flixel.addons.transition.TransitionEffect; import flixel.addons.transition.FlxTransitionSprite.TransitionStatus; import flixel.FlxSprite; +import flixel.graphics.FlxGraphic; import flixel.tweens.FlxTween; import flixel.util.FlxColor; import flixel.util.FlxGradient; @@ -12,208 +13,191 @@ import openfl.Assets; import openfl.display.BitmapDataChannel; import openfl.geom.Matrix; import openfl.geom.Point; +import openfl.geom.Rectangle; +#if html5 +@:keep @:bitmap("assets/images/transitions/diagonal_gradient.png") +private class RawGraphicDiagonalGradient extends BitmapData {} +class GraphicDiagonalGradient extends RawGraphicDiagonalGradient +{ + static inline var WIDTH = 319; + static inline var HEIGHT = 128; + + public function new(?onLoad) + { + super(WIDTH, HEIGHT, true, 0xFFffffff, onLoad); + // Set properties because `@:bitmap` constructors ignore width/height + this.width = WIDTH; + this.height = HEIGHT; + } +} +#else @:keep @:bitmap("assets/images/transitions/diagonal_gradient.png") private class GraphicDiagonalGradient extends BitmapData {} +#end +typedef TweenEndValues = { ?x:Float, ?y:Float, ?alpha:Float }; /** * * @author larsiusprime */ class TransitionFade extends TransitionEffect { + public static inline var GRADIENT_PATH = "flixel/images/transitions/diagonal_gradient.png"; + var back:FlxSprite; - var tweenStr:String = ""; - var tweenStr2:String = ""; - var tweenValStart:Float = 0; - var tweenValStart2:Float = 0; - var tweenValEnd:Float = 0; - var tweenValEnd2:Float = 0; - + public function new(data:TransitionData) { super(data); - + back = makeSprite(data.direction.x, data.direction.y, data.region); back.scrollFactor.set(0, 0); add(back); } - + public override function destroy():Void { super.destroy(); back = null; } - - public override function start(NewStatus:TransitionStatus):Void + + public override function start(newStatus:TransitionStatus):Void { - super.start(NewStatus); - - setTweenValues(NewStatus, _data.direction.x, _data.direction.y); - - switch (tweenStr) - { - case "alpha": - back.alpha = tweenValStart; - case "x": - back.x = tweenValStart; - case "y": - back.y = tweenValStart; - } - switch (tweenStr2) - { - case "alpha": - back.alpha = tweenValStart2; - case "x": - back.x = tweenValStart2; - case "y": - back.y = tweenValStart2; - } - - var Values:Dynamic = {}; - Reflect.setField(Values, tweenStr, tweenValEnd); - if (tweenStr2 != "") - { - Reflect.setField(Values, tweenStr2, tweenValEnd2); - } + super.start(newStatus); + + final endValues:TweenEndValues = {}; + setTweenValues(newStatus == IN, _data.direction.x, _data.direction.y, back, endValues); + _data.tweenOptions.onComplete = finishTween; - FlxTween.tween(back, Values, _data.duration, _data.tweenOptions); + FlxTween.tween(back, endValues, _data.duration, _data.tweenOptions); } - - function setTweenValues(NewStatus:TransitionStatus, DirX:Float, DirY:Float):Void + + function setTweenValues(isIn:Bool, dirX:Float, dirY:Float, sprite:FlxSprite, values:TweenEndValues) { - if (DirX == 0 && DirY == 0) + final isOut = !isIn; + if (dirX == 0 && dirY == 0) { // no direction - tweenStr = "alpha"; - tweenValStart = NewStatus == IN ? 0.0 : 1.0; - tweenValEnd = NewStatus == IN ? 1.0 : 0.0; + sprite.alpha = isIn ? 0 : 1; + values.alpha = isOut ? 0 : 1; } - else if (Math.abs(DirX) > 0 && DirY == 0) + else if (dirX != 0 && dirY != 0) { - // horizontal wipe - tweenStr = "x"; - if (DirX > 0) + // diagonal wipe + if (dirX > 0) { - tweenValStart = NewStatus == IN ? -back.width : 0; - tweenValEnd = NewStatus == IN ? 0 : -back.width; + sprite.x = isIn ? -back.width : 0; + values.x = isOut ? -back.width : 0; } else { - tweenValStart = NewStatus == IN ? FlxG.width : -back.width / 2; - tweenValEnd = NewStatus == IN ? -back.width / 2 : FlxG.width; + sprite.x = isIn ? FlxG.width : FlxG.width - back.width; + values.x = isOut ? FlxG.width : FlxG.width - back.width; } + + return; } - else if ((DirX == 0 && Math.abs(DirY) > 0)) + else if (dirX != 0) { - // vertical wipe - tweenStr = "y"; - if (DirY > 0) + // horizontal wipe + if (dirX > 0) { - tweenValStart = NewStatus == IN ? -back.height : 0; - tweenValEnd = NewStatus == IN ? 0 : -back.height; + sprite.x = isIn ? -back.width : 0; + values.x = isOut ? -back.width : 0; } else { - tweenValStart = NewStatus == IN ? FlxG.height : -back.height / 2; - tweenValEnd = NewStatus == IN ? -back.height / 2 : FlxG.height; + sprite.x = isIn ? FlxG.width : -back.width / 2; + values.x = isOut ? FlxG.width : -back.width / 2; } } - else if (Math.abs(DirX) > 0 && Math.abs(DirY) > 0) + else { - // diagonal wipe - tweenStr = "x"; - tweenStr2 = "y"; - if (DirX > 0) - { - tweenValStart = NewStatus == IN ? -back.width : 0; - tweenValEnd = NewStatus == IN ? 0 : -back.width; - } - else - { - tweenValStart = NewStatus == IN ? FlxG.width : -back.width * (2 / 3); - tweenValEnd = NewStatus == IN ? -back.width * (2 / 3) : FlxG.width; - } - if (DirY > 0) + // vertical wipe + if (dirY > 0) { - tweenValStart2 = NewStatus == IN ? -back.height : 0; - tweenValEnd2 = NewStatus == IN ? 0 : -back.height; + sprite.y = isIn ? -back.height : 0; + values.y = isOut ? -back.height : 0; } else { - tweenValStart2 = NewStatus == IN ? FlxG.height : -back.height * (2 / 3); - tweenValEnd2 = NewStatus == IN ? -back.height * (2 / 3) : FlxG.height; + sprite.y = isIn ? FlxG.height : -back.height / 2; + values.y = isOut ? FlxG.height : -back.height / 2; } } } - - function makeSprite(DirX:Float, DirY:Float, region:FlxRect):FlxSprite + + function makeSprite(dirX:Float, dirY:Float, region:FlxRect):FlxSprite { - var s = new FlxSprite(region.x, region.y); - var locX:Float = 0; - var locY:Float = 0; - var angle:Int = 0; - var pixels:BitmapData = null; - if (DirX == 0 && DirY == 0) + final sprite = new FlxSprite(region.x, region.y); + + if (dirX == 0 && dirY == 0) { // no direction - s.makeGraphic(Std.int(region.width), Std.int(region.height), _data.color); + sprite.makeGraphic(Std.int(region.width), Std.int(region.height), _data.color); } - else if (DirX == 0 && Math.abs(DirY) > 0) + else if (dirX == 0 && dirY != 0) { // vertical wipe - locY = DirY > 0 ? region.height : 0; - angle = DirY > 0 ? 90 : 270; - s.makeGraphic(1, Std.int(region.height * 2), _data.color); - pixels = s.pixels; - var gvert = FlxGradient.createGradientBitmapData(1, Std.int(region.height), [_data.color, FlxColor.TRANSPARENT], 1, angle); - pixels.copyPixels(gvert, gvert.rect, new Point(0, locY)); - s.pixels = pixels; - s.scale.set(region.width, 1.0); - s.updateHitbox(); + sprite.makeGraphic(1, Std.int(region.height * 2), _data.color); + final angle = dirY > 0 ? 90 : 270; + final gradient = FlxGradient.createGradientBitmapData(1, Std.int(region.height), [_data.color, FlxColor.TRANSPARENT], 1, angle); + final destY = dirY > 0 ? region.height : 0; + sprite.pixels.copyPixels(gradient, gradient.rect, new Point(0, destY)); + sprite.scale.set(region.width, 1.0); + sprite.updateHitbox(); } - else if (Math.abs(DirX) > 0 && DirY == 0) + else if (dirX != 0 && dirY == 0) { // horizontal wipe - locX = DirX > 0 ? region.width : 0; - angle = DirX > 0 ? 0 : 180; - s.makeGraphic(Std.int(region.width * 2), 1, _data.color); - pixels = s.pixels; - var ghorz = FlxGradient.createGradientBitmapData(Std.int(region.width), 1, [_data.color, FlxColor.TRANSPARENT], 1, angle); - pixels.copyPixels(ghorz, ghorz.rect, new Point(locX, 0)); - s.pixels = pixels; - s.scale.set(1.0, region.height); - s.updateHitbox(); + final destX = dirX > 0 ? region.width : 0; + final angle = dirX > 0 ? 0 : 180; + sprite.makeGraphic(Std.int(region.width * 2), 1, _data.color); + final gradient = FlxGradient.createGradientBitmapData(Std.int(region.width), 1, [_data.color, FlxColor.TRANSPARENT], 1, angle); + sprite.pixels.copyPixels(gradient, gradient.rect, new Point(destX, 0)); + sprite.scale.set(1.0, region.height); + sprite.updateHitbox(); } - else if (Math.abs(DirX) > 0 && Math.abs(DirY) > 0) + else if (dirX != 0 && dirY != 0) { // diagonal wipe - locY = DirY > 0 ? region.height : 0; - s.loadGraphic(getGradient()); - s.flipX = DirX < 0; - s.flipY = DirY < 0; + sprite.loadGraphic(getGradient()); + sprite.color = _data.color; + sprite.flipX = dirX < 0; + sprite.flipY = dirY < 0; } - return s; + + return sprite; } - - function getGradient():BitmapData + + function getGradient():FlxGraphic { - // TODO: this could perhaps be optimized a lot by creating a single-pixel wide sprite, rotating it, scaling it super big, and positioning it properly - var rawBmp = new GraphicDiagonalGradient(0, 0); - var gdiag:BitmapData = cast rawBmp; - var gdiag_scaled:BitmapData = new BitmapData(FlxG.width * 2, FlxG.height * 2, true); - var m:Matrix = new Matrix(); - m.scale(gdiag_scaled.width / gdiag.width, gdiag_scaled.height / gdiag.height); - gdiag_scaled.draw(gdiag, m, null, null, null, true); - var theColor:FlxColor = _data.color; - var final_pixels:BitmapData = new BitmapData(FlxG.width * 3, FlxG.height * 3, true, theColor); - final_pixels.copyChannel(gdiag_scaled, gdiag_scaled.rect, - new Point(final_pixels.width - gdiag_scaled.width, final_pixels.height - gdiag_scaled.height), BitmapDataChannel.RED, BitmapDataChannel.ALPHA); - gdiag.dispose(); - gdiag_scaled.dispose(); - return final_pixels; + // TODO: create this gradient using FlxGradient + final gameWidth = FlxG.width; + final gameHeight = FlxG.height; + final source = FlxG.bitmap.add(GRADIENT_PATH).bitmap; + final key = '$GRADIENT_PATH:${gameWidth}x${gameHeight}'; + + var graphic = FlxG.bitmap.get(key); + if (graphic == null) + { + final gradient = new BitmapData(Math.floor(gameWidth * 2.5), gameHeight, true, 0x0); + + // draw the gradient in the cleared area + final matrix:Matrix = new Matrix(); + matrix.scale(gradient.width / source.width, gradient.height / source.height); + gradient.draw(source, matrix, null, null, null, true); + + // Don't destroy transition bitmaps + graphic = FlxG.bitmap.add(gradient, false, key); + graphic.persist = true; + graphic.destroyOnNoUse = false; + } + + return graphic; } - + function finishTween(f:FlxTween):Void { delayThenFinish(); diff --git a/include.xml b/include.xml index ede498f9..665e6da8 100644 --- a/include.xml +++ b/include.xml @@ -4,4 +4,6 @@ + + From d5cc8a066f97cc985e519061915f64369e8beee0 Mon Sep 17 00:00:00 2001 From: George FunBook Date: Thu, 27 Jul 2023 12:02:17 -0500 Subject: [PATCH 16/69] add #390 #394 and #396 changelog --- CHANGELOG.md | 182 ++++++++++++++++++++++++++++----------------------- haxelib.json | 4 +- 2 files changed, 103 insertions(+), 83 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9062d643..2a5c78c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,23 @@ +3.1.2 (TBD) +------------------------------ +#### Changes and improvements: +- `FlxSkewedSprite`: Allow shaders ([#390](https://github.com/HaxeFlixel/flixel-addons/pull/390)) +- `FlxBackdrop`: Use pooled `FlxPoint` for `spacing` ([#394](https://github.com/HaxeFlixel/flixel-addons/pull/394)) +- `FlxMouseControl`: Deprecated, use [FlxMouseEvent](https://haxeflixel.com/demos/FlxMouseEvent/) instead +- `FlxTransitionSprite`: Fix transition sprite graphics on html5 ([#396](https://github.com/HaxeFlixel/flixel-addons/pull/396)) + - Compress and include asset paths for transition images: + - "flixel/images/transitions/circle.png" + - "flixel/images/transitions/square.png" + - "flixel/images/transitions/diamond.png" + - "flixel/images/transitions/diagonal_gradient.png" + - Fix graphic classes + - `GraphicTransTileCircle` + - `GraphicTransTileSquare` + - `GraphicTransTileDiamond` + - `GraphicDiagonalGradient` + - prevent double update on transitions + - optimize wipe transitions, especially diagonal wipe + 3.1.1 (May 19, 2023) ------------------------------ #### Changes and improvements: @@ -52,8 +72,8 @@ 2.8.0 (February 8, 2020) ------------------------------ * `FlxSliceSprite`: - * added `sourceRect` and `fillCenter` (#334) - * redid the implementation to make it work on older machines and in Safari (#335) + * added `sourceRect` and `fillCenter` (#334) + * redid the implementation to make it work on older machines and in Safari (#335) * Added `flixel.addons.editors.ogmo.FlxOgmo3Loader` (#337) * `flixel.addons.editors.tiled`: added support for grouped layers (#332) @@ -73,9 +93,9 @@ ------------------------------ * Compatibility with flixel 4.6.0 and Haxe 4.0.0-rc.1 * `flixel.addons.editors.tiled`: - * `TiledTileSet`: fixed `numRows` and `numCols` being flipped (#326) - * added support for Tiled Collision Editor (#327) - * `TiledImageLayer`: improved documentation (#329) + * `TiledTileSet`: fixed `numRows` and `numCols` being flipped (#326) + * added support for Tiled Collision Editor (#327) + * `TiledImageLayer`: improved documentation (#329) 2.7.1 (November 10, 2018) ------------------------------ @@ -97,9 +117,9 @@ * `FlxShapeCircle`: fixed some rounding issues (#304) * `FlxExtendedSprite`: fixed click callbacks not working without drag (#308) * `flixel.addons.editors.tiled`: - * fixed loading of external tile sets (#312) - * improved error messages for invalid paths (#312) - * fixed compatibility with Haxe 4 + * fixed loading of external tile sets (#312) + * improved error messages for invalid paths (#312) + * fixed compatibility with Haxe 4 * `FlxSlider`: fixed bounds not being updated after position changes (#306) 2.5.0 (July 22, 2017) @@ -114,9 +134,9 @@ ------------------------------ * `FlxWeapon`: added `angleOffset` to `FlxWeaponFireFrom.PARENT` (#292) * `FlxTypeText`: - * changed `start()` and `erase()` to always set the callbacks (#293) - * stop sounds when typing is complete (#295) - * added `finishSounds` (#296) + * changed `start()` and `erase()` to always set the callbacks (#293) + * stop sounds when typing is complete (#295) + * added `finishSounds` (#296) * `TiledTileLayer`: removed an unnecessary warning on HTML5 (3c79b46) 2.3.0 (February 10, 2017) @@ -124,8 +144,8 @@ * `FlxBackdrop`: fixed `color` not working with tilesheet rendering (#277) * `FlxWeapon`: fixed `FIRE_FROM_PARENT_FACING` angles (#259) * `FlxSliceSprite`: - * added setters for `alpha` and `color` (#276) - * fixed a rendering issue on Flash (#275) + * added setters for `alpha` and `color` (#276) + * fixed a rendering issue on Flash (#275) * `flixel.addons.editors.spine`: support for spinehaxe version 3.5.0 (#281) * `TiledObject`: fixed `gid` handling of flipped objects (#287) @@ -134,8 +154,8 @@ * Compatibility with flixel 4.2.0 * `FlxWeaponFireFrom`: added a `useParentAngle` argument to `PARENT` (#261) * `FlxPexParser`: - * added a `scale` argument to `new()` (#263) - * added support for blend modes (#270) + * added a `scale` argument to `new()` (#263) + * added support for blend modes (#270) * `FlxSpine`: fixed an issue with texture loading and state switches (#265) * `FlxTypeText`: added support for adding / removing more than one char per frame (#267) * `flixel.addons.editors.tiled`: added support for animated tiles (#268) @@ -153,17 +173,17 @@ * `FlxEffectSprite`: added `updateTargetAnimation` (#236) * `FlxControlHandler`: added `invertX` and `invertY` (#239) * `FlxBackdrop`: - * added support for `alpha` (#244) - * added support for `offset` + * added support for `alpha` (#244) + * added support for `offset` * `TiledMap`: - * added a `rootPath` argument to `new()` (#245) - * renamed `FlxTiledAsset` to `FlxTiledMapAsset` (#245) + * added a `rootPath` argument to `new()` (#245) + * renamed `FlxTiledAsset` to `FlxTiledMapAsset` (#245) * `TiledTileLayer`: - * added support for CSV encoding to `tileArray` (#245) - * changed `new()`'s `data` argument from `Dynamic` to `FlxTiledTileAsset` (#245) + * added support for CSV encoding to `tileArray` (#245) + * changed `new()`'s `data` argument from `Dynamic` to `FlxTiledTileAsset` (#245) * `TiledObject`: - * changed the default name from `"[object]"` to `""` (#247) - * [Neko] fixed the types of `flippedHorizontally` / `flippedVertically` + * changed the default name from `"[object]"` to `""` (#247) + * [Neko] fixed the types of `flippedHorizontally` / `flippedVertically` * `TiledLayer`: added `offsetX` and `offsetY` (#251) * `FlxFSM`: [Neko] fixed an invalid field access error (#257) * Added `FlxTiledSprite` @@ -173,71 +193,71 @@ ------------------------------ * Compatibility with flixel 4.0.0 * `flixel.addons.editors.tiled`: - * `TiledLayer` and `TiledObjectGroup` have been replaced with `TiledTileLayer` and `TiledObjectLayer` with a common base class `TiledLayer` - * `TiledMap` now stores object layers and tile layers in a single array, `layers`, to maintain the order of object and tile layers - * `TileTileLayer`: added `encoding` - * `TiledTileSet`: added `"id"` to `tileProps` - * added `TiledImageLayer` - * added `TiledImageTile` and `TiledTileSet#tileImagesSources` + * `TiledLayer` and `TiledObjectGroup` have been replaced with `TiledTileLayer` and `TiledObjectLayer` with a common base class `TiledLayer` + * `TiledMap` now stores object layers and tile layers in a single array, `layers`, to maintain the order of object and tile layers + * `TileTileLayer`: added `encoding` + * `TiledTileSet`: added `"id"` to `tileProps` + * added `TiledImageLayer` + * added `TiledImageTile` and `TiledTileSet#tileImagesSources` * `FlxTileSpecial`: - * fixed bugs related to rotation happening after flipping - * `flipHorizontal` -> `flipX` - * `flipVertical` -> `flipY` + * fixed bugs related to rotation happening after flipping + * `flipHorizontal` -> `flipX` + * `flipVertical` -> `flipY` * added `flixel.addons.util.FlxFSM` * `FlxTrail`: - * now extends `FlxSpriteGroup` - * now supports animations + * now extends `FlxSpriteGroup` + * now supports animations * `FlxTrailArea`: fixed the `offset` of sprites not being taken into account * `flixel.addons.weapon`: - * abstracted `FlxWeapon` into `FlxTypedWeapon` (`FlxWeapon` is now a `typedef` for `FlxTypedWeapon`) - * `FlxTypedWeapon#new()` now requires a `BulletFactory` function - * moved firing logic from `FlxBullet` to `FlxTypedWeapon` - * removed `onFireCallback` and `onFireSound` + * abstracted `FlxWeapon` into `FlxTypedWeapon` (`FlxWeapon` is now a `typedef` for `FlxTypedWeapon`) + * `FlxTypedWeapon#new()` now requires a `BulletFactory` function + * moved firing logic from `FlxBullet` to `FlxTypedWeapon` + * removed `onFireCallback` and `onFireSound` * `FlxTypeText`: - * changed `Dynamic` callbacks to `Void->Void` - * replaced `sound` by a `sounds` array, from which one is randomly picked - * fixed jumping between lines during typing - * added `useDefaultSound` which is `false` by default + * changed `Dynamic` callbacks to `Void->Void` + * replaced `sound` by a `sounds` array, from which one is randomly picked + * fixed jumping between lines during typing + * added `useDefaultSound` which is `false` by default * added `flixel.addons.editors.pex.FlxPexParser` * added `flixel.addons.transition` * added `flixel.addons.util.FlxScene` * `flixel.addons.nape`: - * refactored `FlxNapeState` into a plugin called `FlxNapeSpace`, making it possible to use nape with other `FlxState` child classes like `FlxUIState` - * `FlxNapeSpace`: added `napePhysicsEnabled` - * `FlxNapeSpace`: made `shapeDebug` public - * `FlxNapeSprite`: `setPosition()` is now overridden and sets `body.position` - * `FlxNapeSprite#new()`: the `EnablePhysics` argument is now no longer ignored if `CreateRectangularBody` is `false` + * refactored `FlxNapeState` into a plugin called `FlxNapeSpace`, making it possible to use nape with other `FlxState` child classes like `FlxUIState` + * `FlxNapeSpace`: added `napePhysicsEnabled` + * `FlxNapeSpace`: made `shapeDebug` public + * `FlxNapeSprite`: `setPosition()` is now overridden and sets `body.position` + * `FlxNapeSprite#new()`: the `EnablePhysics` argument is now no longer ignored if `CreateRectangularBody` is `false` * `flixel.addons.plugin.taskManager`: - * `AntTaskManager` -> `FlxTaskManager` - * `AntTask` -> `FlxTask` + * `AntTaskManager` -> `FlxTaskManager` + * `AntTask` -> `FlxTask` * `FlxBackdrop`: added support for `scale`, `loadGraphic()` and `loadFrame()` * `flixel.addons.editors.spine`: - * now uses [spinehaxe](https://github.com/bendmorris/spinehaxe) instead of [spinehx](https://github.com/nitrobin/spinehx) - * `FlxSpine#readSkeletonData()` now allows for different atlas and animation file names + * now uses [spinehaxe](https://github.com/bendmorris/spinehaxe) instead of [spinehx](https://github.com/nitrobin/spinehx) + * `FlxSpine#readSkeletonData()` now allows for different atlas and animation file names * `FlxOgmoLoader`: - * added `getProperty()` - * the constructor no longer sets the camera bounds + * added `getProperty()` + * the constructor no longer sets the camera bounds * `FlxScreenGrab`: - * fixed `defineHotkeys()` arguments overriding those in `grab()` - * now uses linc_dialogs instead of systools on native targets + * fixed `defineHotkeys()` arguments overriding those in `grab()` + * now uses linc_dialogs instead of systools on native targets * `FlxTilemapExt`: - * added support for slopes with 22.5 and 67.5 degrees - * added `setGentle()` and `setSteep()` - * removed `setClouds()` + * added support for slopes with 22.5 and 67.5 degrees + * added `setGentle()` and `setSteep()` + * removed `setClouds()` * `FlxExtendedSprite`: `mouseStartDragCallback` and `mouseStopDragCallback` now work * added `flixel.addons.display.FlxPieDial` * `FlxGridOverlay`: removed the non-functional `AddLegend` arguments * `FlxZoomCamera`: made `zoomSpeed` and `zoomMargin` public * added `flixel.addons.text.FlxTextField` (moved from core Flixel) * added `flixel.addons.effects.chainable`: - * `IFlxEffect` - * `FlxEffectSprite` - * `FlxGlitchEffect` (replaces `FlxGlitchSprite`) - * `FlxWaveEffect` (replaces `FlxWaveSprite`) - * `FlxRainbowEffect` - * `FlxOutlineEffect` - * `FlxTrailEffect` - * `FlxShakeEffect` + * `IFlxEffect` + * `FlxEffectSprite` + * `FlxGlitchEffect` (replaces `FlxGlitchSprite`) + * `FlxWaveEffect` (replaces `FlxWaveSprite`) + * `FlxRainbowEffect` + * `FlxOutlineEffect` + * `FlxTrailEffect` + * `FlxShakeEffect` * added `flixel.addons.effects.FlxClothSprite` 1.1.1 (December 15, 2015) @@ -251,21 +271,21 @@ * Refactored StarFieldFX into FlxStarField2D and FlxStarField3D * FlxBullet: removed redundant xGravity, yGravity, maxVelocityX and maxVelocityY * FlxButtonPlus: - * Fixed initial text visibility - * Added setters for the member sprites and texts so you can change them - * Constructor params X and Y are now Floats + * Fixed initial text visibility + * Added setters for the member sprites and texts so you can change them + * Constructor params X and Y are now Floats * FlxExtendedSprite: mouseStartDragCallback and mouseStopDragCallback now use MouseCallback (instead of Dynamic) * FlxSlider: fixed uniqueness of the body sprite graphic * FlxNestedSprite: fixed a potential issue in destroy() * TiledObjectGroup: - * Removed x, y, width and height vars - * Added map and color vars + * Removed x, y, width and height vars + * Added map and color vars * FlxTypeText: added skip() * FlxNapeState: fixed issue with nape debug draw not showing on native targets * Refactored AntTaskManager: - * Switched to Bool->Void callbacks as opposed to Dynamic - * Now extends FlxBasic and has to be add()ed - * Removed pause variable + * Switched to Bool->Void callbacks as opposed to Dynamic + * Now extends FlxBasic and has to be add()ed + * Removed pause variable * FlxControlHandler: added compensation for diagonal movement * Added FlxNapeTilemap * Added FlxWaveSprite @@ -282,17 +302,17 @@ ------------------------------ * Compatibility with flixel 3.1.0 * FlxButtonPlus: - * fixed button graphic always being white - * use Void->Void for the callback function for consistency with the FlxTypedButton changes ([more info](https://github.com/HaxeFlixel/flixel/issues/805?source=cc)) + * fixed button graphic always being white + * use Void->Void for the callback function for consistency with the FlxTypedButton changes ([more info](https://github.com/HaxeFlixel/flixel/issues/805?source=cc)) * Moved shape classes from flixel-ui to flixel.addons.display.shapes * Added FlxAsyncLoop * FlxNestedSprite: - * fixes for update and draw calls - * added relativeAlpha to fix the alpha calculation + * fixes for update and draw calls + * added relativeAlpha to fix the alpha calculation * FlxSkewedSprite: - * added SimpleGraphic param to the constructor - * now correctly works with origin on cpp targets - * exposed the transformation matrix via transformMatrix and matrixExposed + * added SimpleGraphic param to the constructor + * now correctly works with origin on cpp targets + * exposed the transformation matrix via transformMatrix and matrixExposed * Moved FlxTrail, FlxTrailArea and FlxSlider into flixel-addons 1.0.1 (December 28, 2013) diff --git a/haxelib.json b/haxelib.json index dd5ed5b3..273301ad 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.1.1", - "releasenote": "Fix enum deprecation warnings in haxe 4.3.1", + "version": "3.1.2", + "releasenote": "Fix transition sprite graphics on html5", "contributors": ["haxeflixel", "Gama11", "GeoKureli"] } From f0b2b4f39b797b3f115297eeadb6ccda623a59b7 Mon Sep 17 00:00:00 2001 From: Mihai Alexandru <77043862+MAJigsaw77@users.noreply.github.com> Date: Mon, 7 Aug 2023 06:36:27 +0300 Subject: [PATCH 17/69] Runtime Shaders (#399) * Runtime Shaders * Use lime.utils.Float32Array * Fixed `lime.utils.Log.throwErrors = false;` Letting users to chose where own way to load shaders * A bit more understandable warnings --- flixel/addons/display/FlxRuntimeShader.hx | 651 ++++++++++++++++++++++ 1 file changed, 651 insertions(+) create mode 100644 flixel/addons/display/FlxRuntimeShader.hx diff --git a/flixel/addons/display/FlxRuntimeShader.hx b/flixel/addons/display/FlxRuntimeShader.hx new file mode 100644 index 00000000..9ab2b6e8 --- /dev/null +++ b/flixel/addons/display/FlxRuntimeShader.hx @@ -0,0 +1,651 @@ +package flixel.addons.display; + +#if (FLX_DRAW_QUADS && !flash) +import flixel.graphics.tile.FlxGraphicsShader; +#if lime +import lime.utils.Float32Array; +#end +import openfl.display.BitmapData; +import openfl.display.ShaderInput; +import openfl.display.ShaderParameter; +import openfl.display.ShaderParameterType; + +using StringTools; + +/** + * An wrapper for Flixel/OpenFL's shaders, which takes fragment and vertex source + * in the constructor instead of using macros so it can be provided at runtime. + * + * @author MasterEric + * @author Mihai Alexandru (M.A. Jigsaw) + * + * @see https://github.com/openfl/openfl/blob/develop/src/openfl/utils/_internal/ShaderMacro.hx + * @see https://dixonary.co.uk/blog/shadertoy + */ +class FlxRuntimeShader extends FlxGraphicsShader +{ + private static final BASE_VERTEX_HEADER:String = "attribute float openfl_Alpha; + attribute vec4 openfl_ColorMultiplier; + attribute vec4 openfl_ColorOffset; + attribute vec4 openfl_Position; + attribute vec2 openfl_TextureCoord; + + varying float openfl_Alphav; + varying vec4 openfl_ColorMultiplierv; + varying vec4 openfl_ColorOffsetv; + varying vec2 openfl_TextureCoordv; + + uniform mat4 openfl_Matrix; + uniform bool openfl_HasColorTransform; + uniform vec2 openfl_TextureSize;"; + + private static final BASE_VERTEX_BODY:String = "openfl_Alphav = openfl_Alpha; + openfl_TextureCoordv = openfl_TextureCoord; + + if (openfl_HasColorTransform) + { + openfl_ColorMultiplierv = openfl_ColorMultiplier; + openfl_ColorOffsetv = openfl_ColorOffset / 255.0; + } + + gl_Position = openfl_Matrix * openfl_Position;"; + + private static final BASE_VERTEX_SOURCE:String = "#pragma header + + attribute float alpha; + attribute vec4 colorMultiplier; + attribute vec4 colorOffset; + uniform bool hasColorTransform; + + void main(void) + { + #pragma body + + openfl_Alphav = openfl_Alpha * alpha; + + if (hasColorTransform) + { + openfl_ColorOffsetv = colorOffset / 255.0; + openfl_ColorMultiplierv = colorMultiplier; + } + }"; + + private static final BASE_FRAGMENT_HEADER:String = "varying float openfl_Alphav; + varying vec4 openfl_ColorMultiplierv; + varying vec4 openfl_ColorOffsetv; + varying vec2 openfl_TextureCoordv; + + uniform bool openfl_HasColorTransform; + uniform vec2 openfl_TextureSize; + uniform sampler2D bitmap; + + uniform bool hasTransform; + uniform bool hasColorTransform; + + vec4 flixel_texture2D(sampler2D bitmap, vec2 coord) + { + vec4 color = texture2D(bitmap, coord); + + if (!hasTransform) + { + return color; + } + + if (color.a == 0.0) + { + return vec4(0.0, 0.0, 0.0, 0.0); + } + + if (!hasColorTransform) + { + return color * openfl_Alphav; + } + + color = vec4(color.rgb / color.a, color.a); + + mat4 colorMultiplier = mat4(0); + colorMultiplier[0][0] = openfl_ColorMultiplierv.x; + colorMultiplier[1][1] = openfl_ColorMultiplierv.y; + colorMultiplier[2][2] = openfl_ColorMultiplierv.z; + colorMultiplier[3][3] = openfl_ColorMultiplierv.w; + + color = clamp(openfl_ColorOffsetv + (color * colorMultiplier), 0.0, 1.0); + + if (color.a > 0.0) + { + return vec4(color.rgb * color.a * openfl_Alphav, color.a * openfl_Alphav); + } + + return vec4(0.0, 0.0, 0.0, 0.0); + }"; + + private static final BASE_FRAGMENT_BODY:String = "vec4 color = texture2D(bitmap, openfl_TextureCoordv); + + if (color.a == 0.0) + { + gl_FragColor = vec4 (0.0, 0.0, 0.0, 0.0); + } + else if (openfl_HasColorTransform) + { + color = vec4 (color.rgb / color.a, color.a); + + mat4 colorMultiplier = mat4 (0); + colorMultiplier[0][0] = openfl_ColorMultiplierv.x; + colorMultiplier[1][1] = openfl_ColorMultiplierv.y; + colorMultiplier[2][2] = openfl_ColorMultiplierv.z; + colorMultiplier[3][3] = 1.0; // openfl_ColorMultiplierv.w; + + color = clamp (openfl_ColorOffsetv + (color * colorMultiplier), 0.0, 1.0); + + if (color.a > 0.0) + { + gl_FragColor = vec4 (color.rgb * color.a * openfl_Alphav, color.a * openfl_Alphav); + } + else + { + gl_FragColor = vec4 (0.0, 0.0, 0.0, 0.0); + } + } + else + { + gl_FragColor = color * openfl_Alphav; + }"; + + private static final BASE_FRAGMENT_SOURCE:String = "#pragma header + + void main(void) + { + gl_FragColor = flixel_texture2D(bitmap, openfl_TextureCoordv); + }"; + + /** + * Creates a `FlxRuntimeShader` with specified shader sources. + * If none is provided, it will use the default shader sources. + * + * @param fragmentSource The fragment shader source. + * @param vertexSource The vertex shader source. + */ + public function new(?fragmentSource:String, ?vertexSource:String):Void + { + if (fragmentSource != null && fragmentSource.length > 0) + glFragmentSource = fragmentSource; + else + glFragmentSource = BASE_FRAGMENT_SOURCE; + + if (vertexSource != null && vertexSource.length > 0) + glVertexSource = vertexSource; + else + glVertexSource = BASE_VERTEX_SOURCE; + + super(); + } + + /** + * Modify a float parameter of the shader. + * + * @param name The name of the parameter to modify. + * @param value The new value to use. + */ + public function setFloat(name:String, value:Float):Void + { + var prop:ShaderParameter = Reflect.field(data, name); + + if (prop == null) + { + FlxG.log.warn('Shader float property "$name" not found.'); + return; + } + + prop.value = [value]; + } + + /** + * Retrieve a float parameter of the shader. + * + * @param name The name of the parameter to retrieve. + */ + public function getFloat(name:String):Null + { + var prop:ShaderParameter = Reflect.field(data, name); + + if (prop == null) + { + FlxG.log.warn('Shader float property "$name" not found.'); + return null; + } + + return prop.value[0]; + } + + /** + * Modify a float array parameter of the shader. + * + * @param name The name of the parameter to modify. + * @param value The new value to use. + */ + public function setFloatArray(name:String, value:Array):Void + { + var prop:ShaderParameter = Reflect.field(data, name); + + if (prop == null) + { + FlxG.log.warn('Shader float[] property "$name" not found.'); + return; + } + + prop.value = value; + } + + /** + * Retrieve a float array parameter of the shader. + * + * @param name The name of the parameter to retrieve. + */ + public function getFloatArray(name:String):Null> + { + var prop:ShaderParameter = Reflect.field(data, name); + + if (prop == null) + { + FlxG.log.warn('Shader float[] property "$name" not found.'); + return null; + } + + return prop.value; + } + + /** + * Modify an integer parameter of the shader. + * + * @param name The name of the parameter to modify. + * @param value The new value to use. + */ + public function setInt(name:String, value:Int):Void + { + var prop:ShaderParameter = Reflect.field(data, name); + + if (prop == null) + { + FlxG.log.warn('Shader int property "$name" not found.'); + return; + } + + prop.value = [value]; + } + + /** + * Retrieve an integer parameter of the shader. + * + * @param name The name of the parameter to retrieve. + */ + public function getInt(name:String):Null + { + var prop:ShaderParameter = Reflect.field(data, name); + + if (prop == null) + { + FlxG.log.warn('Shader int property "$name" not found.'); + return null; + } + + return prop.value[0]; + } + + /** + * Modify an integer array parameter of the shader. + * + * @param name The name of the parameter to modify. + * @param value The new value to use. + */ + public function setIntArray(name:String, value:Array):Void + { + var prop:ShaderParameter = Reflect.field(data, name); + + if (prop == null) + { + FlxG.log.warn('Shader int[] property "$name" not found.'); + return; + } + + prop.value = value; + } + + /** + * Retrieve an integer array parameter of the shader. + * + * @param name The name of the parameter to retrieve. + */ + public function getIntArray(name:String):Null> + { + var prop:ShaderParameter = Reflect.field(data, name); + + if (prop == null) + { + FlxG.log.warn('Shader int[] property "$name" not found.'); + return null; + } + + return prop.value; + } + + /** + * Modify a bool parameter of the shader. + * + * @param name The name of the parameter to modify. + * @param value The new value to use. + */ + public function setBool(name:String, value:Bool):Void + { + var prop:ShaderParameter = Reflect.field(data, name); + + if (prop == null) + { + FlxG.log.warn('Shader bool property "$name" not found.'); + return; + } + + prop.value = [value]; + } + + /** + * Retrieve a bool parameter of the shader. + * + * @param name The name of the parameter to retrieve. + */ + public function getBool(name:String):Null + { + var prop:ShaderParameter = Reflect.field(data, name); + + if (prop == null) + { + FlxG.log.warn('Shader bool property "$name" not found.'); + return null; + } + + return prop.value[0]; + } + + /** + * Modify a bool array parameter of the shader. + * + * @param name The name of the parameter to modify. + * @param value The new value to use. + */ + public function setBoolArray(name:String, value:Array):Void + { + var prop:ShaderParameter = Reflect.field(data, name); + + if (prop == null) + { + FlxG.log.warn('Shader bool[] property "$name" not found.'); + return; + } + + prop.value = value; + } + + /** + * Retrieve a bool array parameter of the shader. + * + * @param name The name of the parameter to retrieve. + */ + public function getBoolArray(name:String):Null> + { + var prop:ShaderParameter = Reflect.field(data, name); + + if (prop == null) + { + FlxG.log.warn('Shader bool[] property "$name" not found.'); + return null; + } + + return prop.value; + } + + /** + * Modify a bitmap data parameter of the shader. + * + * @param name The name of the parameter to modify. + * @param value The new value to use. + */ + public function setSampler2D(name:String, value:BitmapData):Void + { + var prop:ShaderInput = Reflect.field(data, name); + + if (prop == null) + { + FlxG.log.warn('Shader sampler2D property "$name" not found.'); + return; + } + + prop.input = value; + } + + /** + * Retrieve a bitmap data parameter of the shader. + * + * @param name The name of the parameter to retrieve. + * @return The value of the parameter. + */ + public function getSampler2D(name:String):Null + { + var prop:ShaderInput = Reflect.field(data, name); + + if (prop == null) + { + FlxG.log.warn('Shader sampler2D property "$name" not found.'); + return null; + } + + return prop.input; + } + + // Overrides + @:noCompletion private override function __processGLData(source:String, storageType:String):Void + { + var lastMatch = 0, position, regex, name, type; + + if (storageType == "uniform") + { + regex = ~/uniform ([A-Za-z0-9]+) ([A-Za-z0-9_]+)/; + } + else + { + regex = ~/attribute ([A-Za-z0-9]+) ([A-Za-z0-9_]+)/; + } + + @:privateAccess + while (regex.matchSub(source, lastMatch)) + { + type = regex.matched(1); + name = regex.matched(2); + + if (StringTools.startsWith(name, "gl_")) + continue; + + var isUniform = (storageType == "uniform"); + + if (StringTools.startsWith(type, "sampler")) + { + var input = new ShaderInput(); + input.name = name; + input.__isUniform = isUniform; + __inputBitmapData.push(input); + + switch (name) + { + case "openfl_Texture": + __texture = input; + case "bitmap": + __bitmap = input; + default: + } + + Reflect.setField(__data, name, input); + + try + { + if (__isGenerated) + Reflect.setField(this, name, input); + } + catch (e:Dynamic) {} + } + else if (!Reflect.hasField(__data, name) || Reflect.field(__data, name) == null) + { + var parameterType:ShaderParameterType = switch (type) + { + case "bool": BOOL; + case "double", "float": FLOAT; + case "int", "uint": INT; + case "bvec2": BOOL2; + case "bvec3": BOOL3; + case "bvec4": BOOL4; + case "ivec2", "uvec2": INT2; + case "ivec3", "uvec3": INT3; + case "ivec4", "uvec4": INT4; + case "vec2", "dvec2": FLOAT2; + case "vec3", "dvec3": FLOAT3; + case "vec4", "dvec4": FLOAT4; + case "mat2", "mat2x2": MATRIX2X2; + case "mat2x3": MATRIX2X3; + case "mat2x4": MATRIX2X4; + case "mat3x2": MATRIX3X2; + case "mat3", "mat3x3": MATRIX3X3; + case "mat3x4": MATRIX3X4; + case "mat4x2": MATRIX4X2; + case "mat4x3": MATRIX4X3; + case "mat4", "mat4x4": MATRIX4X4; + default: null; + } + + var length = switch (parameterType) + { + case BOOL2, INT2, FLOAT2: 2; + case BOOL3, INT3, FLOAT3: 3; + case BOOL4, INT4, FLOAT4, MATRIX2X2: 4; + case MATRIX3X3: 9; + case MATRIX4X4: 16; + default: 1; + } + + var arrayLength = switch (parameterType) + { + case MATRIX2X2: 2; + case MATRIX3X3: 3; + case MATRIX4X4: 4; + default: 1; + } + + switch (parameterType) + { + case BOOL, BOOL2, BOOL3, BOOL4: + var parameter = new ShaderParameter(); + parameter.name = name; + parameter.type = parameterType; + parameter.__arrayLength = arrayLength; + parameter.__isBool = true; + parameter.__isUniform = isUniform; + parameter.__length = length; + __paramBool.push(parameter); + + if (name == "openfl_HasColorTransform") + { + __hasColorTransform = parameter; + } + + Reflect.setField(__data, name, parameter); + + try + { + if (__isGenerated) + Reflect.setField(this, name, parameter); + } + catch (e:Dynamic) {} + + case INT, INT2, INT3, INT4: + var parameter = new ShaderParameter(); + parameter.name = name; + parameter.type = parameterType; + parameter.__arrayLength = arrayLength; + parameter.__isInt = true; + parameter.__isUniform = isUniform; + parameter.__length = length; + __paramInt.push(parameter); + + Reflect.setField(__data, name, parameter); + + try + { + if (__isGenerated) + Reflect.setField(this, name, parameter); + } + catch (e:Dynamic) {} + + default: + var parameter = new ShaderParameter(); + parameter.name = name; + parameter.type = parameterType; + parameter.__arrayLength = arrayLength; + #if lime + if (arrayLength > 0) + parameter.__uniformMatrix = new Float32Array(arrayLength * arrayLength); + #end + parameter.__isFloat = true; + parameter.__isUniform = isUniform; + parameter.__length = length; + __paramFloat.push(parameter); + + if (StringTools.startsWith(name, "openfl_")) + { + switch (name) + { + case "openfl_Alpha": __alpha = parameter; + case "openfl_ColorMultiplier": __colorMultiplier = parameter; + case "openfl_ColorOffset": __colorOffset = parameter; + case "openfl_Matrix": __matrix = parameter; + case "openfl_Position": __position = parameter; + case "openfl_TextureCoord": __textureCoord = parameter; + case "openfl_TextureSize": __textureSize = parameter; + default: + } + } + + Reflect.setField(__data, name, parameter); + + try + { + if (__isGenerated) + Reflect.setField(this, name, parameter); + } + catch (e:Dynamic) {} + } + } + + position = regex.matchedPos(); + lastMatch = position.pos + position.len; + } + } + + @:noCompletion private override function set_glFragmentSource(value:String):String + { + if (value != null) + value = value.replace("#pragma header", BASE_FRAGMENT_HEADER).replace("#pragma body", BASE_FRAGMENT_BODY); + + if (value != __glFragmentSource) + __glSourceDirty = true; + + return __glFragmentSource = value; + } + + @:noCompletion private override function set_glVertexSource(value:String):String + { + if (value != null) + value = value.replace("#pragma header", BASE_VERTEX_HEADER).replace("#pragma body", BASE_VERTEX_BODY); + + if (value != __glVertexSource) + __glSourceDirty = true; + + return __glVertexSource = value; + } +} +#end From d2556e9c13392c536aa9eeb88a49cd10c13d6c3d Mon Sep 17 00:00:00 2001 From: Mihai Alexandru <77043862+MAJigsaw77@users.noreply.github.com> Date: Mon, 7 Aug 2023 18:08:09 +0300 Subject: [PATCH 18/69] Switched `flash` imports to `openfl` were is possible. (#400) * Switch `flash` imports to `openfl`. * Some classes that actually require flash --- flixel/addons/api/FlxGameJolt.hx | 14 +++++++------- flixel/addons/display/FlxGridOverlay.hx | 6 +++--- flixel/addons/display/FlxNestedSprite.hx | 2 +- flixel/addons/display/FlxSpriteAniRot.hx | 6 +++--- flixel/addons/display/shapes/FlxShape.hx | 4 ++-- flixel/addons/display/shapes/FlxShapeArrow.hx | 2 +- flixel/addons/display/shapes/FlxShapeBox.hx | 6 +++--- flixel/addons/display/shapes/FlxShapeCircle.hx | 2 +- flixel/addons/display/shapes/FlxShapeCross.hx | 2 +- flixel/addons/display/shapes/FlxShapeDonut.hx | 8 ++++---- .../addons/display/shapes/FlxShapeDoubleCircle.hx | 2 +- flixel/addons/display/shapes/FlxShapeGrid.hx | 2 +- flixel/addons/display/shapes/FlxShapeLightning.hx | 6 +++--- flixel/addons/display/shapes/FlxShapeLine.hx | 2 +- .../addons/display/shapes/FlxShapeSquareDonut.hx | 4 ++-- flixel/addons/editors/tiled/TiledLayer.hx | 2 +- flixel/addons/editors/tiled/TiledTileLayer.hx | 2 +- flixel/addons/editors/tiled/TiledTileSet.hx | 2 +- flixel/addons/effects/FlxClothSprite.hx | 2 +- flixel/addons/effects/FlxSkewedSprite.hx | 2 +- flixel/addons/effects/FlxTrailArea.hx | 12 ++++++------ flixel/addons/nape/FlxNapeSpace.hx | 2 +- flixel/addons/plugin/FlxScrollingText.hx | 6 +++--- flixel/addons/plugin/control/FlxControlHandler.hx | 2 +- flixel/addons/plugin/screengrab/FlxScreenGrab.hx | 14 +++++++------- flixel/addons/text/FlxTextField.hx | 2 +- flixel/addons/text/FlxTypeText.hx | 2 +- flixel/addons/tile/FlxTileSpecial.hx | 6 +++--- flixel/addons/tile/FlxTilemapExt.hx | 2 +- flixel/addons/transition/TransitionFade.hx | 2 +- flixel/addons/transition/TransitionTiles.hx | 2 +- flixel/addons/ui/FlxButtonPlus.hx | 6 +++--- flixel/addons/ui/FlxClickArea.hx | 8 ++++---- flixel/addons/util/PNGEncoder.hx | 6 +++--- 34 files changed, 75 insertions(+), 75 deletions(-) diff --git a/flixel/addons/api/FlxGameJolt.hx b/flixel/addons/api/FlxGameJolt.hx index a480353e..7b5cd9cd 100644 --- a/flixel/addons/api/FlxGameJolt.hx +++ b/flixel/addons/api/FlxGameJolt.hx @@ -1,12 +1,12 @@ package flixel.addons.api; -import flash.display.Loader; -import flash.display.BitmapData; -import flash.events.Event; -import flash.events.IOErrorEvent; -import flash.net.URLLoader; -import flash.net.URLRequest; -import flash.net.URLRequestMethod; +import openfl.display.Loader; +import openfl.display.BitmapData; +import openfl.events.Event; +import openfl.events.IOErrorEvent; +import openfl.net.URLLoader; +import openfl.net.URLRequest; +import openfl.net.URLRequestMethod; import haxe.crypto.Md5; import haxe.crypto.Sha1; import flixel.FlxG; diff --git a/flixel/addons/display/FlxGridOverlay.hx b/flixel/addons/display/FlxGridOverlay.hx index 9bb6dffe..949ea9f9 100644 --- a/flixel/addons/display/FlxGridOverlay.hx +++ b/flixel/addons/display/FlxGridOverlay.hx @@ -1,8 +1,8 @@ package flixel.addons.display; -import flash.display.BitmapData; -import flash.geom.Point; -import flash.geom.Rectangle; +import openfl.display.BitmapData; +import openfl.geom.Point; +import openfl.geom.Rectangle; import flixel.FlxG; import flixel.FlxSprite; import flixel.util.FlxColor; diff --git a/flixel/addons/display/FlxNestedSprite.hx b/flixel/addons/display/FlxNestedSprite.hx index fe343738..3aed5722 100644 --- a/flixel/addons/display/FlxNestedSprite.hx +++ b/flixel/addons/display/FlxNestedSprite.hx @@ -1,6 +1,6 @@ package flixel.addons.display; -import flash.geom.ColorTransform; +import openfl.geom.ColorTransform; import flixel.FlxBasic; import flixel.FlxG; import flixel.FlxSprite; diff --git a/flixel/addons/display/FlxSpriteAniRot.hx b/flixel/addons/display/FlxSpriteAniRot.hx index 498b40c7..200dff35 100644 --- a/flixel/addons/display/FlxSpriteAniRot.hx +++ b/flixel/addons/display/FlxSpriteAniRot.hx @@ -1,8 +1,8 @@ package flixel.addons.display; -import flash.display.BitmapData; -import flash.geom.Point; -import flash.geom.Rectangle; +import openfl.display.BitmapData; +import openfl.geom.Point; +import openfl.geom.Rectangle; import flixel.FlxSprite; import flixel.graphics.FlxGraphic; import flixel.graphics.frames.FlxFrame; diff --git a/flixel/addons/display/shapes/FlxShape.hx b/flixel/addons/display/shapes/FlxShape.hx index b2276df3..7f69e273 100644 --- a/flixel/addons/display/shapes/FlxShape.hx +++ b/flixel/addons/display/shapes/FlxShape.hx @@ -1,7 +1,7 @@ package flixel.addons.display.shapes; -import flash.display.BlendMode; -import flash.geom.Matrix; +import openfl.display.BlendMode; +import openfl.geom.Matrix; import flixel.FlxSprite; import flixel.util.FlxColor; import flixel.util.FlxSpriteUtil.DrawStyle; diff --git a/flixel/addons/display/shapes/FlxShapeArrow.hx b/flixel/addons/display/shapes/FlxShapeArrow.hx index c31a2ec5..85913196 100644 --- a/flixel/addons/display/shapes/FlxShapeArrow.hx +++ b/flixel/addons/display/shapes/FlxShapeArrow.hx @@ -1,6 +1,6 @@ package flixel.addons.display.shapes; -import flash.geom.Matrix; +import openfl.geom.Matrix; import flixel.FlxG; import flixel.util.FlxColor; import flixel.util.FlxDestroyUtil; diff --git a/flixel/addons/display/shapes/FlxShapeBox.hx b/flixel/addons/display/shapes/FlxShapeBox.hx index 0ce03638..ea0a27cb 100644 --- a/flixel/addons/display/shapes/FlxShapeBox.hx +++ b/flixel/addons/display/shapes/FlxShapeBox.hx @@ -1,8 +1,8 @@ package flixel.addons.display.shapes; -import flash.display.BitmapData; -import flash.display.Shape; -import flash.geom.Matrix; +import openfl.display.BitmapData; +import openfl.display.Shape; +import openfl.geom.Matrix; import flixel.util.FlxColor; import flixel.util.FlxSpriteUtil; import flixel.util.FlxSpriteUtil.LineStyle; diff --git a/flixel/addons/display/shapes/FlxShapeCircle.hx b/flixel/addons/display/shapes/FlxShapeCircle.hx index 20d4ddfd..060158ee 100644 --- a/flixel/addons/display/shapes/FlxShapeCircle.hx +++ b/flixel/addons/display/shapes/FlxShapeCircle.hx @@ -1,6 +1,6 @@ package flixel.addons.display.shapes; -import flash.geom.Matrix; +import openfl.geom.Matrix; import flixel.util.FlxColor; import flixel.util.FlxSpriteUtil; diff --git a/flixel/addons/display/shapes/FlxShapeCross.hx b/flixel/addons/display/shapes/FlxShapeCross.hx index 22629b77..b46d8fcf 100644 --- a/flixel/addons/display/shapes/FlxShapeCross.hx +++ b/flixel/addons/display/shapes/FlxShapeCross.hx @@ -1,6 +1,6 @@ package flixel.addons.display.shapes; -import flash.geom.Matrix; +import openfl.geom.Matrix; import flixel.util.FlxColor; import flixel.math.FlxPoint; import flixel.util.FlxSpriteUtil; diff --git a/flixel/addons/display/shapes/FlxShapeDonut.hx b/flixel/addons/display/shapes/FlxShapeDonut.hx index dec63dfc..5647f602 100644 --- a/flixel/addons/display/shapes/FlxShapeDonut.hx +++ b/flixel/addons/display/shapes/FlxShapeDonut.hx @@ -1,9 +1,9 @@ package flixel.addons.display.shapes; -import flash.display.BitmapData; -import flash.display.BlendMode; -import flash.display.Shape; -import flash.geom.Matrix; +import openfl.display.BitmapData; +import openfl.display.BlendMode; +import openfl.display.Shape; +import openfl.geom.Matrix; import flixel.FlxSprite; import flixel.util.FlxColor; import flixel.util.FlxSpriteUtil; diff --git a/flixel/addons/display/shapes/FlxShapeDoubleCircle.hx b/flixel/addons/display/shapes/FlxShapeDoubleCircle.hx index 1e99b2ed..3d9967ad 100644 --- a/flixel/addons/display/shapes/FlxShapeDoubleCircle.hx +++ b/flixel/addons/display/shapes/FlxShapeDoubleCircle.hx @@ -1,6 +1,6 @@ package flixel.addons.display.shapes; -import flash.geom.Matrix; +import openfl.geom.Matrix; import flixel.util.FlxColor; import flixel.util.FlxSpriteUtil; diff --git a/flixel/addons/display/shapes/FlxShapeGrid.hx b/flixel/addons/display/shapes/FlxShapeGrid.hx index 4c98f9eb..1b288937 100644 --- a/flixel/addons/display/shapes/FlxShapeGrid.hx +++ b/flixel/addons/display/shapes/FlxShapeGrid.hx @@ -1,6 +1,6 @@ package flixel.addons.display.shapes; -import flash.geom.Matrix; +import openfl.geom.Matrix; import flixel.util.FlxColor; import flixel.util.FlxSpriteUtil; diff --git a/flixel/addons/display/shapes/FlxShapeLightning.hx b/flixel/addons/display/shapes/FlxShapeLightning.hx index d841c2a3..93748b29 100644 --- a/flixel/addons/display/shapes/FlxShapeLightning.hx +++ b/flixel/addons/display/shapes/FlxShapeLightning.hx @@ -1,8 +1,8 @@ package flixel.addons.display.shapes; -import flash.display.BitmapData; -import flash.filters.GlowFilter; -import flash.geom.Matrix; +import openfl.display.BitmapData; +import openfl.filters.GlowFilter; +import openfl.geom.Matrix; import flixel.FlxG; import flixel.util.FlxColor; import flixel.math.FlxPoint; diff --git a/flixel/addons/display/shapes/FlxShapeLine.hx b/flixel/addons/display/shapes/FlxShapeLine.hx index 762d0fa0..cf0bfb38 100644 --- a/flixel/addons/display/shapes/FlxShapeLine.hx +++ b/flixel/addons/display/shapes/FlxShapeLine.hx @@ -1,6 +1,6 @@ package flixel.addons.display.shapes; -import flash.geom.Matrix; +import openfl.geom.Matrix; import flixel.math.FlxPoint; import flixel.util.FlxColor; import flixel.util.FlxDestroyUtil; diff --git a/flixel/addons/display/shapes/FlxShapeSquareDonut.hx b/flixel/addons/display/shapes/FlxShapeSquareDonut.hx index 6db2cdee..bed4ec6a 100644 --- a/flixel/addons/display/shapes/FlxShapeSquareDonut.hx +++ b/flixel/addons/display/shapes/FlxShapeSquareDonut.hx @@ -1,7 +1,7 @@ package flixel.addons.display.shapes; -import flash.display.BlendMode; -import flash.geom.Matrix; +import openfl.display.BlendMode; +import openfl.geom.Matrix; import flixel.util.FlxColor; import flixel.util.FlxSpriteUtil; diff --git a/flixel/addons/editors/tiled/TiledLayer.hx b/flixel/addons/editors/tiled/TiledLayer.hx index 6fc41945..ca39fe80 100644 --- a/flixel/addons/editors/tiled/TiledLayer.hx +++ b/flixel/addons/editors/tiled/TiledLayer.hx @@ -1,6 +1,6 @@ package flixel.addons.editors.tiled; -import flash.utils.ByteArray; +import openfl.utils.ByteArray; import haxe.xml.Access; /** diff --git a/flixel/addons/editors/tiled/TiledTileLayer.hx b/flixel/addons/editors/tiled/TiledTileLayer.hx index 870012bc..101c0ef1 100644 --- a/flixel/addons/editors/tiled/TiledTileLayer.hx +++ b/flixel/addons/editors/tiled/TiledTileLayer.hx @@ -1,6 +1,6 @@ package flixel.addons.editors.tiled; -import flash.utils.Endian; +import openfl.utils.Endian; import flixel.addons.editors.tiled.TiledLayer.TiledLayerType; import openfl.utils.ByteArray; import haxe.xml.Access; diff --git a/flixel/addons/editors/tiled/TiledTileSet.hx b/flixel/addons/editors/tiled/TiledTileSet.hx index 8ad61c65..18c555d8 100644 --- a/flixel/addons/editors/tiled/TiledTileSet.hx +++ b/flixel/addons/editors/tiled/TiledTileSet.hx @@ -1,6 +1,6 @@ package flixel.addons.editors.tiled; -import flash.geom.Rectangle; +import openfl.geom.Rectangle; import flixel.util.typeLimit.OneOfTwo; import openfl.Assets; import openfl.utils.ByteArray; diff --git a/flixel/addons/effects/FlxClothSprite.hx b/flixel/addons/effects/FlxClothSprite.hx index 6cb07bf8..500d1677 100644 --- a/flixel/addons/effects/FlxClothSprite.hx +++ b/flixel/addons/effects/FlxClothSprite.hx @@ -1,6 +1,6 @@ package flixel.addons.effects; -import flash.geom.Rectangle; +import openfl.geom.Rectangle; import flixel.FlxCamera; import flixel.FlxSprite; import flixel.graphics.FlxGraphic; diff --git a/flixel/addons/effects/FlxSkewedSprite.hx b/flixel/addons/effects/FlxSkewedSprite.hx index 7d7d4d9c..9a7e66b3 100644 --- a/flixel/addons/effects/FlxSkewedSprite.hx +++ b/flixel/addons/effects/FlxSkewedSprite.hx @@ -1,6 +1,6 @@ package flixel.addons.effects; -import flash.geom.Matrix; +import openfl.geom.Matrix; import flixel.FlxCamera; import flixel.FlxG; import flixel.FlxSprite; diff --git a/flixel/addons/effects/FlxTrailArea.hx b/flixel/addons/effects/FlxTrailArea.hx index 74679d5b..244cbd6e 100644 --- a/flixel/addons/effects/FlxTrailArea.hx +++ b/flixel/addons/effects/FlxTrailArea.hx @@ -1,11 +1,11 @@ package flixel.addons.effects; -import flash.display.BitmapData; -import flash.display.BlendMode; -import flash.geom.ColorTransform; -import flash.geom.Matrix; -import flash.geom.Point; -import flash.geom.Rectangle; +import openfl.display.BitmapData; +import openfl.display.BlendMode; +import openfl.geom.ColorTransform; +import openfl.geom.Matrix; +import openfl.geom.Point; +import openfl.geom.Rectangle; import flixel.FlxG; import flixel.FlxSprite; import flixel.group.FlxGroup; diff --git a/flixel/addons/nape/FlxNapeSpace.hx b/flixel/addons/nape/FlxNapeSpace.hx index 66ee3d21..9e6330bf 100644 --- a/flixel/addons/nape/FlxNapeSpace.hx +++ b/flixel/addons/nape/FlxNapeSpace.hx @@ -1,6 +1,6 @@ package flixel.addons.nape; -import flash.display.BitmapData; +import openfl.display.BitmapData; import flixel.FlxBasic; import flixel.FlxG; import flixel.system.ui.FlxSystemButton; diff --git a/flixel/addons/plugin/FlxScrollingText.hx b/flixel/addons/plugin/FlxScrollingText.hx index 068c3c79..a5577cee 100644 --- a/flixel/addons/plugin/FlxScrollingText.hx +++ b/flixel/addons/plugin/FlxScrollingText.hx @@ -1,8 +1,8 @@ package flixel.addons.plugin; -import flash.display.BitmapData; -import flash.geom.Point; -import flash.geom.Rectangle; +import openfl.display.BitmapData; +import openfl.geom.Point; +import openfl.geom.Rectangle; import flixel.FlxBasic; import flixel.text.FlxBitmapText; import flixel.util.FlxColor; diff --git a/flixel/addons/plugin/control/FlxControlHandler.hx b/flixel/addons/plugin/control/FlxControlHandler.hx index a932c4f6..8cdb4c42 100644 --- a/flixel/addons/plugin/control/FlxControlHandler.hx +++ b/flixel/addons/plugin/control/FlxControlHandler.hx @@ -1,7 +1,7 @@ package flixel.addons.plugin.control; #if FLX_KEYBOARD -import flash.geom.Rectangle; +import openfl.geom.Rectangle; import flixel.FlxG; import flixel.FlxSprite; import flixel.math.FlxMath; diff --git a/flixel/addons/plugin/screengrab/FlxScreenGrab.hx b/flixel/addons/plugin/screengrab/FlxScreenGrab.hx index 30237337..663d9098 100644 --- a/flixel/addons/plugin/screengrab/FlxScreenGrab.hx +++ b/flixel/addons/plugin/screengrab/FlxScreenGrab.hx @@ -1,11 +1,11 @@ package flixel.addons.plugin.screengrab; #if !js -import flash.display.Bitmap; -import flash.display.BitmapData; -import flash.geom.Matrix; -import flash.geom.Rectangle; -import flash.utils.ByteArray; +import openfl.display.Bitmap; +import openfl.display.BitmapData; +import openfl.geom.Matrix; +import openfl.geom.Rectangle; +import openfl.utils.ByteArray; import flixel.addons.util.PNGEncoder; import flixel.FlxG; import flixel.input.keyboard.FlxKey; @@ -16,7 +16,7 @@ import lime.ui.FileDialogType; import openfl.display.PNGEncoderOptions; #end #else -import flash.net.FileReference; +import openfl.net.FileReference; #end /** @@ -178,7 +178,7 @@ class FlxScreenGrab extends FlxBasic #elseif (!lime_legacy || lime < "2.9.0") var documentsDirectory = ""; #if lime_legacy - documentsDirectory = flash.filesystem.File.documentsDirectory.nativePath; + documentsDirectory = openfl.filesystem.File.documentsDirectory.nativePath; #else documentsDirectory = lime.system.System.documentsDirectory; #end diff --git a/flixel/addons/text/FlxTextField.hx b/flixel/addons/text/FlxTextField.hx index 3fde9433..e4ff0e37 100644 --- a/flixel/addons/text/FlxTextField.hx +++ b/flixel/addons/text/FlxTextField.hx @@ -1,6 +1,6 @@ package flixel.addons.text; -import flash.display.BitmapData; +import openfl.display.BitmapData; import flixel.FlxBasic; import flixel.FlxCamera; import flixel.FlxG; diff --git a/flixel/addons/text/FlxTypeText.hx b/flixel/addons/text/FlxTypeText.hx index 97bb4389..240a82b8 100644 --- a/flixel/addons/text/FlxTypeText.hx +++ b/flixel/addons/text/FlxTypeText.hx @@ -7,7 +7,7 @@ import flixel.system.FlxAssets; import flixel.text.FlxText; import flixel.sound.FlxSound; import flixel.math.FlxRandom; -import flash.media.Sound; +import openfl.media.Sound; #if !flash @:sound("assets/sounds/type.ogg") diff --git a/flixel/addons/tile/FlxTileSpecial.hx b/flixel/addons/tile/FlxTileSpecial.hx index a64925e3..aa241dbd 100644 --- a/flixel/addons/tile/FlxTileSpecial.hx +++ b/flixel/addons/tile/FlxTileSpecial.hx @@ -1,8 +1,8 @@ package flixel.addons.tile; -import flash.display.BitmapData; -import flash.geom.Point; -import flash.geom.Rectangle; +import openfl.display.BitmapData; +import openfl.geom.Point; +import openfl.geom.Rectangle; import flixel.animation.FlxAnimation; import flixel.FlxBasic; import flixel.FlxG; diff --git a/flixel/addons/tile/FlxTilemapExt.hx b/flixel/addons/tile/FlxTilemapExt.hx index fb7e9b8d..7973569b 100644 --- a/flixel/addons/tile/FlxTilemapExt.hx +++ b/flixel/addons/tile/FlxTilemapExt.hx @@ -1,6 +1,6 @@ package flixel.addons.tile; -import flash.display.BitmapData; +import openfl.display.BitmapData; import flixel.FlxCamera; import flixel.FlxG; import flixel.FlxObject; diff --git a/flixel/addons/transition/TransitionFade.hx b/flixel/addons/transition/TransitionFade.hx index 37e7b923..1bc57086 100644 --- a/flixel/addons/transition/TransitionFade.hx +++ b/flixel/addons/transition/TransitionFade.hx @@ -1,6 +1,6 @@ package flixel.addons.transition; -import flash.display.BitmapData; +import openfl.display.BitmapData; import flixel.addons.transition.TransitionEffect; import flixel.addons.transition.FlxTransitionSprite.TransitionStatus; import flixel.FlxSprite; diff --git a/flixel/addons/transition/TransitionTiles.hx b/flixel/addons/transition/TransitionTiles.hx index 112835b7..30097007 100644 --- a/flixel/addons/transition/TransitionTiles.hx +++ b/flixel/addons/transition/TransitionTiles.hx @@ -1,6 +1,6 @@ package flixel.addons.transition; -import flash.display.BitmapData; +import openfl.display.BitmapData; import flixel.addons.transition.TransitionEffect; import flixel.addons.transition.FlxTransitionSprite.TransitionStatus; import flixel.group.FlxGroup.FlxTypedGroup; diff --git a/flixel/addons/ui/FlxButtonPlus.hx b/flixel/addons/ui/FlxButtonPlus.hx index 8badd200..2a7816bf 100644 --- a/flixel/addons/ui/FlxButtonPlus.hx +++ b/flixel/addons/ui/FlxButtonPlus.hx @@ -1,9 +1,9 @@ package flixel.addons.ui; #if FLX_MOUSE -import flash.events.MouseEvent; -import flash.geom.Rectangle; -import flash.Lib; +import openfl.events.MouseEvent; +import openfl.geom.Rectangle; +import openfl.Lib; import flixel.addons.display.FlxExtendedSprite; import flixel.FlxCamera; import flixel.FlxG; diff --git a/flixel/addons/ui/FlxClickArea.hx b/flixel/addons/ui/FlxClickArea.hx index d619d8b8..8658b4a3 100644 --- a/flixel/addons/ui/FlxClickArea.hx +++ b/flixel/addons/ui/FlxClickArea.hx @@ -1,9 +1,9 @@ package flixel.addons.ui; -import flash.events.Event; -import flash.events.MouseEvent; -import flash.events.TouchEvent; -import flash.Lib; +import openfl.events.Event; +import openfl.events.MouseEvent; +import openfl.events.TouchEvent; +import openfl.Lib; import flixel.FlxG; import flixel.FlxObject; import flixel.ui.FlxButton; diff --git a/flixel/addons/util/PNGEncoder.hx b/flixel/addons/util/PNGEncoder.hx index 707a7114..d9fd99ed 100644 --- a/flixel/addons/util/PNGEncoder.hx +++ b/flixel/addons/util/PNGEncoder.hx @@ -33,9 +33,9 @@ package flixel.addons.util; #if !js -import flash.display.Bitmap; -import flash.display.BitmapData; -import flash.utils.ByteArray; +import openfl.display.Bitmap; +import openfl.display.BitmapData; +import openfl.utils.ByteArray; /** * Class that converts BitmapData into a valid PNG From cabd58f79e9b37a072eba8fe306fac8b26c753c6 Mon Sep 17 00:00:00 2001 From: George Kurelic Date: Tue, 15 Aug 2023 11:25:42 -0700 Subject: [PATCH 19/69] add removeNow arg on remove and replace (#401) * add removeNow arg on remove and replace * fix warning --- flixel/addons/util/FlxFSM.hx | 161 +++++++++++++++-------------------- 1 file changed, 68 insertions(+), 93 deletions(-) diff --git a/flixel/addons/util/FlxFSM.hx b/flixel/addons/util/FlxFSM.hx index b5cc74ee..377ede6c 100644 --- a/flixel/addons/util/FlxFSM.hx +++ b/flixel/addons/util/FlxFSM.hx @@ -462,10 +462,11 @@ class FlxFSMTransitionTable if (_garbagecollect) { _garbagecollect = false; - var removeThese = []; - for (transition in _table) + var i = _table.length; + while (i-- > 0) { - if (transition.remove == true) + final transition = _table[i]; + if (transition.remove) { if (transition.from == currentState) { @@ -473,21 +474,17 @@ class FlxFSMTransitionTable } else { - removeThese.push(transition); + _table.remove(transition); } } } - for (transition in removeThese) - { - _table.remove(transition); - } } for (transition in _table) { if (transition.from == currentState || transition.from == null) { - if (transition.evaluate(owner) == true) + if (transition.evaluate(owner)) { return transition.to; } @@ -557,16 +554,19 @@ class FlxFSMTransitionTable /** * Replaces given state class with another. - * @param target State class to replace - * @param replacement State class to replace with + * @param target State class to replace + * @param replacement State class to replace with + * @param removeNow If true, the transition is removed immediately, otherwise it's + * removed when the target is not in the specified `from` state */ - public function replace(target:Class>, replacement:Class>) + public function replace(target:Class>, replacement:Class>, removeNow = false) { - for (transition in _table) + var i = _table.length; + while (i-- > 0) { + final transition = _table[i]; if (transition.to == target) { - transition.remove = true; if (transition.from == null) { addGlobal(replacement, transition.condition); @@ -575,64 +575,56 @@ class FlxFSMTransitionTable { add(transition.from, replacement, transition.condition); } - _garbagecollect = true; + + removeTransition(transition, removeNow); } - if (transition.from == target) + else if (transition.from == target) { - transition.remove = true; add(replacement, transition.to, transition.condition); - _garbagecollect = true; + removeTransition(transition, removeNow); } } } /** * Removes a transition condition from the table - * @param from From State - * @param to To State - * @param condition Condition function - * @return True when removed, false if not in table + * @param from From state. If null, this arg is ignored + * @param to To state. If null, this arg is ignored + * @param condition Condition function. If null, this arg is ignored + * @param removeNow If true, the transition is removed immediately, otherwise it's + * removed when the target is not in the specified `from` state */ - public function remove(?from:Class>, ?to:Class>, ?condition:NullBool>) + public function remove(?from:Class>, ?to:Class>, ?condition:(T)->Bool, removeNow = false) { - switch ([from, to, condition]) + if (from == null && to == null && condition == null) { - case [f, null, null]: - for (transition in _table) - { - if (from == transition.from) - { - transition.remove = true; - _garbagecollect = true; - } - } - case [f, t, null]: - for (transition in _table) - { - if (from == transition.from && to == transition.to) - { - transition.remove = true; - _garbagecollect = true; - } - } - case [null, t, c]: - for (transition in _table) - { - if (to == transition.to && condition == transition.condition) - { - transition.remove = true; - _garbagecollect = true; - } - } - case [f, t, c]: - for (transition in _table) - { - if (from == transition.from && to == transition.to && condition == transition.condition) - { - transition.remove = true; - _garbagecollect = true; - } - } + FlxG.log.error('Cannot call remove with all null parameters'); + return; + } + + var i = _table.length; + while (i-- > 0) + { + final transition = _table[i]; + if ((from == null || from == transition.from) + && (to == null || to == transition.to) + && (condition == null || condition == transition.condition)) + { + removeTransition(transition, removeNow); + } + } + } + + function removeTransition(transition:Transition, removeNow:Bool) + { + if (removeNow) + { + _table.remove(transition); + } + else + { + transition.remove = true; + _garbagecollect = true; } } @@ -645,41 +637,24 @@ class FlxFSMTransitionTable */ public function hasTransition(?from:Class>, ?to:Class>, ?condition:NullBool>):Bool { - switch ([from, to, condition]) + if (from == null && to == null && condition == null) { - case [f, null, null]: - for (transition in _table) - { - if (from == transition.from && transition.remove == false) - { - return true; - } - } - case [f, t, null]: - for (transition in _table) - { - if (from == transition.from && to == transition.to && transition.remove == false) - { - return true; - } - } - case [null, t, c]: - for (transition in _table) - { - if (to == transition.to && condition == transition.condition && transition.remove == false) - { - return true; - } - } - case [f, t, c]: - for (transition in _table) - { - if (from == transition.from && to == transition.to && condition == transition.condition && transition.remove == false) - { - return true; - } - } + FlxG.log.error('Cannot call hasTransition with all null parameters'); + return false; + } + + var i = _table.length; + while (i-- > 0) + { + final transition = _table[i]; + if ((from == null || from == transition.from) + && (to == null || to == transition.to) + && (condition == null || condition == transition.condition)) + { + return true; + } } + return false; } } From 071f25823e62de6e747e173a7c4fec60a44de8ae Mon Sep 17 00:00:00 2001 From: George Kurelic Date: Tue, 15 Aug 2023 13:32:18 -0500 Subject: [PATCH 20/69] add #399 #400 and #401 to changelog --- CHANGELOG.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a5c78c6..51368eaf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ -3.1.2 (TBD) +3.2.0 (TBD) ------------------------------ +#### New Features: +- `FlxRuntimeShaders`: Generate shaders from glsl provided at runtime ([#399](https://github.com/HaxeFlixel/flixel-addons/pull/399)) + #### Changes and improvements: - `FlxSkewedSprite`: Allow shaders ([#390](https://github.com/HaxeFlixel/flixel-addons/pull/390)) - `FlxBackdrop`: Use pooled `FlxPoint` for `spacing` ([#394](https://github.com/HaxeFlixel/flixel-addons/pull/394)) @@ -17,6 +20,8 @@ - `GraphicDiagonalGradient` - prevent double update on transitions - optimize wipe transitions, especially diagonal wipe + - Replace `flash` imports with `openfl` equivalents, where possible ([#400](https://github.com/HaxeFlixel/flixel-addons/pull/400)) + - `FlxFSMTransitionTable`: Add `removeNow` arg to `remove` and `replace` ([#401](https://github.com/HaxeFlixel/flixel-addons/pull/401)) 3.1.1 (May 19, 2023) ------------------------------ From 1f7ecf7714d09e9e6a060c293d931c09535ec7cc Mon Sep 17 00:00:00 2001 From: George FunBook Date: Tue, 15 Aug 2023 14:09:59 -0500 Subject: [PATCH 21/69] release 3.2.0 --- CHANGELOG.md | 2 +- haxelib.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 51368eaf..028205cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ 3.2.0 (TBD) ------------------------------ #### New Features: -- `FlxRuntimeShaders`: Generate shaders from glsl provided at runtime ([#399](https://github.com/HaxeFlixel/flixel-addons/pull/399)) +- `FlxRuntimeShader`: Generate shaders from glsl provided at runtime ([#399](https://github.com/HaxeFlixel/flixel-addons/pull/399)) #### Changes and improvements: - `FlxSkewedSprite`: Allow shaders ([#390](https://github.com/HaxeFlixel/flixel-addons/pull/390)) diff --git a/haxelib.json b/haxelib.json index 273301ad..40b42951 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.1.2", - "releasenote": "Fix transition sprite graphics on html5", + "version": "3.2.0", + "releasenote": "Add FlxRuntimeShader", "contributors": ["haxeflixel", "Gama11", "GeoKureli"] } From edefd964fe42e495bc2937f34090c5af53903853 Mon Sep 17 00:00:00 2001 From: George FunBook Date: Tue, 15 Aug 2023 14:12:54 -0500 Subject: [PATCH 22/69] release date --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 028205cc..3b664253 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -3.2.0 (TBD) +3.2.0 (August 15, 2023) ------------------------------ #### New Features: - `FlxRuntimeShader`: Generate shaders from glsl provided at runtime ([#399](https://github.com/HaxeFlixel/flixel-addons/pull/399)) From 0986c1e03ed7c9e11cbe341cca91701d7d2dfa65 Mon Sep 17 00:00:00 2001 From: Ne_Eo Date: Tue, 26 Sep 2023 21:11:36 +0200 Subject: [PATCH 23/69] Fix types on backdrop (#408) * Fix types on backdrop * Update flixel/addons/display/FlxBackdrop.hx --------- Co-authored-by: George Kurelic --- flixel/addons/display/FlxBackdrop.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flixel/addons/display/FlxBackdrop.hx b/flixel/addons/display/FlxBackdrop.hx index 9dc2b13f..4927e3bd 100644 --- a/flixel/addons/display/FlxBackdrop.hx +++ b/flixel/addons/display/FlxBackdrop.hx @@ -72,7 +72,7 @@ class FlxBackdrop extends FlxSprite * @param spacingX Amount of spacing between tiles on the X axis * @param spacingY Amount of spacing between tiles on the Y axis */ - public function new(?graphic:FlxGraphicAsset, repeatAxes = XY, spacingX = 0, spacingY = 0) + public function new(?graphic:FlxGraphicAsset, repeatAxes = XY, spacingX = 0.0, spacingY = 0.0) { super(0, 0, graphic); From 5c737533310c41aa8cb035dc1613b1ffed5eb130 Mon Sep 17 00:00:00 2001 From: George Kurelic Date: Tue, 26 Sep 2023 15:55:37 -0500 Subject: [PATCH 24/69] Flx extended sprite (#405) * remove FlxMouseControl references from FlxExtendedSprite * deprecate FlxExtendedSprite for FlxExtendedMouseSprite * remove refs to FlxExtendedSprite * fix CI * make FlxMouseSpring work with any FlxSprite --- .../addons/display/FlxExtendedMouseSprite.hx | 868 +++++++++++++++++ flixel/addons/display/FlxExtendedSprite.hx | 908 +----------------- flixel/addons/display/FlxMouseSpring.hx | 130 ++- flixel/addons/plugin/FlxMouseControl.hx | 26 +- flixel/addons/ui/FlxButtonPlus.hx | 14 +- 5 files changed, 970 insertions(+), 976 deletions(-) create mode 100644 flixel/addons/display/FlxExtendedMouseSprite.hx diff --git a/flixel/addons/display/FlxExtendedMouseSprite.hx b/flixel/addons/display/FlxExtendedMouseSprite.hx new file mode 100644 index 00000000..b501ff05 --- /dev/null +++ b/flixel/addons/display/FlxExtendedMouseSprite.hx @@ -0,0 +1,868 @@ +package flixel.addons.display; + +import flixel.FlxG; +import flixel.FlxSprite; +import flixel.input.mouse.FlxMouseEvent; +import flixel.math.FlxMath; +import flixel.math.FlxPoint; +import flixel.math.FlxRect; +import flixel.system.FlxAssets; +import flixel.util.FlxCollision; +import flixel.util.FlxDirectionFlags; + +/** + * An enhanced FlxSprite that is capable of receiving mouse clicks, being dragged and thrown, mouse springs, gravity and other useful things + * + * **Note:** This class will be deprecated soon, It's quite outdated and unmaintained. + * + * @author Richard Davey / Photon Storm + */ +class FlxExtendedMouseSprite extends FlxSprite +{ + /** + * Used by FlxMouseControl when multiple sprites overlap and register clicks, and you need to determine which sprite has priority + */ + @:deprecated("priorityID is deprecated, click priority is now determined by z-order") + public var priorityID:Int; + + /** + * If the mouse currently pressed down on this sprite? + */ + public var isPressed:Bool = false; + + /** + * Is this sprite allowed to be clicked? + */ + public var clickable:Bool = false; + + /** + * Is this sprite allowed to be thrown? + */ + public var throwable:Bool = false; + + /** + * An FlxRect region of the game world within which the sprite is restricted during mouse drag + */ + public var boundsRect:FlxRect; + + /** + * An FlxSprite the bounds of which this sprite is restricted during mouse drag + */ + public var boundsSprite:FlxSprite; + + /** + * Does this sprite have gravity applied to it? + */ + public var hasGravity:Bool = false; + + /** + * The x axis gravity influence + */ + public var gravityX:Int; + + /** + * The y axis gravity influence + */ + public var gravityY:Int; + + /** + * Determines how quickly the Sprite come to rest on the walls if the sprite has x gravity enabled + */ + public var frictionX:Float; + + /** + * Determines how quickly the Sprite come to rest on the ground if the sprite has y gravity enabled + */ + public var frictionY:Float; + + /** + * If the velocity.x of this sprite falls between zero and this amount, then the sprite will come to a halt (have velocity.x set to zero) + */ + public var toleranceX:Float; + + /** + * If the velocity.y of this sprite falls between zero and this amount, then the sprite will come to a halt (have velocity.y set to zero) + */ + public var toleranceY:Float; + + /** + * Is this sprite being dragged by the mouse or not? + */ + public var isDragged:Bool = false; + + /** + * Is this sprite allowed to be dragged by the mouse? true = yes, false = no + */ + public var draggable:Bool = false; + + /** + * Will the Mouse Spring be active always (false) or only when pressed (true) + */ + public var springOnPressed:Bool = true; + + /** + * By default the spring attaches to the top left of the sprite. To change this location provide an x offset (in pixels) + */ + public var springOffsetX:Int = 0; + + /** + * By default the spring attaches to the top left of the sprite. To change this location provide a y offset (in pixels) + */ + public var springOffsetY:Int = 0; + + #if FLX_MOUSE + /** + * Function called when the mouse is pressed down on this sprite. Function is passed these parameters: obj:FlxExtendedSprite, x:int, y:int + */ + public var mousePressedCallback:MouseCallback; + + /** + * Function called when the mouse is released from this sprite. Function is passed these parameters: obj:FlxExtendedSprite, x:int, y:int + */ + public var mouseReleasedCallback:MouseCallback; + + /** + * The MouseSpring object which is used to tie this sprite to the mouse + */ + public var mouseSpring:FlxMouseSpring; + + /** + * Function called when the mouse starts to drag this sprite. Function is passed these parameters: obj:FlxExtendedSprite, x:int, y:int + */ + public var mouseStartDragCallback:MouseCallback; + + /** + * Function called when the mouse stops dragging this sprite. Function is passed these parameters: obj:FlxExtendedSprite, x:int, y:int + */ + public var mouseStopDragCallback:MouseCallback; + + /** + * Is this sprite using a mouse spring? + */ + public var hasMouseSpring:Bool = false; + #end + + /** + * The number of clicks this item has received. Usually you'd only set it to zero. + */ + public var clicks(get, set):Int; + + /** + * The spring x coordinate in game world space. Consists of sprite.x + springOffsetX + */ + public var springX(get, never):Int; + + /** + * The spring y coordinate in game world space. Consists of sprite.y + springOffsetY + */ + public var springY(get, never):Int; + + /** + * A FlxPoint consisting of this sprites world x/y coordinates + */ + public var point(get, set):FlxPoint; + + /** + * Returns a FlxRect consisting of the bounds of this Sprite. + */ + public var rect(get, never):FlxRect; + + #if FLX_MOUSE + /** + * Return true if the mouse is over this Sprite, otherwise false. Only takes the Sprites bounding box into consideration and does not check if there + * are other sprites potentially on-top of this one. Check the value of this.isPressed if you need to know if the mouse is currently clicked on this sprite. + */ + public var mouseOver(get, never):Bool; + + /** + * Returns how many horizontal pixels the mouse pointer is inside this sprite from the top left corner. Returns -1 if outside. + */ + public var mouseX(get, never):Int; + + /** + * Returns how many vertical pixels the mouse pointer is inside this sprite from the top left corner. Returns -1 if outside. + */ + public var mouseY(get, never):Int; + #end + + var _snapOnDrag:Bool = false; + var _snapOnRelease:Bool = false; + var _snapX:Int; + var _snapY:Int; + + var _clickOnRelease:Bool = false; + var _clickPixelPerfect:Bool = false; + var _clickPixelPerfectAlpha:Int; + var _clickCounter:Int = 0; + + var _throwXFactor:Int; + var _throwYFactor:Int; + + var _dragPixelPerfect:Bool = false; + var _dragPixelPerfectAlpha:Int; + var _dragOffsetX:Int; + var _dragOffsetY:Int; + var _dragFromPoint:Bool; + var _allowHorizontalDrag:Bool = true; + var _allowVerticalDrag:Bool = true; + + /** + * Creates a white 8x8 square FlxExtendedSprite at the specified position. + * Optionally can load a simple, one-frame graphic instead. + * + * @param X The initial X position of the sprite. + * @param Y The initial Y position of the sprite. + * @param SimpleGraphic The graphic you want to display (OPTIONAL - for simple stuff only, do NOT use for animated images!). + */ + public function new(X:Float = 0, Y:Float = 0, ?SimpleGraphic:FlxGraphicAsset) + { + super(X, Y, SimpleGraphic); + #if FLX_MOUSE + FlxMouseEvent.add(this, (_)->mousePressedHandler(), null, null, null, false, true, false); + #end + } + + #if FLX_MOUSE + /** + * Allow this Sprite to receive mouse clicks, the total number of times this sprite is clicked is stored in this.clicks + * You can add callbacks via mousePressedCallback and mouseReleasedCallback + * + * @param OnRelease Register the click when the mouse is pressed down (false) or when it's released (true). Note that callbacks still fire regardless of this setting. + * @param PixelPerfect If true it will use a pixel perfect test to see if you clicked the Sprite. False uses the bounding box. + * @param AlphaThreshold If using pixel perfect collision this specifies the alpha level from 0 to 255 above which a collision is processed (default 255) + */ + public function enableMouseClicks(OnRelease:Bool, PixelPerfect:Bool = false, AlphaThreshold:Int = 255):Void + { + clickable = true; + + _clickOnRelease = OnRelease; + _clickPixelPerfect = PixelPerfect; + _clickPixelPerfectAlpha = AlphaThreshold; + _clickCounter = 0; + + } + + /** + * Stops this sprite from checking for mouse clicks and clears any set callbacks + */ + public inline function disableMouseClicks():Void + { + clickable = false; + mousePressedCallback = null; + mouseReleasedCallback = null; + } + + /** + * Make this Sprite draggable by the mouse. You can also optionally set mouseStartDragCallback and mouseStopDragCallback + * + * @param LockCenter If false the Sprite will drag from where you click it. If true it will center itself to the tip of the mouse pointer. + * @param PixelPerfect If true it will use a pixel perfect test to see if you clicked the Sprite. False uses the bounding box. + * @param AlphaThreshold If using pixel perfect collision this specifies the alpha level from 0 to 255 above which a collision is processed (default 255) + * @param BoundsRect If you want to restrict the drag of this sprite to a specific FlxRect, pass the FlxRect here, otherwise it's free to drag anywhere + * @param BoundsSprite If you want to restrict the drag of this sprite to within the bounding box of another sprite, pass it here + */ + public function enableMouseDrag(LockCenter:Bool = false, PixelPerfect:Bool = false, AlphaThreshold:Int = 255, ?BoundsRect:FlxRect, + ?BoundsSprite:FlxSprite):Void + { + draggable = true; + + _dragFromPoint = LockCenter; + _dragPixelPerfect = PixelPerfect; + _dragPixelPerfectAlpha = AlphaThreshold; + + if (BoundsRect != null) + { + boundsRect = BoundsRect; + } + + if (BoundsSprite != null) + { + boundsSprite = BoundsSprite; + } + } + + /** + * Stops this sprite from being able to be dragged. If it is currently the target of + * an active drag it will be stopped immediately. Also disables any set callbacks. + */ + public function disableMouseDrag():Void + { + if (isDragged) + stopDrag(); + + isDragged = false; + draggable = false; + + mouseStartDragCallback = null; + mouseStopDragCallback = null; + } + + /** + * Make this Sprite throwable by the mouse. The sprite is thrown only when the mouse button is released. + * + * @param FactorX The sprites velocity is set to FlxMouseControl.speedX * xFactor. Try a value around 50+ + * @param FactorY The sprites velocity is set to FlxMouseControl.speedY * yFactor. Try a value around 50+ + */ + public function enableMouseThrow(FactorX:Int, FactorY:Int):Void + { + throwable = true; + _throwXFactor = FactorX; + _throwYFactor = FactorY; + } + + /** + * Stops this sprite from being able to be thrown. If it currently has velocity this is NOT removed from it. + */ + public function disableMouseThrow():Void + { + throwable = false; + } + + /** + * Make this Sprite snap to the given grid either during drag or when it's released. + * For example 16x16 as the snapX and snapY would make the sprite snap to every 16 pixels. + * + * @param SnapX The width of the grid cell in pixels + * @param SnapY The height of the grid cell in pixels + * @param OnDrag If true the sprite will snap to the grid while being dragged + * @param OnRelease If true the sprite will snap to the grid when released + */ + public function enableMouseSnap(SnapX:Int, SnapY:Int, OnDrag:Bool = true, OnRelease:Bool = false):Void + { + _snapOnDrag = OnDrag; + _snapOnRelease = OnRelease; + _snapX = SnapX; + _snapY = SnapY; + } + + /** + * Stops the sprite from snapping to a grid during drag or release. + */ + public function disableMouseSnap():Void + { + _snapOnDrag = false; + _snapOnRelease = false; + } + + /** + * Adds a simple spring between the mouse and this Sprite. The spring can be activated either when the mouse is pressed (default), or enabled all the time. + * Note that nearly always the Spring will over-ride any other motion setting the sprite has (like velocity or gravity) + * + * @param onPressed True if the spring should only be active when the mouse is pressed down on this sprite + * @param retainVelocity True to retain the velocity of the spring when the mouse is released, or false to clear it + * @param tension The tension of the spring, smaller numbers create springs closer to the mouse pointer + * @param friction The friction applied to the spring as it moves + * @param gravity The gravity controls how far "down" the spring hangs (use a negative value for it to hang up!) + * @return The FlxMouseSpring object if you wish to perform further chaining on it. Also available via FlxExtendedSprite.mouseSpring + */ + public function enableMouseSpring(onPressed = true, retainVelocity = false, tension = 0.1, friction = 0.95, + gravity = 0.0, ?offset:FlxPoint):FlxMouseSpring + { + hasMouseSpring = true; + springOnPressed = onPressed; + + if (mouseSpring == null) + { + mouseSpring = new FlxMouseSpring(this, retainVelocity, tension, friction, gravity, offset); + } + else + { + mouseSpring.tension = tension; + mouseSpring.friction = friction; + mouseSpring.gravity = gravity; + mouseSpring.retainVelocity = retainVelocity; + } + + return mouseSpring; + } + + /** + * Stops the sprite to mouse spring from being active + */ + public function disableMouseSpring():Void + { + hasMouseSpring = false; + mouseSpring = null; + } + #end + + /** + * Restricts this sprite to drag movement only on the given axis. Note: If both are set to false the sprite will never move! + * + * @param AllowHorizontalDrag To enable the sprite to be dragged horizontally set to true, otherwise false + * @param AllowVerticalDrag To enable the sprite to be dragged vertically set to true, otherwise false + */ + public function setDragLock(AllowHorizontalDrag:Bool = true, AllowVerticalDrag:Bool = true):Void + { + _allowHorizontalDrag = AllowHorizontalDrag; + _allowVerticalDrag = AllowVerticalDrag; + } + + /** + * Core update loop + */ + override public function update(elapsed:Float):Void + { + #if FLX_MOUSE + if (draggable && isDragged) + { + updateDrag(); + } + + if (hasGravity) + { + updateGravity(); + } + + if (hasMouseSpring) + { + if (springOnPressed == false) + { + mouseSpring.update(elapsed); + } + else + { + if (isPressed) + { + mouseSpring.update(elapsed); + } + else + { + mouseSpring.reset(); + } + } + } + + if (FlxG.mouse.justReleased) + mouseReleasedHandler(); + #end + + super.update(elapsed); + } + + /** + * Called by update, applies friction if the sprite has gravity to stop jittery motion when slowing down + */ + function updateGravity():Void + { + // A sprite can have horizontal and/or vertical gravity in each direction (positiive / negative) + + // First let's check the x movement + if (velocity.x != 0) + { + if (acceleration.x < 0) + { + // Gravity is pulling them left + if ((touching & WALL) != 0) + { + drag.y = frictionY; + + if ((wasTouching & WALL) == 0) + { + if (velocity.x < toleranceX) + { + velocity.x = 0; + } + } + } + else + { + drag.y = 0; + } + } + else if (acceleration.x > 0) + { + // Gravity is pulling them right + if ((touching & WALL) != 0) + { + // Stop them sliding like on ice + drag.y = frictionY; + + if ((wasTouching & WALL) == 0) + { + if (velocity.x > -toleranceX) + { + velocity.x = 0; + } + } + } + else + { + drag.y = 0; + } + } + } + + // Now check the y movement + if (velocity.y != 0) + { + if (acceleration.y < 0) + { + // Gravity is pulling them up (velocity is negative) + if ((touching & CEILING) != 0) + { + drag.x = frictionX; + + if ((wasTouching & CEILING) == 0) + { + if (velocity.y < toleranceY) + { + velocity.y = 0; + } + } + } + else + { + drag.x = 0; + } + } + else if (acceleration.y > 0) + { + // Gravity is pulling them down (velocity is positive) + if ((touching & FLOOR) != 0) + { + // Stop them sliding like on ice + drag.x = frictionX; + + if ((wasTouching & FLOOR) == 0) + { + if (velocity.y > -toleranceY) + { + velocity.y = 0; + } + } + } + else + { + drag.x = 0; + } + } + } + } + + /** + * Updates the Mouse Drag on this Sprite. + */ + function updateDrag():Void + { + // TODO: touch drag + if (_allowHorizontalDrag) + { + #if FLX_MOUSE + x = Math.floor(FlxG.mouse.screenX + scrollFactor.x * (FlxG.mouse.x - FlxG.mouse.screenX)) - _dragOffsetX; + #end + } + + if (_allowVerticalDrag) + { + #if FLX_MOUSE + y = Math.floor(FlxG.mouse.screenY + scrollFactor.y * (FlxG.mouse.y - FlxG.mouse.screenY)) - _dragOffsetY; + #end + } + + if (boundsRect != null) + { + checkBoundsRect(); + } + + if (boundsSprite != null) + { + checkBoundsSprite(); + } + + if (_snapOnDrag) + { + x = (Math.floor(x / _snapX) * _snapX); + y = (Math.floor(y / _snapY) * _snapY); + } + } + + #if FLX_MOUSE + /** + * Called by FlxMouseControl when this sprite is clicked. Should not usually be called directly. + */ + public function mousePressedHandler():Void + { + isPressed = true; + + final mouse = FlxG.mouse.getWorldPosition(); + if (clickable && isOverPixelPerfect(mouse, _clickPixelPerfect, _clickPixelPerfectAlpha)) + { + if (_clickOnRelease == false) + { + _clickCounter++; + } + + if (mousePressedCallback != null) + { + mousePressedCallback(this, mouseX, mouseY); + } + } + + if (draggable && isOverPixelPerfect(mouse, _dragPixelPerfect, _dragPixelPerfectAlpha)) + { + startDrag(); + } + + mouse.put(); + } + + /** + * Called by FlxMouseControl when this sprite is released from a click. Should not usually be called directly. + */ + public function mouseReleasedHandler():Void + { + final wasPressed = isPressed; + isPressed = false; + + if (isDragged) + { + stopDrag(); + } + + if (wasPressed && throwable) + { + velocity.x = FlxG.mouse.deltaX * _throwXFactor; + velocity.y = FlxG.mouse.deltaY * _throwYFactor; + } + + final mouse = FlxG.mouse.getWorldPosition(); + if (wasPressed && clickable && isOverPixelPerfect(mouse, _clickPixelPerfect, _clickPixelPerfectAlpha)) + { + if (_clickOnRelease) + { + _clickCounter++; + } + + if (mouseReleasedCallback != null) + { + mouseReleasedCallback(this, mouseX, mouseY); + } + } + } + + function isOverPixelPerfect(mouse:FlxPoint, pixelPerfect:Bool, alphaThreshold:Int) + { + return pixelPerfect == false || pixelsOverlapPoint(mouse, alphaThreshold); + } + #end + + /** + * Called by FlxMouseControl when Mouse Drag starts on this Sprite. Should not usually be called directly. + */ + public function startDrag():Void + { + isDragged = true; + + #if FLX_MOUSE + if (_dragFromPoint == false) + { + _dragOffsetX = Math.floor(FlxG.mouse.screenX + scrollFactor.x * (FlxG.mouse.x - FlxG.mouse.screenX) - x); + _dragOffsetY = Math.floor(FlxG.mouse.screenY + scrollFactor.y * (FlxG.mouse.y - FlxG.mouse.screenY) - y); + } + else + { + // Move the sprite to the middle of the mouse + _dragOffsetX = Std.int(frameWidth / 2); + _dragOffsetY = Std.int(frameHeight / 2); + } + + if (mouseStartDragCallback != null) + { + mouseStartDragCallback(this, mouseX, mouseY); + } + #end + } + + /** + * Bounds Rect check for the sprite drag + */ + function checkBoundsRect():Void + { + if (x < boundsRect.left) + { + x = boundsRect.x; + } + else if ((x + width) > boundsRect.right) + { + x = boundsRect.right - width; + } + + if (y < boundsRect.top) + { + y = boundsRect.top; + } + else if ((y + height) > boundsRect.bottom) + { + y = boundsRect.bottom - height; + } + } + + /** + * Parent Sprite Bounds check for the sprite drag + */ + function checkBoundsSprite():Void + { + if (x < boundsSprite.x) + { + x = boundsSprite.x; + } + else if ((x + width) > (boundsSprite.x + boundsSprite.width)) + { + x = (boundsSprite.x + boundsSprite.width) - width; + } + + if (y < boundsSprite.y) + { + y = boundsSprite.y; + } + else if ((y + height) > (boundsSprite.y + boundsSprite.height)) + { + y = (boundsSprite.y + boundsSprite.height) - height; + } + } + + /** + * Called by FlxMouseControl when Mouse Drag is stopped on this Sprite. Should not usually be called directly. + */ + public function stopDrag():Void + { + isDragged = false; + + if (_snapOnRelease) + { + x = (Math.floor(x / _snapX) * _snapX); + y = (Math.floor(y / _snapY) * _snapY); + } + + #if FLX_MOUSE + if (mouseStopDragCallback != null) + { + mouseStopDragCallback(this, mouseX, mouseY); + } + #end + } + + /** + * Gravity can be applied to the sprite, pulling it in any direction. Gravity is given in pixels per second and is applied as acceleration. + * If you don't want gravity for a specific direction pass a value of zero. To cancel it entirely pass both values as zero. + * + * @param GravityX A positive value applies gravity dragging the sprite to the right. A negative value drags the sprite to the left. Zero disables horizontal gravity. + * @param GravityY A positive value applies gravity dragging the sprite down. A negative value drags the sprite up. Zero disables vertical gravity. + * @param FrictionX The amount of friction applied to the sprite if it hits a wall. Allows it to come to a stop without constantly jittering. + * @param FrictionY The amount of friction applied to the sprite if it hits the floor/roof. Allows it to come to a stop without constantly jittering. + * @param ToleranceX If the velocity.x of the sprite falls between 0 and +- this value, it is set to stop (velocity.x = 0) + * @param ToleranceY If the velocity.y of the sprite falls between 0 and +- this value, it is set to stop (velocity.y = 0) + */ + public function setGravity(GravityX:Int, GravityY:Int, FrictionX:Float = 500, FrictionY:Float = 500, ToleranceX:Float = 10, ToleranceY:Float = 10):Void + { + hasGravity = true; + + gravityX = GravityX; + gravityY = GravityY; + + frictionX = FrictionX; + frictionY = FrictionY; + + toleranceX = ToleranceX; + toleranceY = ToleranceY; + + if (GravityX == 0 && GravityY == 0) + { + hasGravity = false; + } + + acceleration.x = GravityX; + acceleration.y = GravityY; + } + + /** + * Switches the gravity applied to the sprite. If gravity was +400 Y (pulling them down) this will swap it to -400 Y (pulling them up) + * To reset call flipGravity again + */ + public function flipGravity():Void + { + if (!Math.isNaN(gravityX) && gravityX != 0) + { + gravityX = -gravityX; + acceleration.x = gravityX; + } + + if (!Math.isNaN(gravityY) && gravityY != 0) + { + gravityY = -gravityY; + acceleration.y = gravityY; + } + } + + inline function get_clicks():Int + { + return _clickCounter; + } + + inline function set_clicks(NewValue:Int):Int + { + return _clickCounter = NewValue; + } + + inline function get_springX():Int + { + return Math.floor(x + springOffsetX); + } + + inline function get_springY():Int + { + return Math.floor(y + springOffsetY); + } + + inline function get_point():FlxPoint + { + return _point; + } + + inline function set_point(NewPoint:FlxPoint):FlxPoint + { + return _point = NewPoint; + } + + #if FLX_MOUSE + function get_mouseOver():Bool + { + return FlxMath.pointInCoordinates(Math.floor(FlxG.mouse.screenX + scrollFactor.x * (FlxG.mouse.x - FlxG.mouse.screenX)), + Math.floor(FlxG.mouse.screenY + scrollFactor.y * (FlxG.mouse.y - FlxG.mouse.screenY)), Math.floor(x), Math.floor(y), Math.floor(width), + Math.floor(height)); + } + + function get_mouseX():Int + { + if (mouseOver) + { + return Math.floor(FlxG.mouse.x - x); + } + + return -1; + } + + function get_mouseY():Int + { + if (mouseOver) + { + return Math.floor(FlxG.mouse.y - y); + } + + return -1; + } + #end + + inline function get_rect():FlxRect + { + _rect.x = x; + _rect.y = y; + _rect.width = width; + _rect.height = height; + + return _rect; + } +} + +typedef MouseCallback = (sprite:FlxExtendedMouseSprite, mouseX:Int, mouseY:Int)->Void; diff --git a/flixel/addons/display/FlxExtendedSprite.hx b/flixel/addons/display/FlxExtendedSprite.hx index 3a38b890..fae86b62 100644 --- a/flixel/addons/display/FlxExtendedSprite.hx +++ b/flixel/addons/display/FlxExtendedSprite.hx @@ -1,908 +1,4 @@ package flixel.addons.display; -import flixel.FlxG; -import flixel.FlxSprite; -import flixel.addons.plugin.FlxMouseControl; -import flixel.math.FlxMath; -import flixel.math.FlxPoint; -import flixel.math.FlxRect; -import flixel.system.FlxAssets; -import flixel.util.FlxCollision; -import flixel.util.FlxDirectionFlags; - -/** - * An enhanced FlxSprite that is capable of receiving mouse clicks, being dragged and thrown, mouse springs, gravity and other useful things - * - * @link http://www.photonstorm.com - * @author Richard Davey / Photon Storm - */ -class FlxExtendedSprite extends FlxSprite -{ - /** - * Used by FlxMouseControl when multiple sprites overlap and register clicks, and you need to determine which sprite has priority - */ - public var priorityID:Int; - - /** - * If the mouse currently pressed down on this sprite? - */ - public var isPressed:Bool = false; - - /** - * Is this sprite allowed to be clicked? - */ - public var clickable:Bool = false; - - /** - * Is this sprite allowed to be thrown? - */ - public var throwable:Bool = false; - - /** - * An FlxRect region of the game world within which the sprite is restricted during mouse drag - */ - public var boundsRect:FlxRect; - - /** - * An FlxSprite the bounds of which this sprite is restricted during mouse drag - */ - public var boundsSprite:FlxSprite; - - /** - * Does this sprite have gravity applied to it? - */ - public var hasGravity:Bool = false; - - /** - * The x axis gravity influence - */ - public var gravityX:Int; - - /** - * The y axis gravity influence - */ - public var gravityY:Int; - - /** - * Determines how quickly the Sprite come to rest on the walls if the sprite has x gravity enabled - */ - public var frictionX:Float; - - /** - * Determines how quickly the Sprite come to rest on the ground if the sprite has y gravity enabled - */ - public var frictionY:Float; - - /** - * If the velocity.x of this sprite falls between zero and this amount, then the sprite will come to a halt (have velocity.x set to zero) - */ - public var toleranceX:Float; - - /** - * If the velocity.y of this sprite falls between zero and this amount, then the sprite will come to a halt (have velocity.y set to zero) - */ - public var toleranceY:Float; - - /** - * Is this sprite being dragged by the mouse or not? - */ - public var isDragged:Bool = false; - - /** - * Is this sprite allowed to be dragged by the mouse? true = yes, false = no - */ - public var draggable:Bool = false; - - /** - * Will the Mouse Spring be active always (false) or only when pressed (true) - */ - public var springOnPressed:Bool = true; - - /** - * By default the spring attaches to the top left of the sprite. To change this location provide an x offset (in pixels) - */ - public var springOffsetX:Int; - - /** - * By default the spring attaches to the top left of the sprite. To change this location provide a y offset (in pixels) - */ - public var springOffsetY:Int; - - #if FLX_MOUSE - /** - * Function called when the mouse is pressed down on this sprite. Function is passed these parameters: obj:FlxExtendedSprite, x:int, y:int - */ - public var mousePressedCallback:MouseCallback; - - /** - * Function called when the mouse is released from this sprite. Function is passed these parameters: obj:FlxExtendedSprite, x:int, y:int - */ - public var mouseReleasedCallback:MouseCallback; - - /** - * The MouseSpring object which is used to tie this sprite to the mouse - */ - public var mouseSpring:FlxMouseSpring; - - /** - * Function called when the mouse starts to drag this sprite. Function is passed these parameters: obj:FlxExtendedSprite, x:int, y:int - */ - public var mouseStartDragCallback:MouseCallback; - - /** - * Function called when the mouse stops dragging this sprite. Function is passed these parameters: obj:FlxExtendedSprite, x:int, y:int - */ - public var mouseStopDragCallback:MouseCallback; - - /** - * Is this sprite using a mouse spring? - */ - public var hasMouseSpring:Bool = false; - #end - - /** - * The number of clicks this item has received. Usually you'd only set it to zero. - */ - public var clicks(get, set):Int; - - /** - * The spring x coordinate in game world space. Consists of sprite.x + springOffsetX - */ - public var springX(get, never):Int; - - /** - * The spring y coordinate in game world space. Consists of sprite.y + springOffsetY - */ - public var springY(get, never):Int; - - /** - * A FlxPoint consisting of this sprites world x/y coordinates - */ - public var point(get, set):FlxPoint; - - /** - * Returns a FlxRect consisting of the bounds of this Sprite. - */ - public var rect(get, never):FlxRect; - - #if FLX_MOUSE - /** - * Return true if the mouse is over this Sprite, otherwise false. Only takes the Sprites bounding box into consideration and does not check if there - * are other sprites potentially on-top of this one. Check the value of this.isPressed if you need to know if the mouse is currently clicked on this sprite. - */ - public var mouseOver(get, never):Bool; - - /** - * Returns how many horizontal pixels the mouse pointer is inside this sprite from the top left corner. Returns -1 if outside. - */ - public var mouseX(get, never):Int; - - /** - * Returns how many vertical pixels the mouse pointer is inside this sprite from the top left corner. Returns -1 if outside. - */ - public var mouseY(get, never):Int; - #end - - var _snapOnDrag:Bool = false; - var _snapOnRelease:Bool = false; - var _snapX:Int; - var _snapY:Int; - - var _clickOnRelease:Bool = false; - var _clickPixelPerfect:Bool = false; - var _clickPixelPerfectAlpha:Int; - var _clickCounter:Int = 0; - - var _throwXFactor:Int; - var _throwYFactor:Int; - - var _dragPixelPerfect:Bool = false; - var _dragPixelPerfectAlpha:Int; - var _dragOffsetX:Int; - var _dragOffsetY:Int; - var _dragFromPoint:Bool; - var _allowHorizontalDrag:Bool = true; - var _allowVerticalDrag:Bool = true; - - /** - * Creates a white 8x8 square FlxExtendedSprite at the specified position. - * Optionally can load a simple, one-frame graphic instead. - * - * @param X The initial X position of the sprite. - * @param Y The initial Y position of the sprite. - * @param SimpleGraphic The graphic you want to display (OPTIONAL - for simple stuff only, do NOT use for animated images!). - */ - public function new(X:Float = 0, Y:Float = 0, ?SimpleGraphic:FlxGraphicAsset) - { - super(X, Y, SimpleGraphic); - } - - #if FLX_MOUSE - /** - * Allow this Sprite to receive mouse clicks, the total number of times this sprite is clicked is stored in this.clicks - * You can add callbacks via mousePressedCallback and mouseReleasedCallback - * - * @param OnRelease Register the click when the mouse is pressed down (false) or when it's released (true). Note that callbacks still fire regardless of this setting. - * @param PixelPerfect If true it will use a pixel perfect test to see if you clicked the Sprite. False uses the bounding box. - * @param AlphaThreshold If using pixel perfect collision this specifies the alpha level from 0 to 255 above which a collision is processed (default 255) - */ - public function enableMouseClicks(OnRelease:Bool, PixelPerfect:Bool = false, AlphaThreshold:Int = 255):Void - { - if (FlxG.plugins.get(FlxMouseControl) == null) - { - throw "FlxExtendedSprite.enableMouseClicks called but FlxMouseControl plugin not activated"; - } - - clickable = true; - - _clickOnRelease = OnRelease; - _clickPixelPerfect = PixelPerfect; - _clickPixelPerfectAlpha = AlphaThreshold; - _clickCounter = 0; - } - - /** - * Stops this sprite from checking for mouse clicks and clears any set callbacks - */ - public inline function disableMouseClicks():Void - { - clickable = false; - mousePressedCallback = null; - mouseReleasedCallback = null; - } - - /** - * Make this Sprite draggable by the mouse. You can also optionally set mouseStartDragCallback and mouseStopDragCallback - * - * @param LockCenter If false the Sprite will drag from where you click it. If true it will center itself to the tip of the mouse pointer. - * @param PixelPerfect If true it will use a pixel perfect test to see if you clicked the Sprite. False uses the bounding box. - * @param AlphaThreshold If using pixel perfect collision this specifies the alpha level from 0 to 255 above which a collision is processed (default 255) - * @param BoundsRect If you want to restrict the drag of this sprite to a specific FlxRect, pass the FlxRect here, otherwise it's free to drag anywhere - * @param BoundsSprite If you want to restrict the drag of this sprite to within the bounding box of another sprite, pass it here - */ - public function enableMouseDrag(LockCenter:Bool = false, PixelPerfect:Bool = false, AlphaThreshold:Int = 255, ?BoundsRect:FlxRect, - ?BoundsSprite:FlxSprite):Void - { - if (FlxG.plugins.get(FlxMouseControl) == null) - { - throw "FlxExtendedSprite.enableMouseDrag called but FlxMouseControl plugin not activated"; - } - - draggable = true; - - _dragFromPoint = LockCenter; - _dragPixelPerfect = PixelPerfect; - _dragPixelPerfectAlpha = AlphaThreshold; - - if (BoundsRect != null) - { - boundsRect = BoundsRect; - } - - if (BoundsSprite != null) - { - boundsSprite = BoundsSprite; - } - } - - /** - * Stops this sprite from being able to be dragged. If it is currently the target of - * an active drag it will be stopped immediately. Also disables any set callbacks. - */ - public function disableMouseDrag():Void - { - if (isDragged) - { - FlxMouseControl.dragTarget = null; - FlxMouseControl.isDragging = false; - } - - isDragged = false; - draggable = false; - - mouseStartDragCallback = null; - mouseStopDragCallback = null; - } - - /** - * Make this Sprite throwable by the mouse. The sprite is thrown only when the mouse button is released. - * - * @param FactorX The sprites velocity is set to FlxMouseControl.speedX * xFactor. Try a value around 50+ - * @param FactorY The sprites velocity is set to FlxMouseControl.speedY * yFactor. Try a value around 50+ - */ - public function enableMouseThrow(FactorX:Int, FactorY:Int):Void - { - if (FlxG.plugins.get(FlxMouseControl) == null) - { - throw "FlxExtendedSprite.enableMouseThrow called but FlxMouseControl plugin not activated"; - } - - throwable = true; - _throwXFactor = FactorX; - _throwYFactor = FactorY; - - if (clickable == false && draggable == false) - { - clickable = true; - } - } - - /** - * Stops this sprite from being able to be thrown. If it currently has velocity this is NOT removed from it. - */ - public function disableMouseThrow():Void - { - throwable = false; - } - - /** - * Make this Sprite snap to the given grid either during drag or when it's released. - * For example 16x16 as the snapX and snapY would make the sprite snap to every 16 pixels. - * - * @param SnapX The width of the grid cell in pixels - * @param SnapY The height of the grid cell in pixels - * @param OnDrag If true the sprite will snap to the grid while being dragged - * @param OnRelease If true the sprite will snap to the grid when released - */ - public function enableMouseSnap(SnapX:Int, SnapY:Int, OnDrag:Bool = true, OnRelease:Bool = false):Void - { - _snapOnDrag = OnDrag; - _snapOnRelease = OnRelease; - _snapX = SnapX; - _snapY = SnapY; - } - - /** - * Stops the sprite from snapping to a grid during drag or release. - */ - public function disableMouseSnap():Void - { - _snapOnDrag = false; - _snapOnRelease = false; - } - - /** - * Adds a simple spring between the mouse and this Sprite. The spring can be activated either when the mouse is pressed (default), or enabled all the time. - * Note that nearly always the Spring will over-ride any other motion setting the sprite has (like velocity or gravity) - * - * @param OnPressed True if the spring should only be active when the mouse is pressed down on this sprite - * @param RetainVelocity True to retain the velocity of the spring when the mouse is released, or false to clear it - * @param Tension The tension of the spring, smaller numbers create springs closer to the mouse pointer - * @param Friction The friction applied to the spring as it moves - * @param Gravity The gravity controls how far "down" the spring hangs (use a negative value for it to hang up!) - * @return The FlxMouseSpring object if you wish to perform further chaining on it. Also available via FlxExtendedSprite.mouseSpring - */ - public function enableMouseSpring(OnPressed:Bool = true, RetainVelocity:Bool = false, Tension:Float = 0.1, Friction:Float = 0.95, - Gravity:Float = 0):FlxMouseSpring - { - if (FlxG.plugins.get(FlxMouseControl) == null) - { - throw "FlxExtendedSprite.enableMouseSpring called but FlxMouseControl plugin not activated"; - } - - hasMouseSpring = true; - springOnPressed = OnPressed; - - if (mouseSpring == null) - { - mouseSpring = new FlxMouseSpring(this, RetainVelocity, Tension, Friction, Gravity); - } - else - { - mouseSpring.tension = Tension; - mouseSpring.friction = Friction; - mouseSpring.gravity = Gravity; - } - - if (clickable == false && draggable == false) - { - clickable = true; - } - - return mouseSpring; - } - - /** - * Stops the sprite to mouse spring from being active - */ - public function disableMouseSpring():Void - { - hasMouseSpring = false; - mouseSpring = null; - } - #end - - /** - * Restricts this sprite to drag movement only on the given axis. Note: If both are set to false the sprite will never move! - * - * @param AllowHorizontalDrag To enable the sprite to be dragged horizontally set to true, otherwise false - * @param AllowVerticalDrag To enable the sprite to be dragged vertically set to true, otherwise false - */ - public function setDragLock(AllowHorizontalDrag:Bool = true, AllowVerticalDrag:Bool = true):Void - { - _allowHorizontalDrag = AllowHorizontalDrag; - _allowVerticalDrag = AllowVerticalDrag; - } - - /** - * Core update loop - */ - override public function update(elapsed:Float):Void - { - #if FLX_MOUSE - if (draggable == true && isDragged == true) - { - updateDrag(); - } - - if (isPressed == false && FlxG.mouse.justPressed) - { - checkForClick(); - } - - if (hasGravity == true) - { - updateGravity(); - } - - if (hasMouseSpring == true) - { - if (springOnPressed == false) - { - mouseSpring.update(elapsed); - } - else - { - if (isPressed == true) - { - mouseSpring.update(elapsed); - } - else - { - mouseSpring.reset(); - } - } - } - #end - - super.update(elapsed); - } - - /** - * Called by update, applies friction if the sprite has gravity to stop jittery motion when slowing down - */ - function updateGravity():Void - { - // A sprite can have horizontal and/or vertical gravity in each direction (positiive / negative) - - // First let's check the x movement - if (velocity.x != 0) - { - if (acceleration.x < 0) - { - // Gravity is pulling them left - if ((touching & WALL) != 0) - { - drag.y = frictionY; - - if ((wasTouching & WALL) == 0) - { - if (velocity.x < toleranceX) - { - velocity.x = 0; - } - } - } - else - { - drag.y = 0; - } - } - else if (acceleration.x > 0) - { - // Gravity is pulling them right - if ((touching & WALL) != 0) - { - // Stop them sliding like on ice - drag.y = frictionY; - - if ((wasTouching & WALL) == 0) - { - if (velocity.x > -toleranceX) - { - velocity.x = 0; - } - } - } - else - { - drag.y = 0; - } - } - } - - // Now check the y movement - if (velocity.y != 0) - { - if (acceleration.y < 0) - { - // Gravity is pulling them up (velocity is negative) - if ((touching & CEILING) != 0) - { - drag.x = frictionX; - - if ((wasTouching & CEILING) == 0) - { - if (velocity.y < toleranceY) - { - velocity.y = 0; - } - } - } - else - { - drag.x = 0; - } - } - else if (acceleration.y > 0) - { - // Gravity is pulling them down (velocity is positive) - if ((touching & FLOOR) != 0) - { - // Stop them sliding like on ice - drag.x = frictionX; - - if ((wasTouching & FLOOR) == 0) - { - if (velocity.y > -toleranceY) - { - velocity.y = 0; - } - } - } - else - { - drag.x = 0; - } - } - } - } - - /** - * Updates the Mouse Drag on this Sprite. - */ - function updateDrag():Void - { - // TODO: touch drag - if (_allowHorizontalDrag == true) - { - #if FLX_MOUSE - x = Math.floor(FlxG.mouse.screenX + scrollFactor.x * (FlxG.mouse.x - FlxG.mouse.screenX)) - _dragOffsetX; - #end - } - - if (_allowVerticalDrag == true) - { - #if FLX_MOUSE - y = Math.floor(FlxG.mouse.screenY + scrollFactor.y * (FlxG.mouse.y - FlxG.mouse.screenY)) - _dragOffsetY; - #end - } - - if (boundsRect != null) - { - checkBoundsRect(); - } - - if (boundsSprite != null) - { - checkBoundsSprite(); - } - - if (_snapOnDrag) - { - x = (Math.floor(x / _snapX) * _snapX); - y = (Math.floor(y / _snapY) * _snapY); - } - } - - /** - * Checks if the mouse is over this sprite and pressed, then does a pixel - * perfect check if needed and adds it to the FlxMouseControl check stack. - */ - function checkForClick():Void - { - #if FLX_MOUSE - if (mouseOver && FlxG.mouse.justPressed) - { - // If we don't need a pixel perfect check, then don't bother running one! By this point we know the mouse is over the sprite already - if (_clickPixelPerfect == false && _dragPixelPerfect == false) - { - FlxMouseControl.addToStack(this); - return; - } - - if (_clickPixelPerfect - && FlxCollision.pixelPerfectPointCheck(Math.floor(FlxG.mouse.x), Math.floor(FlxG.mouse.y), this, _clickPixelPerfectAlpha)) - { - FlxMouseControl.addToStack(this); - return; - } - - if (_dragPixelPerfect - && FlxCollision.pixelPerfectPointCheck(Math.floor(FlxG.mouse.x), Math.floor(FlxG.mouse.y), this, _dragPixelPerfectAlpha)) - { - FlxMouseControl.addToStack(this); - return; - } - } - #end - } - - #if FLX_MOUSE - /** - * Called by FlxMouseControl when this sprite is clicked. Should not usually be called directly. - */ - public function mousePressedHandler():Void - { - isPressed = true; - - if (clickable == true && _clickOnRelease == false) - { - _clickCounter++; - } - - if (mousePressedCallback != null) - { - mousePressedCallback(this, mouseX, mouseY); - } - } - - /** - * Called by FlxMouseControl when this sprite is released from a click. Should not usually be called directly. - */ - public function mouseReleasedHandler():Void - { - isPressed = false; - - if (isDragged == true) - { - stopDrag(); - } - - if (clickable == true && _clickOnRelease == true) - { - _clickCounter++; - } - - if (throwable == true) - { - velocity.x = FlxMouseControl.speedX * _throwXFactor; - velocity.y = FlxMouseControl.speedY * _throwYFactor; - } - - if (mouseReleasedCallback != null) - { - mouseReleasedCallback(this, mouseX, mouseY); - } - } - #end - - /** - * Called by FlxMouseControl when Mouse Drag starts on this Sprite. Should not usually be called directly. - */ - public function startDrag():Void - { - isDragged = true; - - #if FLX_MOUSE - if (_dragFromPoint == false) - { - _dragOffsetX = Math.floor(FlxG.mouse.screenX + scrollFactor.x * (FlxG.mouse.x - FlxG.mouse.screenX) - x); - _dragOffsetY = Math.floor(FlxG.mouse.screenY + scrollFactor.y * (FlxG.mouse.y - FlxG.mouse.screenY) - y); - } - else - { - // Move the sprite to the middle of the mouse - _dragOffsetX = Std.int(frameWidth / 2); - _dragOffsetY = Std.int(frameHeight / 2); - } - - if (mouseStartDragCallback != null) - { - mouseStartDragCallback(this, mouseX, mouseY); - } - #end - } - - /** - * Bounds Rect check for the sprite drag - */ - function checkBoundsRect():Void - { - if (x < boundsRect.left) - { - x = boundsRect.x; - } - else if ((x + width) > boundsRect.right) - { - x = boundsRect.right - width; - } - - if (y < boundsRect.top) - { - y = boundsRect.top; - } - else if ((y + height) > boundsRect.bottom) - { - y = boundsRect.bottom - height; - } - } - - /** - * Parent Sprite Bounds check for the sprite drag - */ - function checkBoundsSprite():Void - { - if (x < boundsSprite.x) - { - x = boundsSprite.x; - } - else if ((x + width) > (boundsSprite.x + boundsSprite.width)) - { - x = (boundsSprite.x + boundsSprite.width) - width; - } - - if (y < boundsSprite.y) - { - y = boundsSprite.y; - } - else if ((y + height) > (boundsSprite.y + boundsSprite.height)) - { - y = (boundsSprite.y + boundsSprite.height) - height; - } - } - - /** - * Called by FlxMouseControl when Mouse Drag is stopped on this Sprite. Should not usually be called directly. - */ - public function stopDrag():Void - { - isDragged = false; - - if (_snapOnRelease) - { - x = (Math.floor(x / _snapX) * _snapX); - y = (Math.floor(y / _snapY) * _snapY); - } - - #if FLX_MOUSE - if (mouseStopDragCallback != null) - { - mouseStopDragCallback(this, mouseX, mouseY); - } - #end - } - - /** - * Gravity can be applied to the sprite, pulling it in any direction. Gravity is given in pixels per second and is applied as acceleration. - * If you don't want gravity for a specific direction pass a value of zero. To cancel it entirely pass both values as zero. - * - * @param GravityX A positive value applies gravity dragging the sprite to the right. A negative value drags the sprite to the left. Zero disables horizontal gravity. - * @param GravityY A positive value applies gravity dragging the sprite down. A negative value drags the sprite up. Zero disables vertical gravity. - * @param FrictionX The amount of friction applied to the sprite if it hits a wall. Allows it to come to a stop without constantly jittering. - * @param FrictionY The amount of friction applied to the sprite if it hits the floor/roof. Allows it to come to a stop without constantly jittering. - * @param ToleranceX If the velocity.x of the sprite falls between 0 and +- this value, it is set to stop (velocity.x = 0) - * @param ToleranceY If the velocity.y of the sprite falls between 0 and +- this value, it is set to stop (velocity.y = 0) - */ - public function setGravity(GravityX:Int, GravityY:Int, FrictionX:Float = 500, FrictionY:Float = 500, ToleranceX:Float = 10, ToleranceY:Float = 10):Void - { - hasGravity = true; - - gravityX = GravityX; - gravityY = GravityY; - - frictionX = FrictionX; - frictionY = FrictionY; - - toleranceX = ToleranceX; - toleranceY = ToleranceY; - - if (GravityX == 0 && GravityY == 0) - { - hasGravity = false; - } - - acceleration.x = GravityX; - acceleration.y = GravityY; - } - - /** - * Switches the gravity applied to the sprite. If gravity was +400 Y (pulling them down) this will swap it to -400 Y (pulling them up) - * To reset call flipGravity again - */ - public function flipGravity():Void - { - if (!Math.isNaN(gravityX) && gravityX != 0) - { - gravityX = -gravityX; - acceleration.x = gravityX; - } - - if (!Math.isNaN(gravityY) && gravityY != 0) - { - gravityY = -gravityY; - acceleration.y = gravityY; - } - } - - inline function get_clicks():Int - { - return _clickCounter; - } - - inline function set_clicks(NewValue:Int):Int - { - return _clickCounter = NewValue; - } - - inline function get_springX():Int - { - return Math.floor(x + springOffsetX); - } - - inline function get_springY():Int - { - return Math.floor(y + springOffsetY); - } - - inline function get_point():FlxPoint - { - return _point; - } - - inline function set_point(NewPoint:FlxPoint):FlxPoint - { - return _point = NewPoint; - } - - #if FLX_MOUSE - function get_mouseOver():Bool - { - return FlxMath.pointInCoordinates(Math.floor(FlxG.mouse.screenX + scrollFactor.x * (FlxG.mouse.x - FlxG.mouse.screenX)), - Math.floor(FlxG.mouse.screenY + scrollFactor.y * (FlxG.mouse.y - FlxG.mouse.screenY)), Math.floor(x), Math.floor(y), Math.floor(width), - Math.floor(height)); - } - - function get_mouseX():Int - { - if (mouseOver) - { - return Math.floor(FlxG.mouse.x - x); - } - - return -1; - } - - function get_mouseY():Int - { - if (mouseOver) - { - return Math.floor(FlxG.mouse.y - y); - } - - return -1; - } - #end - - inline function get_rect():FlxRect - { - _rect.x = x; - _rect.y = y; - _rect.width = width; - _rect.height = height; - - return _rect; - } -} - -typedef MouseCallback = FlxExtendedSprite->Int->Int->Void; +@:deprecated('FlxExtendedSprite is deprecated, use FlxExtendedMouseSprite') +typedef FlxExtendedSprite = FlxExtendedMouseSprite; diff --git a/flixel/addons/display/FlxMouseSpring.hx b/flixel/addons/display/FlxMouseSpring.hx index 395992c2..b314e33b 100644 --- a/flixel/addons/display/FlxMouseSpring.hx +++ b/flixel/addons/display/FlxMouseSpring.hx @@ -2,56 +2,85 @@ package flixel.addons.display; #if FLX_MOUSE import flixel.FlxG; +import flixel.FlxSprite; +import flixel.math.FlxPoint; +import flixel.util.FlxDestroyUtil; -class FlxMouseSpring +class FlxMouseSpring implements IFlxDestroyable { - public var sprite:FlxExtendedSprite; + public var sprite:FlxSprite; /** * The tension of the spring, smaller numbers create springs closer to the mouse pointer - * @default 0.1 */ public var tension:Float; /** * The friction applied to the spring as it moves - * @default 0.95 */ public var friction:Float; /** - * The gravity controls how far "down" the spring hangs (use a negative value for it to hang up!) - * @default 0 + * The constant downward force on the sprite (A negative value pulls up!) */ public var gravity:Float; - var _retainVelocity:Bool; - - var _vx:Float = 0; - var _vy:Float = 0; - - var _dx:Float = 0; - var _dy:Float = 0; + /** + * The anchor point of the sprite, relative to its position, If null, the sprite's origin is used + */ + public var offset:FlxPoint; - var _ax:Float = 0; - var _ay:Float = 0; + /** + * Whether to retain the velocity of the spring when the mouse is released. If false, it's cleared on release + */ + public var retainVelocity:Bool; + + @:deprecated("_retainVelocity is deprecated, use retainVelocity instead") + var _retainVelocity(get, set):Bool; + + inline function get__retainVelocity():Bool + { + return retainVelocity; + } + + inline function set__retainVelocity(value:Bool):Bool + { + return retainVelocity = value; + } + + var velocity:FlxPoint = FlxPoint.get(); + var velY:Float; /** - * Adds a spring between the mouse and a FlxExtendedSprite. + * Adds a spring between the mouse and a FlxSprite * - * @param Sprite The FlxExtendedSprite to which this spring is attached - * @param RetainVelocity True to retain the velocity of the spring when the mouse is released, or false to clear it - * @param Tension The tension of the spring, smaller numbers create springs closer to the mouse pointer - * @param Friction The friction applied to the spring as it moves - * @param Gravity The gravity controls how far "down" the spring hangs (use a negative value for it to hang up!) + * @param sprite The FlxSprite to which this spring is attached + * @param retainVelocity True to retain the velocity of the spring when the mouse is released, or false to clear it + * @param tension The tension of the spring, smaller numbers create springs closer to the mouse pointer + * @param friction The friction applied to the spring as it moves + * @param gravity The constant downward force on the sprite (A negative value pulls up!) + * @param offset The anchor point of the sprite, relative to its position, If null, + * the sprite's origin is used. Note: A copy of the passed in point is used. + * */ - public function new(Sprite:FlxExtendedSprite, RetainVelocity:Bool = false, Tension:Float = 0.1, Friction:Float = 0.95, Gravity:Float = 0) + public function new(sprite:FlxSprite, retainVelocity = false, tension = 0.1, friction = 0.95, gravity = 0.0, ?offset:FlxPoint) { - sprite = Sprite; - _retainVelocity = RetainVelocity; - tension = Tension; - friction = Friction; - gravity = Gravity; + this.sprite = sprite; + this.retainVelocity = retainVelocity; + this.tension = tension; + this.friction = friction; + this.gravity = gravity; + + if (offset != null) + { + this.offset = FlxPoint.get().copyFrom(offset); + offset.putWeak(); + } + else if (sprite is FlxExtendedMouseSprite) + { + final extSprite:FlxExtendedMouseSprite = cast sprite; + this.offset = FlxPoint.get(extSprite.springOffsetX, extSprite.springOffsetY); + } } /** @@ -59,21 +88,22 @@ class FlxMouseSpring */ public function update(elapsed:Float):Void { - _dx = FlxG.mouse.x - sprite.springX; - _dy = FlxG.mouse.y - sprite.springY; - - _ax = _dx * tension; - _ay = _dy * tension; - - _vx += _ax; - _vy += _ay; - - _vy += gravity; - _vx *= friction; - _vy *= friction; - - sprite.x += _vx; - sprite.y += _vy; + final offsetX = (offset == null ? offset.x : sprite.origin.x); + final offsetY = (offset == null ? offset.y : sprite.origin.y); + + final disX = FlxG.mouse.x - (sprite.x + offsetX); + final disY = FlxG.mouse.y - (sprite.y + offsetY); + + velocity.x += disX * tension; + velocity.y += disY * tension; + + velocity.x *= friction; + velocity.y += gravity; + velocity.y *= friction; + + // TODO: use sprite.velocity + sprite.x += velocity.x; + sprite.y += velocity.y; } /** @@ -81,14 +111,14 @@ class FlxMouseSpring */ public function reset():Void { - _vx = 0; - _vy = 0; - - _dx = 0; - _dy = 0; - - _ax = 0; - _ay = 0; + velocity.set(0, 0); + } + + public function destroy() + { + sprite = null; + offset = FlxDestroyUtil.put(offset); + velocity = FlxDestroyUtil.put(velocity); } } #end diff --git a/flixel/addons/plugin/FlxMouseControl.hx b/flixel/addons/plugin/FlxMouseControl.hx index 3b3c22d6..b2604f74 100644 --- a/flixel/addons/plugin/FlxMouseControl.hx +++ b/flixel/addons/plugin/FlxMouseControl.hx @@ -1,7 +1,7 @@ package flixel.addons.plugin; #if FLX_MOUSE -import flixel.addons.display.FlxExtendedSprite; +import flixel.addons.display.FlxExtendedMouseSprite; import flixel.FlxBasic; import flixel.FlxG; import flixel.math.FlxMath; @@ -29,7 +29,7 @@ class FlxMouseControl extends FlxBasic public static inline var DESCENDING:Int = 1; /** - * The value that the FlxExtendedSprites are sorted by before deciding which is "on-top" for click select + * The value that the FlxExtendedMouseSprites are sorted by before deciding which is "on-top" for click select */ public static var sortIndex:String = "y"; @@ -44,11 +44,11 @@ class FlxMouseControl extends FlxBasic public static var isDragging:Bool = false; /** - * The FlxExtendedSprite that is currently being dragged, if any. + * The FlxExtendedMouseSprite that is currently being dragged, if any. */ - public static var dragTarget:FlxExtendedSprite; + public static var dragTarget:FlxExtendedMouseSprite; - public static var clickTarget:FlxExtendedSprite; + public static var clickTarget:FlxExtendedMouseSprite; /** * The speed the mouse is moving on the X axis in pixels per frame @@ -76,9 +76,9 @@ class FlxMouseControl extends FlxBasic public static var linkToDeadZone:Bool = false; /** - * The FlxExtendedSprite that currently has the mouse button pressed on it + * The FlxExtendedMouseSprite that currently has the mouse button pressed on it */ - static var _clickStack:Array = new Array(); + static var _clickStack:Array = new Array(); static var _clickCoords:FlxPoint; static var _hasClickTarget:Bool = false; @@ -94,11 +94,11 @@ class FlxMouseControl extends FlxBasic } /** - * Adds the given FlxExtendedSprite to the stack of potential sprites that were clicked, the stack is then sorted and the final sprite is selected from that + * Adds the given FlxExtendedMouseSprite to the stack of potential sprites that were clicked, the stack is then sorted and the final sprite is selected from that * - * @param Item The FlxExtendedSprite that was clicked by the mouse + * @param Item The FlxExtendedMouseSprite that was clicked by the mouse */ - public static function addToStack(Item:FlxExtendedSprite):Void + public static function addToStack(Item:FlxExtendedMouseSprite):Void { if (mouseZone != null) { @@ -143,7 +143,7 @@ class FlxMouseControl extends FlxBasic } /** - * Main Update Loop - checks mouse status and updates FlxExtendedSprites accordingly + * Main Update Loop - checks mouse status and updates FlxExtendedMouseSprites accordingly */ override public function update(elapsed:Float):Void { @@ -192,7 +192,7 @@ class FlxMouseControl extends FlxBasic } else { - // If you are wondering how the brand new array can have anything in it by now, it's because FlxExtendedSprite + // If you are wondering how the brand new array can have anything in it by now, it's because FlxExtendedMouseSprite // adds itself to the clickStack if (FlxG.mouse.pressed && _clickStack.length > 0) { @@ -246,7 +246,7 @@ class FlxMouseControl extends FlxBasic * * @return An integer value: -1 (item1 before item2), 0 (same), or 1 (item1 after item2) */ - function sortHandler(Item1:FlxExtendedSprite, Item2:FlxExtendedSprite):Int + function sortHandler(Item1:FlxExtendedMouseSprite, Item2:FlxExtendedMouseSprite):Int { var prop1 = Reflect.getProperty(Item1, sortIndex); var prop2 = Reflect.getProperty(Item2, sortIndex); diff --git a/flixel/addons/ui/FlxButtonPlus.hx b/flixel/addons/ui/FlxButtonPlus.hx index 2a7816bf..2b13ca15 100644 --- a/flixel/addons/ui/FlxButtonPlus.hx +++ b/flixel/addons/ui/FlxButtonPlus.hx @@ -4,7 +4,7 @@ package flixel.addons.ui; import openfl.events.MouseEvent; import openfl.geom.Rectangle; import openfl.Lib; -import flixel.addons.display.FlxExtendedSprite; +import flixel.addons.display.FlxExtendedMouseSprite; import flixel.FlxCamera; import flixel.FlxG; import flixel.FlxSprite; @@ -60,8 +60,8 @@ class FlxButtonPlus extends FlxSpriteGroup */ public var leaveCallback:Void->Void; - public var buttonNormal(default, set):FlxExtendedSprite; - public var buttonHighlight(default, set):FlxExtendedSprite; + public var buttonNormal(default, set):FlxExtendedMouseSprite; + public var buttonHighlight(default, set):FlxExtendedMouseSprite; public var textNormal(default, set):FlxText; public var textHighlight(default, set):FlxText; @@ -103,7 +103,7 @@ class FlxButtonPlus extends FlxSpriteGroup y = Y; onClickCallback = Callback; - buttonNormal = new FlxExtendedSprite(); + buttonNormal = new FlxExtendedMouseSprite(); #if flash buttonNormal.makeGraphic(Width, Height, borderColor); @@ -116,7 +116,7 @@ class FlxButtonPlus extends FlxSpriteGroup buttonNormal.solid = false; buttonNormal.scrollFactor.set(); - buttonHighlight = new FlxExtendedSprite(); + buttonHighlight = new FlxExtendedMouseSprite(); #if flash buttonHighlight.makeGraphic(Width, Height, borderColor); @@ -382,7 +382,7 @@ class FlxButtonPlus extends FlxSpriteGroup return NewText; } - inline function set_buttonNormal(Value:FlxExtendedSprite):FlxExtendedSprite + inline function set_buttonNormal(Value:FlxExtendedMouseSprite):FlxExtendedMouseSprite { if (Value == null) { @@ -401,7 +401,7 @@ class FlxButtonPlus extends FlxSpriteGroup return buttonNormal = Value; } - inline function set_buttonHighlight(Value:FlxExtendedSprite):FlxExtendedSprite + inline function set_buttonHighlight(Value:FlxExtendedMouseSprite):FlxExtendedMouseSprite { if (Value == null) { From df807d057e15cbe49976ca15122b6c46601b8b07 Mon Sep 17 00:00:00 2001 From: George FunBook Date: Tue, 26 Sep 2023 16:22:14 -0500 Subject: [PATCH 25/69] add #405 and #408 --- CHANGELOG.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b664253..fe72263b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,14 @@ +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)) + 3.2.0 (August 15, 2023) ------------------------------ #### New Features: From b9dedb4b6c7cad023af399f2ba67e16274e0ed7b Mon Sep 17 00:00:00 2001 From: George FunBook Date: Tue, 26 Sep 2023 16:28:35 -0500 Subject: [PATCH 26/69] 3.2.1 release --- haxelib.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/haxelib.json b/haxelib.json index 40b42951..40378a6b 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.0", - "releasenote": "Add FlxRuntimeShader", + "version": "3.2.1", + "releasenote": "Deprecate FlxExtendedSprite", "contributors": ["haxeflixel", "Gama11", "GeoKureli"] } From a9f4f8e89f081153673ecfa11a94436cc121e36e Mon Sep 17 00:00:00 2001 From: George Kurelic Date: Tue, 17 Oct 2023 11:49:23 -0500 Subject: [PATCH 27/69] Pool upkeep (#409) * upkeep for new FlxPool constructor * use version() --- flixel/addons/util/FlxFSM.hx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/flixel/addons/util/FlxFSM.hx b/flixel/addons/util/FlxFSM.hx index 377ede6c..c34d9a0e 100644 --- a/flixel/addons/util/FlxFSM.hx +++ b/flixel/addons/util/FlxFSM.hx @@ -128,7 +128,12 @@ class FlxFSM implements IFlxDestroyable if (newName != null && !pools.exists(newName)) { - pools.set(newName, new FlxPool>(newStateClass)); + #if (flixel < version("5.4.0")) + final newStateConstructor = newStateClass; + #else + final newStateConstructor = ()->Type.createInstance(newStateClass, []); + #end + pools.set(newName, new FlxPool>(newStateConstructor)); } var returnToPool = state; From 105f37a877bf98f998be327629e9afd8cb7d4456 Mon Sep 17 00:00:00 2001 From: Mihai Alexandru <77043862+MAJigsaw77@users.noreply.github.com> Date: Thu, 16 Nov 2023 02:27:57 +0200 Subject: [PATCH 28/69] Show transitions above everything else (#410) * Added a camera for the transition substrate * `Std.int` oops. * Actually * Update Transition.hx * Oops * Not really fixing the issue * add camera on transition start * prevent double camera removal on state switch * set camera color on creation * prevent double destroy on camera * Update Transition.hx * change hxformat to match flixel's * cleanup imports * move top camera logic to TransitionEffect, use modes * lower case args * more docs --------- Co-authored-by: George FunBook --- flixel/addons/transition/Transition.hx | 56 ++++++++------ flixel/addons/transition/TransitionData.hx | 78 ++++++++++++++++---- flixel/addons/transition/TransitionEffect.hx | 51 ++++++++++--- hxformat.json | 3 + 4 files changed, 137 insertions(+), 51 deletions(-) diff --git a/flixel/addons/transition/Transition.hx b/flixel/addons/transition/Transition.hx index 3802bfc0..9e169694 100644 --- a/flixel/addons/transition/Transition.hx +++ b/flixel/addons/transition/Transition.hx @@ -1,10 +1,11 @@ package flixel.addons.transition; -import flixel.addons.transition.TransitionData.TransitionType; +import flixel.addons.transition.TransitionData; import flixel.addons.transition.TransitionEffect; import flixel.addons.transition.TransitionFade; import flixel.addons.transition.TransitionTiles; -import flixel.addons.transition.FlxTransitionSprite.TransitionStatus; +import flixel.addons.transition.FlxTransitionSprite; +import flixel.FlxCamera; import flixel.FlxG; import flixel.FlxSprite; import flixel.FlxSubState; @@ -13,6 +14,7 @@ import flixel.group.FlxGroup.FlxTypedGroup; import flixel.tweens.FlxEase; import flixel.tweens.FlxTween; import flixel.util.FlxColor; +import flixel.util.FlxDestroyUtil; import flixel.util.FlxTimer; /** @@ -23,63 +25,69 @@ import flixel.util.FlxTimer; class Transition extends FlxSubState { public var finishCallback(get, set):Void->Void; - + var _effect:TransitionEffect; - + public function new(data:TransitionData) { super(FlxColor.TRANSPARENT); + _effect = createEffect(data); _effect.scrollFactor.set(0, 0); add(_effect); } - + public override function destroy():Void { super.destroy(); + finishCallback = null; - _effect = null; + + _effect = FlxDestroyUtil.destroy(_effect); } - - public function start(NewStatus:TransitionStatus):Void + + public function start(newStatus:TransitionStatus):Void { - _effect.start(NewStatus); + _effect.start(newStatus); } - - public function setStatus(NewStatus:TransitionStatus):Void + + public function setStatus(newStatus:TransitionStatus):Void { - _effect.setStatus(NewStatus); + _effect.setStatus(newStatus); } - - function createEffect(Data:TransitionData):TransitionEffect + + function createEffect(data:TransitionData):TransitionEffect { - switch (Data.type) + switch (data.type) { case TransitionType.TILES: - return new TransitionTiles(Data); + return new TransitionTiles(data); case TransitionType.FADE: - return new TransitionFade(Data); - default: - return null; + return new TransitionFade(data); + case TransitionType.NONE: + throw "Unexpected TransitionType: NONE"; } } - + function get_finishCallback():Void->Void { if (_effect != null) { return _effect.finishCallback; } + return null; } - - function set_finishCallback(f:Void->Void):Void->Void + + function set_finishCallback(callback:Void->Void):Void->Void { if (_effect != null) { - _effect.finishCallback = f; - return f; + _effect.finishCallback = callback; + + return callback; } + return null; } } diff --git a/flixel/addons/transition/TransitionData.hx b/flixel/addons/transition/TransitionData.hx index 09190f8e..873a033d 100644 --- a/flixel/addons/transition/TransitionData.hx +++ b/flixel/addons/transition/TransitionData.hx @@ -15,6 +15,22 @@ enum abstract TransitionType(String) var FADE = "fade"; } +/** + * Whether this transition will use a new camera, the top camera, or the default camera(s) + * @since 5.6.0 + */ +enum TransitionCameraMode +{ + /** The transition will use the current top-most camera, this is the default value */ + TOP; + + /** The transition will create and use a new camera above all others */ + NEW; + + /** The transition will use the default cameras */ + DEFAULT; +} + typedef TransitionTileData = { asset:FlxGraphicAsset, @@ -28,44 +44,76 @@ typedef TransitionTileData = */ class TransitionData implements IFlxDestroyable { + /** `NONE`, `TILE`, or `FADE` */ public var type:TransitionType; + + /** The graphic to tile, when `TILE` type is used */ public var tileData:TransitionTileData; + + /** The color of the transition */ public var color:FlxColor; + + /** How long the transition will take */ public var duration:Float = 1.0; + + /** Add a "wipe" effect to various transition styles */ public var direction:FlxPoint; + + /** Used to override the options of the tween controlling this transtition */ public var tweenOptions:TweenOptions; + + /** The area of the screen to display the transition */ public var region:FlxRect; - + + /** + * Whether this transition will use a new camera, the top camera, or the default camera + * @since 5.6.0 + */ + public var cameraMode:TransitionCameraMode = TOP; + public function destroy():Void { tileData = null; direction = null; - tweenOptions.onComplete = null; - tweenOptions.ease = null; tweenOptions = null; region = null; direction = null; } - - public function new(TransType:TransitionType = FADE, Color:FlxColor = FlxColor.WHITE, Duration:Float = 1.0, ?Direction:FlxPoint, - ?TileData:TransitionTileData, ?Region:FlxRect) + + /** + * Used to define a transition for `FlxTransitionableState` + * + * @param type `NONE`, `TILE`, or `FADE` + * @param color The color of the transition + * @param duration How long the transition will take + * @param direction Add a "wipe" effect to various transition styles + * @param tileData The graphic to tile, when `TILE` type is used + * @param region The area of the screen to display the transition + * @param cameraMode Whether this transition will use a new camera, the top camera, or the default camera + */ + public function new(type = FADE, color = FlxColor.WHITE, duration = 1.0, ?direction:FlxPoint, ?tileData:TransitionTileData, ?region:FlxRect, + cameraMode = TOP) { - type = TransType; - tileData = TileData; - duration = Duration; - color = Color; - direction = Direction; + this.type = type; + this.tileData = tileData; + this.duration = duration; + this.color = color; if (direction == null) { direction = new FlxPoint(0, 0); } - FlxMath.bound(direction.x, -1, 1); - FlxMath.bound(direction.y, -1, 1); + else + { + direction.x = FlxMath.bound(direction.x, -1, 1); + direction.y = FlxMath.bound(direction.y, -1, 1); + } + this.direction = direction; tweenOptions = {onComplete: null}; - region = Region; - if (Region == null) + if (region == null) { region = new FlxRect(0, 0, FlxG.width, FlxG.height); } + this.region = region; + this.cameraMode = cameraMode; } } diff --git a/flixel/addons/transition/TransitionEffect.hx b/flixel/addons/transition/TransitionEffect.hx index 502c34d1..fda10cc2 100644 --- a/flixel/addons/transition/TransitionEffect.hx +++ b/flixel/addons/transition/TransitionEffect.hx @@ -14,30 +14,40 @@ class TransitionEffect extends FlxSpriteGroup { public var finishCallback:Void->Void; public var finished(default, null):Bool = false; - + var _started:Bool = false; var _endStatus:TransitionStatus; var _finalDelayTime:Float = 0.0; - + var _customCamera:FlxCamera; + var _data:TransitionData; - + public function new(data:TransitionData) { _data = data; super(); } - + override public function destroy():Void { super.destroy(); finishCallback = null; + + if (_customCamera != null) + { + // may already be removed via state switching + if (FlxG.cameras.list.contains(_customCamera)) + FlxG.cameras.remove(_customCamera, true); + + _customCamera = null; + } } - - public function start(NewStatus:TransitionStatus):Void + + public function start(newStatus:TransitionStatus):Void { _started = true; - - if (NewStatus == IN) + + if (newStatus == IN) { _endStatus = FULL; } @@ -45,21 +55,38 @@ class TransitionEffect extends FlxSpriteGroup { _endStatus = EMPTY; } + + switch (_data.cameraMode) + { + case NEW: + // create a new camera above everything else + _customCamera = new FlxCamera(0, 0, Std.int(_data.region.width), Std.int(_data.region.height)); + _customCamera.bgColor = 0x0; + FlxG.cameras.add(_customCamera, false); + camera = _customCamera; + case TOP: + // get the last added camera so it shows up on top of everything + final cams = FlxG.cameras.list; + camera = cams[cams.length - 1]; + case DEFAULT: + // do nothing + } } - - public function setStatus(NewStatus:TransitionStatus):Void + + public function setStatus(newStatus:TransitionStatus):Void { // override per subclass } - + function delayThenFinish():Void { new FlxTimer().start(_finalDelayTime, onFinish); // force one last render call before exiting } - + function onFinish(f:FlxTimer):Void { finished = true; + if (finishCallback != null) { var callback = finishCallback; diff --git a/hxformat.json b/hxformat.json index 66cb3869..d747ff50 100644 --- a/hxformat.json +++ b/hxformat.json @@ -11,5 +11,8 @@ "doWhile": "next", "tryBody": "next", "tryCatch": "next" + }, + "indentation":{ + "trailingWhitespace": true } } From cffaaed3a26a31137408e43ee7105255b91ec141 Mon Sep 17 00:00:00 2001 From: George Kurelic Date: Wed, 15 Nov 2023 18:30:56 -0600 Subject: [PATCH 29/69] fix incorrect since in TransitionData.hx from #410 --- flixel/addons/transition/TransitionData.hx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/flixel/addons/transition/TransitionData.hx b/flixel/addons/transition/TransitionData.hx index 873a033d..e1f6ce18 100644 --- a/flixel/addons/transition/TransitionData.hx +++ b/flixel/addons/transition/TransitionData.hx @@ -17,7 +17,7 @@ enum abstract TransitionType(String) /** * Whether this transition will use a new camera, the top camera, or the default camera(s) - * @since 5.6.0 + * @since 3.3.0 */ enum TransitionCameraMode { @@ -67,7 +67,7 @@ class TransitionData implements IFlxDestroyable /** * Whether this transition will use a new camera, the top camera, or the default camera - * @since 5.6.0 + * @since 3.3.0 */ public var cameraMode:TransitionCameraMode = TOP; From 4abaf994c327a4a3be0fbf39538c3515b1c7d803 Mon Sep 17 00:00:00 2001 From: George Kurelic Date: Wed, 22 Nov 2023 17:20:41 -0600 Subject: [PATCH 30/69] Fix CI (#411) * Update main.yml * change test location * fix addons dev path --- .github/workflows/main.yml | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5ecc4c6c..850b5494 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,22 +1,37 @@ name: CI -on: [push, pull_request, workflow_dispatch, repository_dispatch] +on: + push: + pull_request: + workflow_dispatch: + repository_dispatch: jobs: build: strategy: matrix: - haxe-version: ["4.2.5", stable, nightly] + haxe-version: ["4.2.5", "4.3.3", latest] target: [html5, hl, neko, flash, cpp] fail-fast: false runs-on: ubuntu-latest steps: - - uses: lix-pm/setup-lix@master - - uses: actions/checkout@v2 - - run: haxelib dev flixel-addons . - - uses: HaxeFlixel/setup-flixel@master + - run: sudo apt-get update + + - uses: actions/checkout@v3 + + - uses: krdlab/setup-haxe@v1 with: haxe-version: ${{matrix.haxe-version}} + + - name: "Configure Haxelib" + run: | + haxelib setup /home/runner/haxe/haxelib/ + haxelib install haxelib 4.0.3 + haxelib dev flixel-addons . + + - uses: HaxeFlixel/setup-flixel@master + with: + haxe-version: current flixel-versions: dev target: ${{matrix.target}} run-tests: true From 9e0ac438edb346fa8188c92633e80662af8a307b Mon Sep 17 00:00:00 2001 From: Ne_Eo Date: Thu, 14 Dec 2023 18:17:37 +0100 Subject: [PATCH 31/69] Fix transition bug with persistent images (#412) * Fix transition bug with persistent images Optimize fade transition * Fixed potential issue with defaultAntialiasing on transitions --- flixel/addons/transition/TransitionFade.hx | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/flixel/addons/transition/TransitionFade.hx b/flixel/addons/transition/TransitionFade.hx index 1bc57086..ef0850bf 100644 --- a/flixel/addons/transition/TransitionFade.hx +++ b/flixel/addons/transition/TransitionFade.hx @@ -73,7 +73,7 @@ class TransitionFade extends TransitionEffect FlxTween.tween(back, endValues, _data.duration, _data.tweenOptions); } - function setTweenValues(isIn:Bool, dirX:Float, dirY:Float, sprite:FlxSprite, values:TweenEndValues) + function setTweenValues(isIn:Bool, dirX:Float, dirY:Float, sprite:FlxSprite, values:TweenEndValues):Void { final isOut = !isIn; if (dirX == 0 && dirY == 0) @@ -127,20 +127,30 @@ class TransitionFade extends TransitionEffect } } } + + inline function getBitmapKey(dirX:Float, dirY:Float, color:FlxColor):String + { + return "transition" + color + "x" + dirX + "y" + dirY; + } function makeSprite(dirX:Float, dirY:Float, region:FlxRect):FlxSprite { final sprite = new FlxSprite(region.x, region.y); + final bitmapKey = getBitmapKey(dirX, dirY, _data.color); + + sprite.antialiasing = false; if (dirX == 0 && dirY == 0) { // no direction - sprite.makeGraphic(Std.int(region.width), Std.int(region.height), _data.color); + sprite.makeGraphic(1, 1, _data.color, false, bitmapKey); + sprite.scale.set(Std.int(region.width), Std.int(region.height)); + sprite.updateHitbox(); } else if (dirX == 0 && dirY != 0) { // vertical wipe - sprite.makeGraphic(1, Std.int(region.height * 2), _data.color); + sprite.makeGraphic(1, Std.int(region.height * 2), _data.color, false, bitmapKey); final angle = dirY > 0 ? 90 : 270; final gradient = FlxGradient.createGradientBitmapData(1, Std.int(region.height), [_data.color, FlxColor.TRANSPARENT], 1, angle); final destY = dirY > 0 ? region.height : 0; @@ -153,7 +163,7 @@ class TransitionFade extends TransitionEffect // horizontal wipe final destX = dirX > 0 ? region.width : 0; final angle = dirX > 0 ? 0 : 180; - sprite.makeGraphic(Std.int(region.width * 2), 1, _data.color); + sprite.makeGraphic(Std.int(region.width * 2), 1, _data.color, false, bitmapKey); final gradient = FlxGradient.createGradientBitmapData(Std.int(region.width), 1, [_data.color, FlxColor.TRANSPARENT], 1, angle); sprite.pixels.copyPixels(gradient, gradient.rect, new Point(destX, 0)); sprite.scale.set(1.0, region.height); From aad9c350153edfcdd1d4955b787231c2cec38e43 Mon Sep 17 00:00:00 2001 From: Mihai Alexandru <77043862+MAJigsaw77@users.noreply.github.com> Date: Wed, 20 Dec 2023 23:34:52 +0200 Subject: [PATCH 32/69] Fixed `FlxRuntimeShader` on the latest flixel commit. (#414) * Fixed `FlxRuntimeShader` on latest flixel. * Update flixel/addons/display/FlxRuntimeShader.hx Co-authored-by: George Kurelic * A bit of formatting * Update FlxRuntimeShader.hx * This should fix the compile now * fix flash --------- Co-authored-by: George Kurelic --- flixel/addons/display/FlxRuntimeShader.hx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/flixel/addons/display/FlxRuntimeShader.hx b/flixel/addons/display/FlxRuntimeShader.hx index 9ab2b6e8..423a6190 100644 --- a/flixel/addons/display/FlxRuntimeShader.hx +++ b/flixel/addons/display/FlxRuntimeShader.hx @@ -1,6 +1,10 @@ package flixel.addons.display; -#if (FLX_DRAW_QUADS && !flash) +#if (nme || flash) + #if FLX_NO_COVERAGE_TEST + #error "FlxRuntimeShader isn't available with nme or flash." + #end +#else import flixel.graphics.tile.FlxGraphicsShader; #if lime import lime.utils.Float32Array; From 19c281642d956e577bd2d6e495c53fe079ca7e26 Mon Sep 17 00:00:00 2001 From: itulau <102986935+itulau@users.noreply.github.com> Date: Fri, 22 Dec 2023 17:24:02 -0300 Subject: [PATCH 33/69] Fix FlxNestedSprite showing default icon incorrectly (#415) By adding a check for existence on _frame (which FlxSprite uses to insert the default png) when drawing the element this prevents the default behavior. --- flixel/addons/display/FlxNestedSprite.hx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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) { From 3fce942fde2b4d8e436995a2fc7efa603df4695d Mon Sep 17 00:00:00 2001 From: George Kurelic Date: Thu, 4 Jan 2024 10:36:47 -0500 Subject: [PATCH 34/69] use setup-flixel v1 --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 850b5494..e5faab14 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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 From 1869a4b68f52c91c9dd9d2b00c8a2dffe3db5058 Mon Sep 17 00:00:00 2001 From: George Kurelic Date: Thu, 4 Jan 2024 14:53:57 -0600 Subject: [PATCH 35/69] set version 3.2.2 --- haxelib.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/haxelib.json b/haxelib.json index 40378a6b..1d77a7b5 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.2", + "releasenote": "Compatibility with flixel changes", "contributors": ["haxeflixel", "Gama11", "GeoKureli"] } From 719fd7b527ca9b75ba019c0a2b59d0ce0a79c15e Mon Sep 17 00:00:00 2001 From: George FunBook Date: Thu, 4 Jan 2024 15:55:01 -0600 Subject: [PATCH 36/69] add all current 3.2.2 changes --- CHANGELOG.md | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fe72263b..4abba748 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,20 @@ -3.2.1 (September 26, 2023) +3.2.2 (TBD) ------------------------------ +#### 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)) From b82db849603e250e0574c16ab71a13229e65b4ba Mon Sep 17 00:00:00 2001 From: George Kurelic Date: Thu, 4 Jan 2024 15:57:04 -0600 Subject: [PATCH 37/69] Add compatibility checks with flixel (#419) * check compatibility with flixel * update formatting settings * wrap in #if macro --- .vscode/settings.json | 3 +- .../effects/chainable/FlxEffectSprite.hx | 6 ++ .../addons/system/macros/FlxAddonDefines.hx | 64 +++++++++++++++++++ flixel/addons/text/FlxTypeText.hx | 6 ++ .../transition/FlxTransitionableState.hx | 6 ++ flixel/addons/weapon/FlxWeapon.hx | 6 ++ 6 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 flixel/addons/system/macros/FlxAddonDefines.hx 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/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/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/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; From fd536638635989020061fcd7725013a690c52347 Mon Sep 17 00:00:00 2001 From: George FunBook Date: Thu, 4 Jan 2024 15:59:30 -0600 Subject: [PATCH 38/69] add minimum versions --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4abba748..41a1985d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ 3.2.2 (TBD) ------------------------------ +#### 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)) From 535a78eff341dc449d1d3524e28021c4a95e2930 Mon Sep 17 00:00:00 2001 From: George Kurelic Date: Thu, 4 Jan 2024 17:59:48 -0600 Subject: [PATCH 39/69] fix plugin warnings (#418) --- flixel/addons/nape/FlxNapeSpace.hx | 4 ++++ 1 file changed, 4 insertions(+) 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()); From ce8b9693a192de42adc9a29f52851e9efa7d14f9 Mon Sep 17 00:00:00 2001 From: George Kurelic Date: Wed, 28 Feb 2024 06:08:45 -0800 Subject: [PATCH 40/69] flixel 5.2 compat (#423) --- flixel/addons/display/FlxBackdrop.hx | 60 +++++++++++++--------------- 1 file changed, 28 insertions(+), 32 deletions(-) diff --git a/flixel/addons/display/FlxBackdrop.hx b/flixel/addons/display/FlxBackdrop.hx index 4927e3bd..90731e13 100644 --- a/flixel/addons/display/FlxBackdrop.hx +++ b/flixel/addons/display/FlxBackdrop.hx @@ -146,10 +146,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 +156,17 @@ class FlxBackdrop extends FlxSprite { var largest:FlxCamera = null; var largestArea = 0.0; - var view = FlxRect.get(); 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); @@ -208,24 +203,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) @@ -311,13 +307,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,12 +321,12 @@ 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); @@ -407,7 +403,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 +412,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)) { From 74a9604542a8bc0e3cdcb0cd04344e36bd7bee46 Mon Sep 17 00:00:00 2001 From: George Kurelic Date: Sun, 10 Mar 2024 07:08:16 -0700 Subject: [PATCH 41/69] use FlxContainer and getCameras (#424) --- flixel/addons/display/FlxBackdrop.hx | 6 ++++++ flixel/addons/display/FlxSliceSprite.hx | 2 +- flixel/addons/display/FlxTiledSprite.hx | 2 +- flixel/addons/editors/spine/FlxSpine.hx | 2 +- flixel/addons/effects/FlxTrail.hx | 4 ++-- flixel/addons/transition/TransitionEffect.hx | 4 ++-- flixel/addons/ui/FlxButtonPlus.hx | 4 ++-- flixel/addons/ui/FlxClickArea.hx | 3 +++ flixel/addons/ui/FlxSlider.hx | 16 ++++++++++------ 9 files changed, 28 insertions(+), 15 deletions(-) diff --git a/flixel/addons/display/FlxBackdrop.hx b/flixel/addons/display/FlxBackdrop.hx index 90731e13..cdc498a5 100644 --- a/flixel/addons/display/FlxBackdrop.hx +++ b/flixel/addons/display/FlxBackdrop.hx @@ -113,6 +113,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)) @@ -156,6 +159,9 @@ class FlxBackdrop extends FlxSprite { var largest:FlxCamera = null; var largestArea = 0.0; + #if (flixel >= "5.7.0") + final cameras = getCamerasLegacy(); // else use this.cameras + #end for (camera in cameras) { if (!camera.visible || !camera.exists || !isOnScreen(camera)) 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 b47b8efe..4fe74730 100644 --- a/flixel/addons/display/FlxTiledSprite.hx +++ b/flixel/addons/display/FlxTiledSprite.hx @@ -144,7 +144,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/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..025d245f 100644 --- a/flixel/addons/ui/FlxClickArea.hx +++ b/flixel/addons/ui/FlxClickArea.hx @@ -127,6 +127,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 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) { From e0a906afa39a009398b00998a1bb6007963465a5 Mon Sep 17 00:00:00 2001 From: George FunBook Date: Sun, 10 Mar 2024 09:10:56 -0500 Subject: [PATCH 42/69] release 3.2.2 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 41a1985d..f804d725 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -3.2.2 (TBD) +3.2.2 (March 10, 2024) ------------------------------ #### Dependencies: - Minimum versions allowed: From 74215257c33409e2c8b14847fc05dc633182c9a8 Mon Sep 17 00:00:00 2001 From: George FunBook Date: Sun, 10 Mar 2024 12:04:22 -0500 Subject: [PATCH 43/69] fix version --- flixel/addons/util/FlxFSM.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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, []); From 0d3b597b982e050386f6b927c5be204fec5ac33d Mon Sep 17 00:00:00 2001 From: George Kurelic Date: Tue, 19 Mar 2024 07:12:34 -0700 Subject: [PATCH 44/69] use FlxButtonState for 5.7.0 compat (#425) --- flixel/addons/ui/FlxClickArea.hx | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/flixel/addons/ui/FlxClickArea.hx b/flixel/addons/ui/FlxClickArea.hx index 025d245f..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; @@ -151,7 +157,7 @@ class FlxClickArea extends FlxObject } if (offAll) { - status = FlxButton.NORMAL; + status = NORMAL; } } } @@ -169,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; } } @@ -185,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; } @@ -193,6 +199,6 @@ class FlxClickArea extends FlxObject { onUp(); } - status = FlxButton.NORMAL; + status = NORMAL; } } From bc6cd74b001c76ff10c4bf4ac49afa8026493afc Mon Sep 17 00:00:00 2001 From: MaybeMaru <97055307+MaybeMaru@users.noreply.github.com> Date: Sun, 14 Apr 2024 00:55:24 +0200 Subject: [PATCH 45/69] Avoid FlxBackdrop matrix leak (#426) * Update FlxBackdrop.hx * whoops missed these * revert certain changes, add tileSize.put calls --------- Co-authored-by: George Kurelic --- flixel/addons/display/FlxBackdrop.hx | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/flixel/addons/display/FlxBackdrop.hx b/flixel/addons/display/FlxBackdrop.hx index cdc498a5..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(); } @@ -200,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); @@ -256,6 +258,7 @@ class FlxBackdrop extends FlxSprite } } + tileSize.put(); camera.buffer.unlock(); } @@ -275,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) { @@ -339,33 +342,33 @@ class FlxBackdrop extends FlxSprite 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(); } From 9eabccfa66ec783d846425fe3313c3c501bc965d Mon Sep 17 00:00:00 2001 From: George Kurelic Date: Wed, 15 May 2024 14:08:47 -0500 Subject: [PATCH 46/69] remove latest CI for now --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e5faab14..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 From c4a3d29be048910c21f40eb8b80338294349440b Mon Sep 17 00:00:00 2001 From: George Kurelic Date: Wed, 15 May 2024 15:54:15 -0500 Subject: [PATCH 47/69] fix docs (#429) * fix docs * remove commented code --- flixel/addons/display/FlxRuntimeShader.hx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/flixel/addons/display/FlxRuntimeShader.hx b/flixel/addons/display/FlxRuntimeShader.hx index 423a6190..8134f9c5 100644 --- a/flixel/addons/display/FlxRuntimeShader.hx +++ b/flixel/addons/display/FlxRuntimeShader.hx @@ -1,8 +1,8 @@ package flixel.addons.display; #if (nme || flash) - #if FLX_NO_COVERAGE_TEST - #error "FlxRuntimeShader isn't available with nme or flash." + #if (FLX_NO_COVERAGE_TEST && !(doc_gen)) + #error "FlxRuntimeShader isn't available with nme or flash." #end #else import flixel.graphics.tile.FlxGraphicsShader; From 2759aff3d6f024b38aa4c4bfc30f93ad501292d7 Mon Sep 17 00:00:00 2001 From: George FunBook Date: Wed, 15 May 2024 16:07:16 -0500 Subject: [PATCH 48/69] release 3.2.3 --- CHANGELOG.md | 10 ++++++++++ haxelib.json | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f804d725..7937aac6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +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: diff --git a/haxelib.json b/haxelib.json index 1d77a7b5..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.2", - "releasenote": "Compatibility with flixel changes", + "version": "3.2.3", + "releasenote": "Compatibility with flixel 5.7.0", "contributors": ["haxeflixel", "Gama11", "GeoKureli"] } From 6b0ec36b145dee2cc8d8056ba3048da5c6b83379 Mon Sep 17 00:00:00 2001 From: George Kurelic Date: Wed, 5 Jun 2024 17:23:35 -0500 Subject: [PATCH 49/69] 5.9.0 compat (#431) --- flixel/addons/editors/ogmo/FlxOgmo3Loader.hx | 4 + flixel/addons/tile/FlxRayCastTilemap.hx | 6 +- flixel/addons/tile/FlxTilemapExt.hx | 93 +++++++++++++++++++- flixel/addons/weapon/FlxWeapon.hx | 12 ++- 4 files changed, 102 insertions(+), 13 deletions(-) diff --git a/flixel/addons/editors/ogmo/FlxOgmo3Loader.hx b/flixel/addons/editors/ogmo/FlxOgmo3Loader.hx index 95dd88f5..b5702fa0 100644 --- a/flixel/addons/editors/ogmo/FlxOgmo3Loader.hx +++ b/flixel/addons/editors/ogmo/FlxOgmo3Loader.hx @@ -284,7 +284,11 @@ class FlxOgmo3Loader for (i in 0...tileFlags.length) { var flag = tileFlags[i]; + #if (flixel < "5.9.0") var specialTile = new FlxTileSpecial(tilemap.getTileByIndex(i), false, false, 0); + #else + var specialTile = new FlxTileSpecial(tilemap.getTileIndex(i), false, false, 0); + #end if (flag & 4 > 0) specialTile.flipX = true; diff --git a/flixel/addons/tile/FlxRayCastTilemap.hx b/flixel/addons/tile/FlxRayCastTilemap.hx index 3d5e5b13..b708ba1b 100644 --- a/flixel/addons/tile/FlxRayCastTilemap.hx +++ b/flixel/addons/tile/FlxRayCastTilemap.hx @@ -6,6 +6,7 @@ import flixel.math.FlxPoint; /** * @author greglieberman */ +@:deprecated("FlxRayCastTilemap is deprecated, use FlxTilemap.ray or rayStep, instead")// for flixel 5.9.0 class FlxRayCastTilemap extends FlxTilemap { /** @@ -222,11 +223,6 @@ class FlxRayCastTilemap extends FlxTilemap return Y * widthInTiles + X; } - public function getTileIndex(X:Int, Y:Int):Int - { - return Y * widthInTiles + X; - } - public function coordsToTileX(CoordX:Float):Float { return Std.int((CoordX - x) / scaledTileWidth); diff --git a/flixel/addons/tile/FlxTilemapExt.hx b/flixel/addons/tile/FlxTilemapExt.hx index 7973569b..538241f3 100644 --- a/flixel/addons/tile/FlxTilemapExt.hx +++ b/flixel/addons/tile/FlxTilemapExt.hx @@ -322,6 +322,7 @@ class FlxTilemapExt extends FlxTilemap } } + #if (flixel < "5.9.0") /** * THIS IS A COPY FROM FlxTilemap BUT IT SOLVES SLOPE COLLISION TOO * Checks if the Object overlaps any tiles with any collision flags set, @@ -334,7 +335,7 @@ class FlxTilemapExt extends FlxTilemap * @param position Optional, specify a custom position for the tilemap (useful for overlapsAt()-type functionality). * @return Whether there were overlaps, or if a callback was specified, whatever the return value of the callback was. */ - override public function overlapsWithCallback(object:FlxObject, ?callback:FlxObject->FlxObject->Bool, flipCallbackParams:Bool = false, + override function overlapsWithCallback(object:FlxObject, ?callback:FlxObject->FlxObject->Bool, flipCallbackParams:Bool = false, ?position:FlxPoint):Bool { var results:Bool = false; @@ -375,8 +376,7 @@ class FlxTilemapExt extends FlxTilemap continue; final tile = _tileObjects[dataIndex]; - - if (tile.allowCollisions != NONE) + if (tile.solid) { var overlapFound = false; @@ -400,7 +400,10 @@ class FlxTilemapExt extends FlxTilemap } else { - overlapFound = (object.x + object.width > tile.x) && (object.x < tile.x + tile.width) && (object.y + object.height > tile.y) + overlapFound + = (object.x + object.width > tile.x) + && (object.x < tile.x + tile.width) + && (object.y + object.height > tile.y) && (object.y < tile.y + tile.height); } @@ -425,6 +428,88 @@ class FlxTilemapExt extends FlxTilemap return results; } + #else + /** + * Hacky fix for `FlxTilemapExt`, with all the new changes to 5.9.0 it's better to perfectly + * recreate the old behavior, here and then make a new tilemap with slopes that uses the new + * features to eventually replace it + */ + override function processOverlaps(object:TObj, ?processCallback:(FlxTile, TObj)->Bool, ?position:FlxPoint, isCollision = true):Bool + { + var results:Bool = false; + + var xPos:Float = x; + var yPos:Float = y; + + if (position != null) + { + xPos = position.x; + yPos = position.y; + position.putWeak(); + } + + inline function bindInt(value:Int, min:Int, max:Int) + { + return Std.int(FlxMath.bound(value, min, max)); + } + + // Figure out what tiles we need to check against, and bind them by the map edges + final minTileX:Int = bindInt(Math.floor((object.x - xPos) / scaledTileWidth), 0, widthInTiles); + final minTileY:Int = bindInt(Math.floor((object.y - yPos) / scaledTileHeight), 0, heightInTiles); + final maxTileX:Int = bindInt(Math.ceil((object.x + object.width - xPos) / scaledTileWidth), 0, widthInTiles); + final maxTileY:Int = bindInt(Math.ceil((object.y + object.height - yPos) / scaledTileHeight), 0, heightInTiles); + + // Cache tilemap movement + final deltaX:Float = xPos - last.x; + final deltaY:Float = yPos - last.y; + + // Loop through the range of tiles and call the callback on them, accordingly + for (row in minTileY...maxTileY) + { + for (column in minTileX...maxTileX) + { + final mapIndex:Int = (row * widthInTiles) + column; + final dataIndex:Int = _data[mapIndex]; + if (dataIndex < 0) + continue; + + final tile = _tileObjects[dataIndex]; + tile.orientAt(xPos, yPos, column, row); + + if (tile.solid) + { + var overlapFound = false; + if (processCallback != null) + { + overlapFound = processCallback(tile, object); + } + else + { + overlapFound = tile.overlapsObject(object); + } + + // New generalized slope collisions + if (overlapFound || checkArrays(tile.index)) + { + if ((tile.callbackFunction != null) && ((tile.filter == null) || Std.isOfType(object, tile.filter))) + { + tile.callbackFunction(tile, object); + tile.onCollide.dispatch(tile, object); + } + results = true; + } + } + else if ((tile.callbackFunction != null) && ((tile.filter == null) || Std.isOfType(object, tile.filter))) + { + tile.callbackFunction(tile, object); + tile.onCollide.dispatch(tile, object); + } + } + } + + return results; + } + #end /** * Set glue to force contact with slopes and a slow down factor while climbing diff --git a/flixel/addons/weapon/FlxWeapon.hx b/flixel/addons/weapon/FlxWeapon.hx index 0c43dd37..d8c04de5 100644 --- a/flixel/addons/weapon/FlxWeapon.hx +++ b/flixel/addons/weapon/FlxWeapon.hx @@ -430,16 +430,20 @@ class FlxTypedWeapon } } - function shouldBulletHit(Object:FlxObject, Bullet:FlxObject):Bool + function shouldBulletHit(object:FlxObject, bullet:FlxObject):Bool { - if (parent == Object && skipParentCollision) + if (parent == object && skipParentCollision) { return false; } - if ((Object is FlxTilemap)) + if ((object is FlxTilemap)) { - return cast(Object, FlxTilemap).overlapsWithCallback(Bullet); + #if (flixel < "5.9.0") + return cast(object, FlxTilemap).overlapsWithCallback(bullet); + #else + return cast(object, FlxTilemap).processOverlaps(bullet); + #end } else { From 423ba2b05c6ee3d913d39776b92c7ddba1690727 Mon Sep 17 00:00:00 2001 From: George FunBook Date: Wed, 5 Jun 2024 17:26:16 -0500 Subject: [PATCH 50/69] prepare for 3.2.4 --- CHANGELOG.md | 7 +++++++ haxelib.json | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7937aac6..669b753e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +3.2.4 (TBD) +------------------------------ +#### Changes and improvements: +- Compatibility with Flixel 5.9.0 ([431](https://github.com/HaxeFlixel/flixel-addons/pull/431)) + - Deprecated `FlxRayCastTilemap` + - Minor upkeep for `FlxTilemapExt`, `FlxOgmo3Loader`, `FlxOgmo3Loader` + 3.2.3 (May 15, 2024) ------------------------------ diff --git a/haxelib.json b/haxelib.json index 9cda487a..137b228a 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.3", - "releasenote": "Compatibility with flixel 5.7.0", + "version": "3.2.4", + "releasenote": "Compatibility with flixel 5.9.0", "contributors": ["haxeflixel", "Gama11", "GeoKureli"] } From 83a0984a4fb39bd13f890005c456bebdb2878ba9 Mon Sep 17 00:00:00 2001 From: George Kurelic Date: Thu, 6 Jun 2024 09:48:23 -0500 Subject: [PATCH 51/69] Tilemapext overlaps (#432) * use forEachOverlappingTile after all * rename method --- flixel/addons/tile/FlxTilemapExt.hx | 88 +++++++++-------------------- 1 file changed, 26 insertions(+), 62 deletions(-) diff --git a/flixel/addons/tile/FlxTilemapExt.hx b/flixel/addons/tile/FlxTilemapExt.hx index 538241f3..068518a3 100644 --- a/flixel/addons/tile/FlxTilemapExt.hx +++ b/flixel/addons/tile/FlxTilemapExt.hx @@ -434,79 +434,43 @@ class FlxTilemapExt extends FlxTilemap * recreate the old behavior, here and then make a new tilemap with slopes that uses the new * features to eventually replace it */ - override function processOverlaps(object:TObj, ?processCallback:(FlxTile, TObj)->Bool, ?position:FlxPoint, isCollision = true):Bool + override function objectOverlapsTiles(object:TObj, ?callback:(FlxTile, TObj)->Bool, ?position:FlxPoint, isCollision = true):Bool { - var results:Bool = false; - - var xPos:Float = x; - var yPos:Float = y; - - if (position != null) - { - xPos = position.x; - yPos = position.y; - position.putWeak(); - } - - inline function bindInt(value:Int, min:Int, max:Int) + var results = false; + function each(tile:FlxTile) { - return Std.int(FlxMath.bound(value, min, max)); - } - - // Figure out what tiles we need to check against, and bind them by the map edges - final minTileX:Int = bindInt(Math.floor((object.x - xPos) / scaledTileWidth), 0, widthInTiles); - final minTileY:Int = bindInt(Math.floor((object.y - yPos) / scaledTileHeight), 0, heightInTiles); - final maxTileX:Int = bindInt(Math.ceil((object.x + object.width - xPos) / scaledTileWidth), 0, widthInTiles); - final maxTileY:Int = bindInt(Math.ceil((object.y + object.height - yPos) / scaledTileHeight), 0, heightInTiles); - - // Cache tilemap movement - final deltaX:Float = xPos - last.x; - final deltaY:Float = yPos - last.y; - - // Loop through the range of tiles and call the callback on them, accordingly - for (row in minTileY...maxTileY) - { - for (column in minTileX...maxTileX) + if (tile.solid) { - final mapIndex:Int = (row * widthInTiles) + column; - final dataIndex:Int = _data[mapIndex]; - if (dataIndex < 0) - continue; - - final tile = _tileObjects[dataIndex]; - tile.orientAt(xPos, yPos, column, row); - - if (tile.solid) + var overlapFound = false; + if (callback != null) { - var overlapFound = false; - if (processCallback != null) - { - overlapFound = processCallback(tile, object); - } - else - { - overlapFound = tile.overlapsObject(object); - } + overlapFound = callback(tile, object); + } + else + { + overlapFound = tile.overlapsObject(object); + } - // New generalized slope collisions - if (overlapFound || checkArrays(tile.index)) + // New generalized slope collisions + if (overlapFound || checkArrays(tile.index)) + { + if (tile.callbackFunction != null) { - if ((tile.callbackFunction != null) && ((tile.filter == null) || Std.isOfType(object, tile.filter))) - { - tile.callbackFunction(tile, object); - tile.onCollide.dispatch(tile, object); - } - results = true; + tile.callbackFunction(tile, object); + tile.onCollide.dispatch(tile, object); } - } - else if ((tile.callbackFunction != null) && ((tile.filter == null) || Std.isOfType(object, tile.filter))) - { - tile.callbackFunction(tile, object); - tile.onCollide.dispatch(tile, object); + results = true; } } + else if ((tile.callbackFunction != null) && ((tile.filter == null) || Std.isOfType(object, tile.filter))) + { + tile.callbackFunction(tile, object); + tile.onCollide.dispatch(tile, object); + } } + forEachOverlappingTile(object, each, position); + return results; } #end From ac508d88f48cafc48a96e720d7f73b1659929b00 Mon Sep 17 00:00:00 2001 From: George Kurelic Date: Thu, 6 Jun 2024 12:23:35 -0500 Subject: [PATCH 52/69] fix weapon (#433) --- flixel/addons/weapon/FlxWeapon.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flixel/addons/weapon/FlxWeapon.hx b/flixel/addons/weapon/FlxWeapon.hx index d8c04de5..e701528d 100644 --- a/flixel/addons/weapon/FlxWeapon.hx +++ b/flixel/addons/weapon/FlxWeapon.hx @@ -442,7 +442,7 @@ class FlxTypedWeapon #if (flixel < "5.9.0") return cast(object, FlxTilemap).overlapsWithCallback(bullet); #else - return cast(object, FlxTilemap).processOverlaps(bullet); + return cast(object, FlxTilemap).objectOverlapsTiles(bullet); #end } else From 4ec75fe24fd74aeaa663a4576919278cec0431b5 Mon Sep 17 00:00:00 2001 From: George Kurelic Date: Thu, 13 Jun 2024 14:11:12 -0500 Subject: [PATCH 53/69] FlxTiledSprite honors clipRect (#435) --- flixel/addons/display/FlxTiledSprite.hx | 377 ++++++++++++++---------- 1 file changed, 219 insertions(+), 158 deletions(-) diff --git a/flixel/addons/display/FlxTiledSprite.hx b/flixel/addons/display/FlxTiledSprite.hx index 4fe74730..738699fb 100644 --- a/flixel/addons/display/FlxTiledSprite.hx +++ b/flixel/addons/display/FlxTiledSprite.hx @@ -8,6 +8,7 @@ import flixel.math.FlxMath; import flixel.system.FlxAssets.FlxGraphicAsset; import flixel.util.FlxColor; import flixel.util.FlxDestroyUtil; +import flixel.math.FlxRect; import flixel.util.FlxSpriteUtil; /** @@ -21,44 +22,44 @@ class FlxTiledSprite extends FlxStrip * The x-offset of the texture */ public var scrollX(default, set):Float = 0; - + /** * The y-offset of the texture. */ public var scrollY(default, set):Float = 0; - + /** * Repeat texture on x axis. Default is true */ public var repeatX(default, set):Bool = true; - + /** * Repeat texture on y axis. Default is true */ public var repeatY(default, set):Bool = true; - + /** * Helper sprite, which does actual rendering in blit render mode. */ var renderSprite:FlxSprite; - + var regen:Bool = true; - + var graphicVisible:Bool = true; - - public function new(?Graphic:FlxGraphicAsset, Width:Float, Height:Float, RepeatX:Bool = true, RepeatY:Bool = true) + + public function new(?graphic:FlxGraphicAsset, width:Float, height:Float, repeatX = true, repeatY = true) { super(); - + repeat = true; - + indices[0] = 0; indices[1] = 1; indices[2] = 2; indices[3] = 2; indices[4] = 3; indices[5] = 0; - + uvtData[0] = 0; uvtData[1] = 0; uvtData[2] = 1; @@ -67,58 +68,64 @@ class FlxTiledSprite extends FlxStrip uvtData[5] = 1; uvtData[6] = 0; uvtData[7] = 1; - + vertices[0] = 0; vertices[1] = 0; - vertices[2] = Width; + vertices[2] = width; vertices[3] = 0; - vertices[4] = Width; - vertices[5] = Height; + vertices[4] = width; + vertices[5] = height; vertices[6] = 0; - vertices[7] = Height; - - width = Width; - height = Height; - - repeatX = RepeatX; - repeatY = RepeatY; - - if (Graphic != null) - loadGraphic(Graphic); + vertices[7] = height; + + this.width = width; + this.height = height; + + this.repeatX = repeatX; + this.repeatY = repeatY; + + if (graphic != null) + loadGraphic(graphic); } - - override public function destroy():Void + + override function destroy():Void { renderSprite = FlxDestroyUtil.destroy(renderSprite); super.destroy(); } - - override public function loadGraphic(Graphic:FlxGraphicAsset, Animated:Bool = false, Width:Int = 0, Height:Int = 0, Unique:Bool = false, - ?Key:String):FlxSprite + + override function loadGraphic(graphic, animated = false, width = 0, height = 0, unique = false, ?key:String):FlxSprite { - graphic = FlxG.bitmap.add(Graphic); + this.graphic = FlxG.bitmap.add(graphic); return this; } - - public function loadFrame(Frame:FlxFrame):FlxTiledSprite + + public function loadFrame(frame:FlxFrame):FlxTiledSprite { - graphic = FlxGraphic.fromFrame(Frame); + graphic = FlxGraphic.fromFrame(frame); return this; } - - override function set_graphic(Value:FlxGraphic):FlxGraphic + + override function set_clipRect(value:FlxRect):FlxRect { - if (graphic != Value) + regen = true; + + return super.set_clipRect(value); + } + + override function set_graphic(value:FlxGraphic):FlxGraphic + { + if (graphic != value) regen = true; - - return super.set_graphic(Value); + + return super.set_graphic(value); } - + function regenGraphic():Void { if (!regen || graphic == null) return; - + if (FlxG.renderBlit) { updateRenderSprite(); @@ -127,69 +134,92 @@ class FlxTiledSprite extends FlxStrip { updateVerticesData(); } - + regen = false; } - - override public function draw():Void + + override function draw():Void { if (regen) regenGraphic(); - - if (!graphicVisible) - return; - - if (FlxG.renderBlit) + + if (graphicVisible) { - renderSprite.x = x; - renderSprite.y = y; - renderSprite.scrollFactor.set(scrollFactor.x, scrollFactor.y); - renderSprite._cameras = _cameras; - renderSprite.draw(); + if (FlxG.renderBlit) + { + renderSprite.x = x; + renderSprite.y = y; + renderSprite.scrollFactor.set(scrollFactor.x, scrollFactor.y); + renderSprite._cameras = _cameras; + renderSprite.draw(); + } + else + { + super.draw(); + } } - else + + #if FLX_DEBUG + if (FlxG.debugger.drawDebug) + drawDebug(); + #end + } + + #if FLX_DEBUG + /** + * Copied exactly from `FlxObject`, to avoid any future changes to `FlxStrip`'s debug drawing + */ + override function drawDebug() + { + if (ignoreDrawDebug) + return; + + final drawPath = path != null && !path.ignoreDrawDebug; + + for (camera in getCamerasLegacy()) { - super.draw(); + drawDebugOnCamera(camera); + + if (drawPath) + { + path.drawDebugOnCamera(camera); + } } } - + #end + function updateRenderSprite():Void { graphicVisible = true; - + if (renderSprite == null) renderSprite = new FlxSprite(); - - var rectX:Float = repeatX ? 0 : scrollX; - var rectWidth:Float = repeatX ? width : graphic.bitmap.width; - - if (!repeatX && (rectX > width || rectX + rectWidth < 0)) + + final drawRect = getDrawRect(); + drawRect.x = Std.int(drawRect.x); + drawRect.y = Std.int(drawRect.y); + drawRect.width = Std.int(drawRect.width); + drawRect.height = Std.int(drawRect.height); + //TODO: rect.int() or smth + + if (drawRect.width * drawRect.height == 0) { graphicVisible = false; + drawRect.put(); return; } - - var rectY:Float = repeatY ? 0 : scrollY; - var rectHeight:Float = repeatY ? height : graphic.bitmap.height; - - if (!repeatY && (rectY > height || rectY + rectHeight < 0)) - { - graphicVisible = false; - return; - } - - if (renderSprite.width != width || renderSprite.height != height) + + if (renderSprite.width != drawRect.width || renderSprite.height != drawRect.height) { - renderSprite.makeGraphic(Std.int(width), Std.int(height), FlxColor.TRANSPARENT, true); + renderSprite.makeGraphic(Std.int(drawRect.width), Std.int(drawRect.height), FlxColor.TRANSPARENT, true); } else { - _flashRect2.setTo(0, 0, width, height); - renderSprite.pixels.fillRect(_flashRect2, FlxColor.TRANSPARENT); + renderSprite.pixels.fillRect(renderSprite.pixels.rect, FlxColor.TRANSPARENT); } - + FlxSpriteUtil.flashGfx.clear(); - + if (scrollX != 0 || scrollY != 0) { _matrix.identity(); @@ -201,119 +231,150 @@ class FlxTiledSprite extends FlxStrip { FlxSpriteUtil.flashGfx.beginBitmapFill(graphic.bitmap); } - - FlxSpriteUtil.flashGfx.drawRect(rectX, rectY, rectWidth, rectHeight); + + FlxSpriteUtil.flashGfx.drawRect(drawRect.x, drawRect.y, drawRect.width, drawRect.height); renderSprite.pixels.draw(FlxSpriteUtil.flashGfxSprite, null, colorTransform); FlxSpriteUtil.flashGfx.clear(); renderSprite.dirty = true; } - + function updateVerticesData():Void { if (graphic == null) return; - - var frame:FlxFrame = graphic.imageFrame.frame; + + final frame:FlxFrame = graphic.imageFrame.frame; graphicVisible = true; - - if (repeatX) + + final drawRect = getDrawRect(); + + if (drawRect.width * drawRect.height == 0) { - vertices[0] = vertices[6] = 0.0; - vertices[2] = vertices[4] = width; - - uvtData[0] = uvtData[6] = -scrollX / frame.sourceSize.x; - uvtData[2] = uvtData[4] = uvtData[0] + width / frame.sourceSize.x; + graphicVisible = false; + drawRect.put(); + return; } - else + + // Texture coordinates (UVs) + final rectUX:Float = (drawRect.x - scrollX) / frame.sourceSize.x; + final rectVX:Float = rectUX + (drawRect.width-drawRect.x) / frame.sourceSize.x; + final rectUY:Float = (drawRect.y - scrollY) / frame.sourceSize.y; + final rectVY:Float = rectUY + (drawRect.height - drawRect.y) / frame.sourceSize.y; + + vertices[0] = drawRect.x; + vertices[2] = drawRect.width; + vertices[4] = drawRect.width; + vertices[6] = drawRect.x; + + uvtData[0] = rectUX; + uvtData[2] = rectVX; + uvtData[4] = rectVX; + uvtData[6] = rectUX; + + vertices[1] = drawRect.y; + vertices[3] = drawRect.y; + vertices[5] = drawRect.height; + vertices[7] = drawRect.height; + + uvtData[1] = rectUY; + uvtData[3] = rectUY; + uvtData[5] = rectVY; + uvtData[7] = rectVY; + + drawRect.put(); + } + + function getDrawRect(?result:FlxRect):FlxRect + { + if (result == null) + result = FlxRect.get(); + + final frame:FlxFrame = graphic.imageFrame.frame; + final sourceSizeX = FlxG.renderBlit ? graphic.bitmap.width : frame.sourceSize.x; + final sourceSizeY = FlxG.renderBlit ? graphic.bitmap.height : frame.sourceSize.y; + + result.x = (repeatX ? 0 : scrollX); + if (clipRect != null) { - vertices[0] = vertices[6] = FlxMath.bound(scrollX, 0, width); - vertices[2] = vertices[4] = FlxMath.bound(scrollX + frame.sourceSize.x, 0, width); - - if (vertices[2] - vertices[0] <= 0) - { - graphicVisible = false; - return; - } - - uvtData[0] = uvtData[6] = (vertices[0] - scrollX) / frame.sourceSize.x; - uvtData[2] = uvtData[4] = uvtData[0] + (vertices[2] - vertices[0]) / frame.sourceSize.x; + result.x += clipRect.x; } - - if (repeatY) + result.x = FlxMath.bound(result.x, 0, width); + + result.width = (repeatX ? result.x + width : scrollX + sourceSizeX); + if (clipRect != null) { - vertices[1] = vertices[3] = 0.0; - vertices[5] = vertices[7] = height; - - uvtData[1] = uvtData[3] = -scrollY / frame.sourceSize.y; - uvtData[5] = uvtData[7] = uvtData[1] + height / frame.sourceSize.y; + result.width = FlxMath.bound(result.width, clipRect.x, clipRect.right); } - else + result.width = FlxMath.bound(result.width, 0, width); + + result.y = (repeatY ? 0 : scrollY); + if (clipRect != null) { - vertices[1] = vertices[3] = FlxMath.bound(scrollY, 0, height); - vertices[5] = vertices[7] = FlxMath.bound(scrollY + frame.sourceSize.y, 0, height); - - if (vertices[5] - vertices[1] <= 0) - { - graphicVisible = false; - return; - } - - uvtData[1] = uvtData[3] = (vertices[1] - scrollY) / frame.sourceSize.y; - uvtData[5] = uvtData[7] = uvtData[1] + (vertices[5] - vertices[1]) / frame.sourceSize.y; + result.y += clipRect.y; } + result.y = FlxMath.bound(result.y, 0, height); + + result.height = (repeatY ? result.y + height : scrollY + sourceSizeY); + if (clipRect != null) + { + result.height = FlxMath.bound(result.height, clipRect.y, clipRect.bottom); + } + result.height = FlxMath.bound(result.height, 0, height); + + return result; } - - override function set_width(Width:Float):Float + + override function set_width(value:Float):Float { - if (Width <= 0) - return Width; - - if (Width != width) + if (value <= 0) + return value; + + if (value != width) regen = true; - - return super.set_width(Width); + + return super.set_width(value); } - - override function set_height(Height:Float):Float + + override function set_height(value:Float):Float { - if (Height <= 0) - return Height; - - if (Height != height) + if (value <= 0) + return value; + + if (value != height) regen = true; - - return super.set_height(Height); + + return super.set_height(value); } - - function set_scrollX(Value:Float):Float + + function set_scrollX(value:Float):Float { - if (Value != scrollX) + if (value != scrollX) regen = true; - - return scrollX = Value; + + return scrollX = value; } - - function set_scrollY(Value:Float):Float + + function set_scrollY(value:Float):Float { - if (Value != scrollY) + if (value != scrollY) regen = true; - - return scrollY = Value; + + return scrollY = value; } - - function set_repeatX(Value:Bool):Bool + + function set_repeatX(value:Bool):Bool { - if (Value != repeatX) + if (value != repeatX) regen = true; - - return repeatX = Value; + + return repeatX = value; } - - function set_repeatY(Value:Bool):Bool + + function set_repeatY(value:Bool):Bool { - if (Value != repeatY) + if (value != repeatY) regen = true; - - return repeatY = Value; + + return repeatY = value; } } From f76d8b22fd5fd25d2b65e92a56393fdf4ae14ece Mon Sep 17 00:00:00 2001 From: George Kurelic Date: Fri, 14 Jun 2024 12:51:44 -0500 Subject: [PATCH 54/69] fix deprec (#436) --- flixel/addons/effects/FlxTrail.hx | 3 ++- flixel/addons/nape/FlxNapeTilemap.hx | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/flixel/addons/effects/FlxTrail.hx b/flixel/addons/effects/FlxTrail.hx index 6f5112b1..e7caef35 100644 --- a/flixel/addons/effects/FlxTrail.hx +++ b/flixel/addons/effects/FlxTrail.hx @@ -244,7 +244,8 @@ class FlxTrail extends #if (flixel < "5.7.0") FlxSpriteGroup #else FlxSpriteCont function cacheValue(array:Array, value:T) { array.unshift(value); - FlxArrayUtil.setLength(array, _trailLength); + if (array.length > _trailLength) + array.resize(_trailLength); } public function resetTrail():Void diff --git a/flixel/addons/nape/FlxNapeTilemap.hx b/flixel/addons/nape/FlxNapeTilemap.hx index 49122efd..613841f9 100644 --- a/flixel/addons/nape/FlxNapeTilemap.hx +++ b/flixel/addons/nape/FlxNapeTilemap.hx @@ -42,7 +42,7 @@ class FlxNapeTilemap extends FlxTilemap { super.loadMapFromCSV(MapData, TileGraphic, TileWidth, TileHeight, AutoTile, StartingIndex, DrawIndex, CollideIndex); _binaryData = new Array(); - FlxArrayUtil.setLength(_binaryData, _data.length); + _binaryData.resize(_data.length); return this; } @@ -51,7 +51,7 @@ class FlxNapeTilemap extends FlxTilemap { super.loadMapFromArray(MapData, WidthInTiles, HeightInTiles, TileGraphic, TileWidth, TileHeight, AutoTile, StartingIndex, DrawIndex, CollideIndex); _binaryData = new Array(); - FlxArrayUtil.setLength(_binaryData, _data.length); + _binaryData.resize(_data.length); return this; } @@ -60,7 +60,7 @@ class FlxNapeTilemap extends FlxTilemap { super.loadMapFrom2DArray(MapData, TileGraphic, TileWidth, TileHeight, AutoTile, StartingIndex, DrawIndex, CollideIndex); _binaryData = new Array(); - FlxArrayUtil.setLength(_binaryData, _data.length); + _binaryData.resize(_data.length); return this; } From cdeb0de4e274bbced42656332a8436c25a398984 Mon Sep 17 00:00:00 2001 From: George Kurelic Date: Sat, 15 Jun 2024 18:58:16 -0500 Subject: [PATCH 55/69] fix Nape tilemap for 5.9.0+ (#437) * fix Nape tilemap for 5.9.0+ * update ci --- .github/workflows/main.yml | 5 ++--- flixel/addons/nape/FlxNapeTilemap.hx | 17 +++++++++-------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c1dcd0ff..bbc23ba9 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"] + haxe-version: ["4.2.5", "4.3.4"] target: [html5, hl, neko, flash, cpp] fail-fast: false runs-on: ubuntu-latest @@ -29,9 +29,8 @@ jobs: haxelib install haxelib 4.0.3 haxelib dev flixel-addons . - - uses: HaxeFlixel/setup-flixel@v1 + - uses: HaxeFlixel/setup-flixel@master with: - haxe-version: current flixel-versions: dev target: ${{matrix.target}} run-tests: true diff --git a/flixel/addons/nape/FlxNapeTilemap.hx b/flixel/addons/nape/FlxNapeTilemap.hx index 613841f9..bc8f529f 100644 --- a/flixel/addons/nape/FlxNapeTilemap.hx +++ b/flixel/addons/nape/FlxNapeTilemap.hx @@ -1,13 +1,13 @@ package flixel.addons.nape; -import flixel.addons.nape.FlxNapeSpace; import flixel.FlxG; +import flixel.addons.nape.FlxNapeSpace; import flixel.math.FlxPoint; import flixel.math.FlxRect; +import flixel.system.FlxAssets; +import flixel.tile.FlxBaseTilemap; import flixel.tile.FlxTilemap; import flixel.util.FlxArrayUtil; -import flixel.tile.FlxBaseTilemap; -import flixel.system.FlxAssets; import nape.geom.Vec2; import nape.phys.Body; import nape.phys.BodyType; @@ -100,11 +100,12 @@ class FlxNapeTilemap extends FlxTilemap var polygon:Polygon; for (index in tileIndices) { - var coords:Array = getTileCoords(index, false); - if (coords == null) - continue; - - for (point in coords) + #if (flixel >= "5.9.0") + final points = getAllTilePos(index); + #else + final points = getTileCoords(index, false); + #end + for (point in points) { polygon = new Polygon(vertices, mat); polygon.translate(Vec2.get(point.x, point.y)); From 346dd1284ebe9e6087a957a82b5aec733f7d2a33 Mon Sep 17 00:00:00 2001 From: George Kurelic Date: Thu, 11 Jul 2024 10:38:52 -0400 Subject: [PATCH 56/69] Flixel 5.9.0 compat (#440) --- .../addons/display/FlxExtendedMouseSprite.hx | 23 ++++++++++++++----- flixel/addons/ui/FlxSlider.hx | 14 +++++++---- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/flixel/addons/display/FlxExtendedMouseSprite.hx b/flixel/addons/display/FlxExtendedMouseSprite.hx index b501ff05..a2cebd3d 100644 --- a/flixel/addons/display/FlxExtendedMouseSprite.hx +++ b/flixel/addons/display/FlxExtendedMouseSprite.hx @@ -183,6 +183,8 @@ class FlxExtendedMouseSprite extends FlxSprite * Returns how many vertical pixels the mouse pointer is inside this sprite from the top left corner. Returns -1 if outside. */ public var mouseY(get, never):Int; + var viewX(get, never):Int; + var viewY(get, never):Int; #end var _snapOnDrag:Bool = false; @@ -549,14 +551,14 @@ class FlxExtendedMouseSprite extends FlxSprite if (_allowHorizontalDrag) { #if FLX_MOUSE - x = Math.floor(FlxG.mouse.screenX + scrollFactor.x * (FlxG.mouse.x - FlxG.mouse.screenX)) - _dragOffsetX; + x = Math.floor(viewX + scrollFactor.x * (FlxG.mouse.x - viewX)) - _dragOffsetX; #end } if (_allowVerticalDrag) { #if FLX_MOUSE - y = Math.floor(FlxG.mouse.screenY + scrollFactor.y * (FlxG.mouse.y - FlxG.mouse.screenY)) - _dragOffsetY; + y = Math.floor(viewY + scrollFactor.y * (FlxG.mouse.y - viewY)) - _dragOffsetY; #end } @@ -657,8 +659,8 @@ class FlxExtendedMouseSprite extends FlxSprite #if FLX_MOUSE if (_dragFromPoint == false) { - _dragOffsetX = Math.floor(FlxG.mouse.screenX + scrollFactor.x * (FlxG.mouse.x - FlxG.mouse.screenX) - x); - _dragOffsetY = Math.floor(FlxG.mouse.screenY + scrollFactor.y * (FlxG.mouse.y - FlxG.mouse.screenY) - y); + _dragOffsetX = Math.floor(viewX + scrollFactor.x * (FlxG.mouse.x - viewX) - x); + _dragOffsetY = Math.floor(viewY + scrollFactor.y * (FlxG.mouse.y - viewY) - y); } else { @@ -828,8 +830,8 @@ class FlxExtendedMouseSprite extends FlxSprite #if FLX_MOUSE function get_mouseOver():Bool { - return FlxMath.pointInCoordinates(Math.floor(FlxG.mouse.screenX + scrollFactor.x * (FlxG.mouse.x - FlxG.mouse.screenX)), - Math.floor(FlxG.mouse.screenY + scrollFactor.y * (FlxG.mouse.y - FlxG.mouse.screenY)), Math.floor(x), Math.floor(y), Math.floor(width), + return FlxMath.pointInCoordinates(Math.floor(viewX + scrollFactor.x * (FlxG.mouse.x - viewX)), + Math.floor(viewY + scrollFactor.y * (FlxG.mouse.y - viewY)), Math.floor(x), Math.floor(y), Math.floor(width), Math.floor(height)); } @@ -852,6 +854,15 @@ class FlxExtendedMouseSprite extends FlxSprite return -1; } + inline function get_viewX():Int + { + return #if (flixel < version("5.9.0")) FlxG.mouse.screenX #else FlxG.mouse.viewX #end; + } + + inline function get_viewY():Int + { + return #if (flixel < version("5.9.0")) FlxG.mouse.screenY #else FlxG.mouse.viewY #end; + } #end inline function get_rect():FlxRect diff --git a/flixel/addons/ui/FlxSlider.hx b/flixel/addons/ui/FlxSlider.hx index 9522d8e4..c8b97410 100644 --- a/flixel/addons/ui/FlxSlider.hx +++ b/flixel/addons/ui/FlxSlider.hx @@ -271,11 +271,17 @@ class FlxSlider extends #if (flixel < "5.7.0") FlxSpriteGroup #else FlxSpriteCon override public function update(elapsed:Float):Void { // Clicking and sound logic - #if (flixel >= "5.7.0") + #if (flixel >= version("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 (flixel >= version("5.9.0")) + final viewX = FlxG.mouse.viewX; + final viewY = FlxG.mouse.viewY; + #else + final viewX = FlxG.mouse.screenX; + final viewY = FlxG.mouse.screenY; + #end + if (FlxMath.pointInFlxRect(viewX, viewY, _bounds)) { if (hoverAlpha != 1) { @@ -293,7 +299,7 @@ class FlxSlider extends #if (flixel < "5.7.0") FlxSpriteGroup #else FlxSpriteCon if (FlxG.mouse.pressed) { - handle.x = FlxG.mouse.screenX; + handle.x = viewX; updateValue(); #if FLX_SOUND_SYSTEM From 003353355ec8cdcc65c1ec986c4611b89762dd8e Mon Sep 17 00:00:00 2001 From: rich <87835336+richTrash21@users.noreply.github.com> Date: Mon, 15 Jul 2024 19:22:34 +0400 Subject: [PATCH 57/69] remove deprecation warning on flixel 5.9.0 (#441) --- flixel/addons/transition/FlxTransitionSprite.hx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/flixel/addons/transition/FlxTransitionSprite.hx b/flixel/addons/transition/FlxTransitionSprite.hx index f75b4120..a70b5901 100644 --- a/flixel/addons/transition/FlxTransitionSprite.hx +++ b/flixel/addons/transition/FlxTransitionSprite.hx @@ -143,7 +143,12 @@ class FlxTransitionSprite extends FlxSprite } animation.play(anim); + #if (flixel < version("5.9.0")) animation.finishCallback = onFinishAnim; + #else + if (!animation.onFinish.has(onFinishAnim)) + animation.onFinish.add(onFinishAnim); + #end status = Status; } From 8649eb692a0cfb95b2f0bee2afd094dae13415e8 Mon Sep 17 00:00:00 2001 From: Mihai Alexandru <77043862+MAJigsaw77@users.noreply.github.com> Date: Tue, 3 Sep 2024 16:29:52 +0000 Subject: [PATCH 58/69] Refactor Shader Metadata Handling and Improve Readability. (#442) * Add `FlxRuntimeShaderMacro`. * Improve `FlxRuntimeShader`. * Oops * Oops v2 * More readable `toString`. * Fix grammar. * It doesn't seem to trace anything nice so revert. * Misspell fix --- flixel/addons/display/FlxRuntimeShader.hx | 278 +++++------------- .../system/macros/FlxRuntimeShaderMacro.hx | 78 +++++ 2 files changed, 156 insertions(+), 200 deletions(-) create mode 100644 flixel/addons/system/macros/FlxRuntimeShaderMacro.hx diff --git a/flixel/addons/display/FlxRuntimeShader.hx b/flixel/addons/display/FlxRuntimeShader.hx index 8134f9c5..8f584785 100644 --- a/flixel/addons/display/FlxRuntimeShader.hx +++ b/flixel/addons/display/FlxRuntimeShader.hx @@ -5,7 +5,9 @@ package flixel.addons.display; #error "FlxRuntimeShader isn't available with nme or flash." #end #else +import flixel.addons.system.macros.FlxRuntimeShaderMacro; import flixel.graphics.tile.FlxGraphicsShader; +import flixel.util.FlxStringUtil; #if lime import lime.utils.Float32Array; #end @@ -28,140 +30,6 @@ using StringTools; */ class FlxRuntimeShader extends FlxGraphicsShader { - private static final BASE_VERTEX_HEADER:String = "attribute float openfl_Alpha; - attribute vec4 openfl_ColorMultiplier; - attribute vec4 openfl_ColorOffset; - attribute vec4 openfl_Position; - attribute vec2 openfl_TextureCoord; - - varying float openfl_Alphav; - varying vec4 openfl_ColorMultiplierv; - varying vec4 openfl_ColorOffsetv; - varying vec2 openfl_TextureCoordv; - - uniform mat4 openfl_Matrix; - uniform bool openfl_HasColorTransform; - uniform vec2 openfl_TextureSize;"; - - private static final BASE_VERTEX_BODY:String = "openfl_Alphav = openfl_Alpha; - openfl_TextureCoordv = openfl_TextureCoord; - - if (openfl_HasColorTransform) - { - openfl_ColorMultiplierv = openfl_ColorMultiplier; - openfl_ColorOffsetv = openfl_ColorOffset / 255.0; - } - - gl_Position = openfl_Matrix * openfl_Position;"; - - private static final BASE_VERTEX_SOURCE:String = "#pragma header - - attribute float alpha; - attribute vec4 colorMultiplier; - attribute vec4 colorOffset; - uniform bool hasColorTransform; - - void main(void) - { - #pragma body - - openfl_Alphav = openfl_Alpha * alpha; - - if (hasColorTransform) - { - openfl_ColorOffsetv = colorOffset / 255.0; - openfl_ColorMultiplierv = colorMultiplier; - } - }"; - - private static final BASE_FRAGMENT_HEADER:String = "varying float openfl_Alphav; - varying vec4 openfl_ColorMultiplierv; - varying vec4 openfl_ColorOffsetv; - varying vec2 openfl_TextureCoordv; - - uniform bool openfl_HasColorTransform; - uniform vec2 openfl_TextureSize; - uniform sampler2D bitmap; - - uniform bool hasTransform; - uniform bool hasColorTransform; - - vec4 flixel_texture2D(sampler2D bitmap, vec2 coord) - { - vec4 color = texture2D(bitmap, coord); - - if (!hasTransform) - { - return color; - } - - if (color.a == 0.0) - { - return vec4(0.0, 0.0, 0.0, 0.0); - } - - if (!hasColorTransform) - { - return color * openfl_Alphav; - } - - color = vec4(color.rgb / color.a, color.a); - - mat4 colorMultiplier = mat4(0); - colorMultiplier[0][0] = openfl_ColorMultiplierv.x; - colorMultiplier[1][1] = openfl_ColorMultiplierv.y; - colorMultiplier[2][2] = openfl_ColorMultiplierv.z; - colorMultiplier[3][3] = openfl_ColorMultiplierv.w; - - color = clamp(openfl_ColorOffsetv + (color * colorMultiplier), 0.0, 1.0); - - if (color.a > 0.0) - { - return vec4(color.rgb * color.a * openfl_Alphav, color.a * openfl_Alphav); - } - - return vec4(0.0, 0.0, 0.0, 0.0); - }"; - - private static final BASE_FRAGMENT_BODY:String = "vec4 color = texture2D(bitmap, openfl_TextureCoordv); - - if (color.a == 0.0) - { - gl_FragColor = vec4 (0.0, 0.0, 0.0, 0.0); - } - else if (openfl_HasColorTransform) - { - color = vec4 (color.rgb / color.a, color.a); - - mat4 colorMultiplier = mat4 (0); - colorMultiplier[0][0] = openfl_ColorMultiplierv.x; - colorMultiplier[1][1] = openfl_ColorMultiplierv.y; - colorMultiplier[2][2] = openfl_ColorMultiplierv.z; - colorMultiplier[3][3] = 1.0; // openfl_ColorMultiplierv.w; - - color = clamp (openfl_ColorOffsetv + (color * colorMultiplier), 0.0, 1.0); - - if (color.a > 0.0) - { - gl_FragColor = vec4 (color.rgb * color.a * openfl_Alphav, color.a * openfl_Alphav); - } - else - { - gl_FragColor = vec4 (0.0, 0.0, 0.0, 0.0); - } - } - else - { - gl_FragColor = color * openfl_Alphav; - }"; - - private static final BASE_FRAGMENT_SOURCE:String = "#pragma header - - void main(void) - { - gl_FragColor = flixel_texture2D(bitmap, openfl_TextureCoordv); - }"; - /** * Creates a `FlxRuntimeShader` with specified shader sources. * If none is provided, it will use the default shader sources. @@ -174,12 +42,12 @@ class FlxRuntimeShader extends FlxGraphicsShader if (fragmentSource != null && fragmentSource.length > 0) glFragmentSource = fragmentSource; else - glFragmentSource = BASE_FRAGMENT_SOURCE; + glFragmentSource = FlxRuntimeShaderMacro.retrieveMetadata('glFragmentSource', false); if (vertexSource != null && vertexSource.length > 0) glVertexSource = vertexSource; else - glVertexSource = BASE_VERTEX_SOURCE; + glVertexSource = FlxRuntimeShaderMacro.retrieveMetadata('glVertexSource', false); super(); } @@ -192,15 +60,15 @@ class FlxRuntimeShader extends FlxGraphicsShader */ public function setFloat(name:String, value:Float):Void { - var prop:ShaderParameter = Reflect.field(data, name); + final shaderParameter:ShaderParameter = Reflect.field(data, name); - if (prop == null) + if (shaderParameter == null) { - FlxG.log.warn('Shader float property "$name" not found.'); + FlxG.log.warn('Shader float parameter "$name" not found.'); return; } - prop.value = [value]; + shaderParameter.value = [value]; } /** @@ -210,15 +78,15 @@ class FlxRuntimeShader extends FlxGraphicsShader */ public function getFloat(name:String):Null { - var prop:ShaderParameter = Reflect.field(data, name); + final shaderParameter:ShaderParameter = Reflect.field(data, name); - if (prop == null) + if (shaderParameter == null) { - FlxG.log.warn('Shader float property "$name" not found.'); + FlxG.log.warn('Shader float parameter "$name" not found.'); return null; } - return prop.value[0]; + return shaderParameter.value[0]; } /** @@ -229,15 +97,15 @@ class FlxRuntimeShader extends FlxGraphicsShader */ public function setFloatArray(name:String, value:Array):Void { - var prop:ShaderParameter = Reflect.field(data, name); + final shaderParameter:ShaderParameter = Reflect.field(data, name); - if (prop == null) + if (shaderParameter == null) { - FlxG.log.warn('Shader float[] property "$name" not found.'); + FlxG.log.warn('Shader float[] parameter "$name" not found.'); return; } - prop.value = value; + shaderParameter.value = value; } /** @@ -247,15 +115,15 @@ class FlxRuntimeShader extends FlxGraphicsShader */ public function getFloatArray(name:String):Null> { - var prop:ShaderParameter = Reflect.field(data, name); + final shaderParameter:ShaderParameter = Reflect.field(data, name); - if (prop == null) + if (shaderParameter == null) { - FlxG.log.warn('Shader float[] property "$name" not found.'); + FlxG.log.warn('Shader float[] parameter "$name" not found.'); return null; } - return prop.value; + return shaderParameter.value; } /** @@ -266,15 +134,15 @@ class FlxRuntimeShader extends FlxGraphicsShader */ public function setInt(name:String, value:Int):Void { - var prop:ShaderParameter = Reflect.field(data, name); + final shaderParameter:ShaderParameter = Reflect.field(data, name); - if (prop == null) + if (shaderParameter == null) { - FlxG.log.warn('Shader int property "$name" not found.'); + FlxG.log.warn('Shader int parameter "$name" not found.'); return; } - prop.value = [value]; + shaderParameter.value = [value]; } /** @@ -284,15 +152,15 @@ class FlxRuntimeShader extends FlxGraphicsShader */ public function getInt(name:String):Null { - var prop:ShaderParameter = Reflect.field(data, name); + final shaderParameter:ShaderParameter = Reflect.field(data, name); - if (prop == null) + if (shaderParameter == null) { - FlxG.log.warn('Shader int property "$name" not found.'); + FlxG.log.warn('Shader int parameter "$name" not found.'); return null; } - return prop.value[0]; + return shaderParameter.value[0]; } /** @@ -303,15 +171,15 @@ class FlxRuntimeShader extends FlxGraphicsShader */ public function setIntArray(name:String, value:Array):Void { - var prop:ShaderParameter = Reflect.field(data, name); + final shaderParameter:ShaderParameter = Reflect.field(data, name); - if (prop == null) + if (shaderParameter == null) { - FlxG.log.warn('Shader int[] property "$name" not found.'); + FlxG.log.warn('Shader int[] parameter "$name" not found.'); return; } - prop.value = value; + shaderParameter.value = value; } /** @@ -321,15 +189,15 @@ class FlxRuntimeShader extends FlxGraphicsShader */ public function getIntArray(name:String):Null> { - var prop:ShaderParameter = Reflect.field(data, name); + final shaderParameter:ShaderParameter = Reflect.field(data, name); - if (prop == null) + if (shaderParameter == null) { - FlxG.log.warn('Shader int[] property "$name" not found.'); + FlxG.log.warn('Shader int[] parameter "$name" not found.'); return null; } - return prop.value; + return shaderParameter.value; } /** @@ -340,15 +208,15 @@ class FlxRuntimeShader extends FlxGraphicsShader */ public function setBool(name:String, value:Bool):Void { - var prop:ShaderParameter = Reflect.field(data, name); + final shaderParameter:ShaderParameter = Reflect.field(data, name); - if (prop == null) + if (shaderParameter == null) { - FlxG.log.warn('Shader bool property "$name" not found.'); + FlxG.log.warn('Shader bool parameter "$name" not found.'); return; } - prop.value = [value]; + shaderParameter.value = [value]; } /** @@ -358,15 +226,15 @@ class FlxRuntimeShader extends FlxGraphicsShader */ public function getBool(name:String):Null { - var prop:ShaderParameter = Reflect.field(data, name); + final shaderParameter:ShaderParameter = Reflect.field(data, name); - if (prop == null) + if (shaderParameter == null) { - FlxG.log.warn('Shader bool property "$name" not found.'); + FlxG.log.warn('Shader bool parameter "$name" not found.'); return null; } - return prop.value[0]; + return shaderParameter.value[0]; } /** @@ -377,15 +245,15 @@ class FlxRuntimeShader extends FlxGraphicsShader */ public function setBoolArray(name:String, value:Array):Void { - var prop:ShaderParameter = Reflect.field(data, name); + final shaderParameter:ShaderParameter = Reflect.field(data, name); - if (prop == null) + if (shaderParameter == null) { - FlxG.log.warn('Shader bool[] property "$name" not found.'); + FlxG.log.warn('Shader bool[] parameter "$name" not found.'); return; } - prop.value = value; + shaderParameter.value = value; } /** @@ -395,57 +263,65 @@ class FlxRuntimeShader extends FlxGraphicsShader */ public function getBoolArray(name:String):Null> { - var prop:ShaderParameter = Reflect.field(data, name); + final shaderParameter:ShaderParameter = Reflect.field(data, name); - if (prop == null) + if (shaderParameter == null) { - FlxG.log.warn('Shader bool[] property "$name" not found.'); + FlxG.log.warn('Shader bool[] parameter "$name" not found.'); return null; } - return prop.value; + return shaderParameter.value; } /** - * Modify a bitmap data parameter of the shader. + * Modify a bitmap data input of the shader. * * @param name The name of the parameter to modify. * @param value The new value to use. */ public function setSampler2D(name:String, value:BitmapData):Void { - var prop:ShaderInput = Reflect.field(data, name); + final shaderInput:ShaderInput = Reflect.field(data, name); - if (prop == null) + if (shaderInput == null) { - FlxG.log.warn('Shader sampler2D property "$name" not found.'); + FlxG.log.warn('Shader sampler2D input "$name" not found.'); return; } - prop.input = value; + shaderInput.input = value; } /** - * Retrieve a bitmap data parameter of the shader. + * Retrieve a bitmap data input of the shader. * * @param name The name of the parameter to retrieve. * @return The value of the parameter. */ public function getSampler2D(name:String):Null { - var prop:ShaderInput = Reflect.field(data, name); + final shaderInput:ShaderInput = Reflect.field(data, name); - if (prop == null) + if (shaderInput == null) { - FlxG.log.warn('Shader sampler2D property "$name" not found.'); + FlxG.log.warn('Shader sampler2D input "$name" not found.'); return null; } - return prop.input; + return shaderInput.input; + } + + /** + * Convert the shader to a readable string name. Useful for debugging. + */ + public function toString():String + { + return FlxStringUtil.getDebugString([for (field in Reflect.fields(data)) LabelValuePair.weak(field, Reflect.field(data, field))]); } - // Overrides - @:noCompletion private override function __processGLData(source:String, storageType:String):Void + @:noCompletion + private override function __processGLData(source:String, storageType:String):Void { var lastMatch = 0, position, regex, name, type; @@ -630,10 +506,11 @@ class FlxRuntimeShader extends FlxGraphicsShader } } - @:noCompletion private override function set_glFragmentSource(value:String):String + @:noCompletion + private override function set_glFragmentSource(value:String):String { if (value != null) - value = value.replace("#pragma header", BASE_FRAGMENT_HEADER).replace("#pragma body", BASE_FRAGMENT_BODY); + value = value.replace("#pragma header", FlxRuntimeShaderMacro.retrieveMetadata('glFragmentHeader')).replace("#pragma body", FlxRuntimeShaderMacro.retrieveMetadata('glFragmentBody')); if (value != __glFragmentSource) __glSourceDirty = true; @@ -641,10 +518,11 @@ class FlxRuntimeShader extends FlxGraphicsShader return __glFragmentSource = value; } - @:noCompletion private override function set_glVertexSource(value:String):String + @:noCompletion + private override function set_glVertexSource(value:String):String { if (value != null) - value = value.replace("#pragma header", BASE_VERTEX_HEADER).replace("#pragma body", BASE_VERTEX_BODY); + value = value.replace("#pragma header", FlxRuntimeShaderMacro.retrieveMetadata('glVertexHeader')).replace("#pragma body", FlxRuntimeShaderMacro.retrieveMetadata('glVertexBody')); if (value != __glVertexSource) __glSourceDirty = true; diff --git a/flixel/addons/system/macros/FlxRuntimeShaderMacro.hx b/flixel/addons/system/macros/FlxRuntimeShaderMacro.hx new file mode 100644 index 00000000..91c9630b --- /dev/null +++ b/flixel/addons/system/macros/FlxRuntimeShaderMacro.hx @@ -0,0 +1,78 @@ +package flixel.addons.system.macros; + +import haxe.macro.Context; +import haxe.macro.Expr; +import haxe.macro.Type; + +using haxe.macro.ExprTools; + +class FlxRuntimeShaderMacro +{ + /** + * Retrieves the value of a specified metadata tag (only `String` values) from the current class + * or any of its superclasses. The function searches the fields of the class + * for the specified metadata and returns its value as a macro expression. + * If `overwrite` is set to `false`, it will use the first non-null `String` value + * found and ignore any subsequent values. + * + * @param metaName The name of the metadata tag to retrieve. + * @param overwrite If `true`, the metadata value will be concatenated when found; if `false`, only the first non-null value will be used. + * @return The value of the specified metadata as an expression, or `null` if not found. + */ + public static macro function retrieveMetadata(metaName:String, overwrite:Bool = true):Expr + { + var result:String = null; + + final localClass:ClassType = Context.getLocalClass().get(); + + result = checkClassForMetadata(localClass, metaName, overwrite, result); + + var parent:ClassType = localClass.superClass != null ? localClass.superClass.t.get() : null; + + while (parent != null) + { + result = checkClassForMetadata(parent, metaName, overwrite, result); + + parent = parent.superClass != null ? parent.superClass.t.get() : null; + } + + // Context.info('Retrieving $metaName: $result', Context.currentPos()); + + return macro $v{result}; + } + + #if macro + @:noCompletion + private static function checkClassForMetadata(classType:ClassType, metaName:String, overwrite:Bool, currentResult:String):String + { + var result:String = currentResult; + + for (field in [classType.constructor.get()].concat(classType.fields.get())) + { + for (meta in field.meta.get()) + { + if (meta.name == metaName || meta.name == ':' + metaName) + { + final value:Dynamic = meta.params[0].getValue(); + + if (!(value is String)) + continue; + + if (overwrite) + result = result == null ? value : '$value\n$result'; + else if (result == null) + { + result = value; + break; + } + } + } + + if (!overwrite && result != null) + break; + } + + return result; + } + #end +} From bbb020a19895973e33ea55b5ca0e9c2d6198bc21 Mon Sep 17 00:00:00 2001 From: Vortex <73261680+Vortex2Oblivion@users.noreply.github.com> Date: Fri, 27 Sep 2024 14:46:26 +0000 Subject: [PATCH 59/69] oxipng all assets (#445) --- assets/images/napeDebug.png | Bin 280 -> 143 bytes assets/images/transitions/circle.png | Bin 824 -> 299 bytes .../images/transitions/diagonal_gradient.png | Bin 3812 -> 730 bytes assets/images/transitions/diamond.png | Bin 788 -> 236 bytes assets/images/transitions/square.png | Bin 383 -> 209 bytes 5 files changed, 0 insertions(+), 0 deletions(-) diff --git a/assets/images/napeDebug.png b/assets/images/napeDebug.png index fd7746890a9fe93fd176548ad6d3081e358cbcf7..04e1230525ad684674074e3af692661e838f3f8c 100644 GIT binary patch delta 125 zcmV-@0D}LR0*?WZ8FmB!000A}zpVfO09HvvK~#9!V_;zT4+MW>8Gr!7WYtnNJN7(=w00000NkvXXu0mjfg4r~| delta 264 zcmeBYoWV3fvYw5BfnnvEay1~umgMd30;GZ9r}OT5AjMhW5n0T@z%2~Ij105pNB{-d zOFVsD+3)g*@$*=17M?f(C?uO15>euupPQSSR|4cRFgO>bCYGe8D3oWGWGJ|M`Ua%v zrLqIXYdl>XLnJQup5MsZY#`F|@O8arWCNp-i&;X`nge1z6LfDVcwY#000J1OjJex|NsC0|5beTYybcN0(4SNQ~v{=`V;RB8b*lu9GfCW6Gzzgg(pdbZ^z)66&$bg1?M}Gt47~qkSdo==m9b|;J zFu(}(F?8hFj8WoJFX2ctAd z1~eoEMj_HXv@s-}xgL{93XH;fxFdQThr$Y delta 813 zcmV+|1JeAf0=Nc{7=H)`0000h7Q;0F0004VQb$4nuFf3k0008=NklNv73QnbziiVbaIvRNbDQAU?_U4Hq8Q2_R5I>l<~H>BCD)Kkh+@?ZE_s z6aomei<&@us`afArVlS8--8fQd#?upfGPdSZU72de?BkRM_)fvFZvoiH>9I$M{I_B zH6k}+n?C%QfPYX^fKW;F1mbng=;!v>lx%dsPy`Up zS~njN^?E$E_jRgl{Fz4(8L!d0`7=Y6pAG0j0HM`h;OH4d&Rnli(VpA$S^$qAfYh`N9uYw#;|PQpjzEBL0)NOg(G!SQ%`;!CDC-`KteZeb zyO#!_8v*3J?F8b5J6A)++J%PzM0?NDx zCG#k6w41r%@k~IVhSoRg)lKg1g<*s#%ux>}F!4RufF>q@Ks|eJ+PnW}opA(ockR|5 z96`nQU;~<%00JC2yGV>Og%N=M8!-Txz)VU20a_d_7(MQ9m@NQh9YOW1ebj>^s0j%m rKqe&uP`fGtXvQO`jN0!#qy~V$DG=5Gqx!;;00000NkvXXu0mjf{V#S+ diff --git a/assets/images/transitions/diagonal_gradient.png b/assets/images/transitions/diagonal_gradient.png index 9555ea7d1f3e964097e65ad71352654633cd1272..b14b8fe71cc12f843343f784eb9215af52e509f6 100644 GIT binary patch literal 730 zcmeAS@N?(olHy`uVBq!ia0y~yV6+3W8#tJObvddIOO z$S?T+@9&@AzkdGs{_X3R&!0Yic>nJ0o7b;izIguZ>681r+nejF%Zu}~)05+)!-M_3 z-JR{N&5iZ7)s^L?#fAB~*_j#U3w2ln1FO~3#WAGf*4qn?yayZvj%={h{9`!%@Uxo| zO*i-3wtsuIyXsQL`@F@r8_jPCR}XD!?{@23vmL70-b!vszc9~n5HaNa_9-#slqRzS PW0%3x)z4*}Q$iB}y{N6y literal 3812 zcmW-kc|6nq1IITxw$PBHlns4dNnsT~<=hxjxyqd@$DFyTkuMW-Bv(Y_h*Dbagdt~g z<(6_xu8EAW`3k?!XaDT++H=o6AMd>%pMOR&zJcRCDtZ(Gf$$pWV@)9ts0OejVVuBg zYBI;a5XezAJO*QI?Cu-r8{qDHPuu{55x?i}>x%bsfk5<0xlcpP&Bujf2Ph%;3;GlV z!gG1kz?qK6%vJP{JL0nA?+wh&csKO6_W8Wkq)1bPsH=v9Ry8G z!qAns0~Z!3nVB;vw{XuF6o$IndiYp9EbzH0th%R#XHZn5I7SG~=BYtFPx?v}Y+ z&1-tLHubMRkGa;4jp;3Ry4nk^H2WM}Cp~D;e;=jE;3?b=uh`G9zpoBSv@-DyCRB8+ zbL2atA)AcmiHis}ak&+ny%q~b0clCfK>Tw#TB*Cg|MH^0W#?SfLBS!7uCg`CNbH~; z$Reh4(^>>ejxNvDR}7gA#}Mwja;9|@oZ1hIJM^2if6=B$OlzSAgcio#8%*~LBNYb! znXrYbe#56q4qI!?T(Rvni#5!HZtlqo$C&1ah**N80Sg9-#_RUg?ORC!2H&PZVXf@3GTZ8qbcWTR+*G&gnao{%j9 z75$ycO%GyTzRIQ<>&73+$1hs==!67MJ1-ntn8Hp>F2ls97`{Z}wdH|B@eMTg13^?qC9Zh`96huCg|5U-IcB3-jTJKz5FwSq-C!_ z{(6C_I3J9?&Wv7i(Ts!Q2~j;R=je@2tYfN@r($u|e%9^YuwHRj9&|#7lTbOQC6|}@ zQ<9KFLivM=uJWaF%!J>n&1wEu@#wCwxkA6IwotM_h+v4Y3Nfdp?`JXHI`j%bJTGaW zBa?cHZpVcFRgK6Kzy4K1m9G`nO-v%5)#0WJP$j5BDf;FzlLFBs+c{1rp$*lIqkiek z$Nyl4WIm=i>FW#y4>=Bn4XF>wD?cl{9xRPZB!*-Y7=<~+AzS1{L0o*Fk7?U=dU zb-AnH(&iFy*Yobc=f_|9vM=|=J~fmt%FUlDpk$go4M_R<**ncM2D9eJ!Emz z#JVU@zw{>lww3O;YyZQ9z2DSbzzb!^R~c3s#(c5Lkh>NCrs%9ijn4M-6?FZ%shB*& z_l1nFZX@XedwNfJwDU{z;qaE7dYV^Ff5b&A{v+=X7wGudShbW z)%WfTr-vgE{-yn<{X>t6osX>?Gm2G<<;T@KKmV!S#V>P7ro@ageB6!Ktu~2L{ zT4j$?rUh?B_+$Wdgn`l$MG^&EA##zgv6i8{>?ny%3HTXcM%74S9apy3=NiAI28W z7Q&%%bO>%Ow&koSttwk5&BVu9=||}M%1T|lyyd=}qc~n(S zv+TBXUF}v4w8j1ytV8r_xvB?To|cKQ|I5>pR1>@Xe65%4aMSO!>cVppdn|F2*o}>C zw&Wr zBweX;(r5ekD4L)d;Vhm0QMt-YOK9I{8y*ys6H{dM*y@s%Z&h2>%|-nsy8nOv+W{XI zZp?=*hBt85JgOPvnJ?Qe$d9R`f<;)3$~g~pFG=Al88xiryibFRFJ(8 zN|AFivncSVK5DJ#yOWcX@J~Ebx6Nkt!-$Wr_kz#bjBADWdhN}Q)j3b85~&O+l%ZAe zc$3mz$x2Sl8vOfSPg&2g)t1%SwYsWd{8EZPZL@K+!VcOnDZeb#A@n|^>vxki-pZ;W zwj5XI_VP>fn}GL=(_#-a&1G)Qkp14_r(RY2esB7?zq*g%dXA_bIXnJzq)GF$dgzD# zw`9tlhNexvMdPu8SG-hS%8YW8w}-jcIsD(ytdP)o{m&_R(m5q1MTWSZY^tl{pOK0z zXO*UaLvmHe>tb@on6>}u(;~=+JK;YVAvc)0%NpIP-!`Mi5POrd-W_Yk4}A8FaHd`Q zZstp~ax-RAb~|?7nxcoH%<4&6HoDU7OTR$BaGsrNW{A%Yp>vnUO%my>cWyx0CN_q? zm8pAmm^xD|pQ(Pqel>`u9@0VmLVFu*ansJ(_E()xIE6Cs=KY$?+ZU7nz1#cF<;AJy zJ2Aa1YO59+{29O8dYzGz>AU-*KH|Z*wNF=i)_;gSK8gI;({v^5!uE8}o)u#W zM^US<#PU40Qn5^j3v2X|qD&ZS^`%&zL?Ji|#qu0kBVR19032mxu{ZkiHN*m0H_0o9|)p} z2qX&tMg$1bh=|`H5Ce>05NHz-J}jWmoOK4lCn92c958YL!y5z!M8q8y0E~wq=q4f# z#sI?(Fg^r_V%H^Gxn^qG&fFIf&{&SeZJn1Utdhl$gYtYD!JwA`Lp68+Jf4^=25K&? zT|VFyKw+pWcz|I_&AmLdR81|R?h)*1X-yWBy67lt|m7A{K=62ZcEpujo< zx)o=01}&S^1h3#I1_)G%bicPCXoI0Xus}L}BZURvsCDp%s>aYa zSmzjqq29AV27QCo7>1)Bvd%%IZX1K%z*L3idK87seRz6Shz Og&64Gz>;+wqW%wRQEsFF diff --git a/assets/images/transitions/diamond.png b/assets/images/transitions/diamond.png index 4abb5cc8869a3ffa7fe7d12fb5a015137da0f007..87f8100ab8dbc19b3fad33f36e6f6604111eada1 100644 GIT binary patch delta 220 zcmbQj_J(nSL_H%j0|SHLjleP>#TMWb;`$#9LTkR}07aNeg8YL2Gd$gH;05GO_H=O! zskpWE+D6_M0|C~Hjw~%x95kn}Ee+&S6%bPR=bCZYS;~er;{2wkrj?gX)sN4}sb$)k zV3%-b0lUKgUDKb;nN;g>P0w6M-N%|oyM#gG=;Y8K8%|eMk*NV8PJtKoFUZ{xcFl{_YcORvy~=E{XS9eSYFTf&JBe%k>}aKW`YtQ0J@1USKjm`x*0_dh7WW zeN$ySpRY(MvpF7e>`J!9SGikH>t7U#2r!7+-LLuo(KB6umBm7wZIRjJ8@CJ7rt`2Vo&WK4KQk9cff|p?`5dF}#)$K23UM7wOji;W zvWz?T%BGi{Oi=i==ijIMjI1mx4mx}}qqbS1<7*BZQ~%7c`t!k@`9tSq4t9rJFch%s-R zch-S{e{sVcUgp5ro^Re-Z1!ejo_PFe|8<}kH}gf~*=Ldzu5Fg&c#x{0@I3+9MLYg9 zCW=h3LUJ{O&8e5HEsZPAs(dS(b5pgs@x~ZH_va&ER$eeh|`sDTb>qqWQoo~Bw zyAj0uJu9ylyt3VL`oBPfcwrUe%qOpBzn_2S_vHJk-|x-zP4k_*ce3eM^Ep-g{$hfv z91<>!JK33o;qIL5{*$3C(BWKb<4d4oLxa~hd3Zh;iA>m>m;evCgijjs6}DU)s|*Zm zH=opDOS7Hb$SCK=cu-bi20Y+q*qmZN7U)o*#p45xg2?k}2_LLP1m^Id+Sb6tB$Aj= zl{Pt&=S-CubMx^)hXyMipIo(#+aI6NljQM{dz#EFBJjXRVg@*LH_tnJU=Jk1m%$@k z?fmQ0$4fO87_yL@B%SCs$& diff --git a/assets/images/transitions/square.png b/assets/images/transitions/square.png index a6667f2c76b07cdfd9cf702f8b6b70fc53df780a..be99972044382c2fb9b491e78f12d64e16dda47e 100644 GIT binary patch delta 193 zcmey*bdhm_L_H%j0|SHLjleP>#TMWb;`$#9LTkR}07aNeg8YL2Gd$gH;05GWc)B=- zRNOjxZKEKApor_mY!)X~4cE*m%S2Q;SdZlinlETDZhmiDQ^c6iz~`vQyvRvSrB&wy z*UbQtq6Jz{oQgR-maupBXiS``vT2h`*~Akog{*eIWlY-knEzV*MtL*)Z|~(7^fSqO r*~!%g{66*J>C@~h;=BGw9pK-kJIklw(Ut8$M=*H0`njxgN@xNAiv3Lf delta 368 zcmcb}_@8NlL_G%^0|SG$*kMy3#aJBV?!>U}oXkrg+tSm;F{EP7+q;%RhYSQ<9T)8Q zKh?K|nfcf!Gvl!DtV`bP*J9npf4G2|VVAHJ!}$}385a}>3KsBNm8&=~ytsQ)P{8h= zB!>Wlk%cx>PrVQmOT+fX$_IWJ3n?({lo4e-Ha~=gfkF@T8G|mb=P>xk zFh#-P+H8=jhE}dFl<>Zr@-Lgcy)e)O*M#SR+;pJv0*BUhwmfyhD$(G zGLP^x%;pr(60~O!S9C~_{K&jPnUU#dr~HE=77hdVKMd^x3Jzh9*!6rG7;1#<3k(>U zCUpN;$PM(4`NzYVEF27y9rMoty;-GR#{{H0F6aK)!*IAyq}kb3cm^;`89ZJ6T-G@y GGywn@-GImd From 34553216f635bd450a33a1edd243b5aedfd52ed3 Mon Sep 17 00:00:00 2001 From: George Kurelic Date: Mon, 30 Sep 2024 11:29:12 -0500 Subject: [PATCH 60/69] Refactor FlxPieDial, add FlxRadialGauge (#444) * refactor FlxPieDial, add FlxPieGauge * add FlxPieGuageShape, rename makePieDialGraphic * remove guages on flash * fix spelling and rename FlxPieGuage to FlxRadialGauge * rename makePieDialGraphic to makeShapeGraphic * use floats * improve doc --- flixel/addons/display/FlxPieDial.hx | 522 ++++++++++++++---------- flixel/addons/display/FlxRadialGauge.hx | 155 +++++++ 2 files changed, 462 insertions(+), 215 deletions(-) create mode 100644 flixel/addons/display/FlxRadialGauge.hx diff --git a/flixel/addons/display/FlxPieDial.hx b/flixel/addons/display/FlxPieDial.hx index 0c50c9da..e5e8d382 100644 --- a/flixel/addons/display/FlxPieDial.hx +++ b/flixel/addons/display/FlxPieDial.hx @@ -1,18 +1,23 @@ package flixel.addons.display; import flixel.FlxSprite; +import flixel.graphics.FlxGraphic; +import flixel.graphics.tile.FlxGraphicsShader; import flixel.math.FlxMath; import flixel.math.FlxPoint; +import flixel.util.FlxBitmapDataPool; import flixel.util.FlxColor; +import flixel.util.FlxSpriteUtil; import openfl.display.BitmapData; import openfl.display.BitmapDataChannel; import openfl.display.BlendMode; +import openfl.geom.Point; +import openfl.geom.Rectangle; using flixel.util.FlxSpriteUtil; /** * A dynamic shape that fills up the way a pie chart does. Useful for timers and other things. - * @author larsiusprime */ class FlxPieDial extends FlxSprite { @@ -20,269 +25,356 @@ class FlxPieDial extends FlxSprite * A value between 0.0 (empty) and 1.0 (full) */ public var amount(default, set):Float; - - var pieFrames:Int = 0; - - public function new(X:Float, Y:Float, Radius:Int, Color:FlxColor = FlxColor.WHITE, Frames:Int = 36, ?Shape:FlxPieDialShape, Clockwise:Bool = true, - InnerRadius:Int = 0) + + public function new(x = 0.0, y = 0.0, radius:Int, color = FlxColor.WHITE, frames = 36, ?shape:FlxPieDialShape, clockwise = true, innerRadius = 0) { - if (Shape == null) - Shape = CIRCLE; - super(X, Y); - makePieDialGraphic(Radius, Color, Frames, Shape, Clockwise, InnerRadius); + if (shape == null) + shape = CIRCLE; + + super(x, y); + getPieDialGraphic(radius, color, frames, shape, clockwise, innerRadius); amount = 1.0; } override public function draw():Void { - if (amount == 0) + if (amount * animation.numFrames < 1) return; + super.draw(); } - - function makePieDialGraphic(Radius:Int, Color:FlxColor, Frames:Int, Shape:FlxPieDialShape, Clockwise:Bool, InnerRadius:Int) + + function getPieDialGraphic(radius:Int, color:FlxColor, frames:Int, shape:FlxPieDialShape, clockwise:Bool, innerRadius:Int) { - pieFrames = Frames; - var key:String = "pie_dial_" + Color.toHexString() + "_" + Radius + "_" + Frames + "_" + Shape + "_" + Clockwise + "_" + InnerRadius; - var W = Radius * 2; - var H = Radius * 2; - if (!FlxG.bitmap.checkCache(key)) - { - var bmp = makePieDialGraphicSub(Radius, Color, Frames, Shape, Clockwise, InnerRadius); - FlxG.bitmap.add(bmp, true, key); - } - - loadGraphic(key, true, W, H); + final graphic = FlxPieDialUtils.getPieDialGraphic(radius, color, frames, shape, clockwise, innerRadius); + loadGraphic(graphic, true, radius * 2, radius * 2); } - - function makePieDialGraphicSub(Radius:Int, Color:Int, Frames:Int, Shape:FlxPieDialShape, Clockwise:Bool, InnerRadius):BitmapData + + function set_amount(f:Float):Float { - var W = Radius * 2; - var H = Radius * 2; - - var rows:Int = Math.ceil(Math.sqrt(Frames)); - var cols:Int = Math.ceil((Frames) / rows); - - var back = Clockwise ? FlxColor.BLACK : FlxColor.WHITE; - var fore = Clockwise ? FlxColor.WHITE : FlxColor.BLACK; - - var fullFrame = makeFullFrame(Radius, Color, Frames, Shape, Clockwise, InnerRadius); - var nextFrame = new FlxSprite().makeGraphic(W, H, back, false); - - var bmp:BitmapData = new BitmapData(W * cols, H * rows, false, back); - var i:Int = 0; - _flashPoint.setTo(0, 0); - var p:FlxPoint = FlxPoint.get(0, -1); - var degrees:Float = 360 / (Frames); - if (!Clockwise) + amount = FlxMath.bound(f, 0.0, 1.0); + var frame:Int = Std.int(f * animation.numFrames); + animation.frameIndex = frame; + if (amount == 1.0) { - degrees *= -1; + animation.frameIndex = 0; // special case for full frame } + return amount; + } +} - var sweep:Float = Clockwise ? 0 : 360; - var bmp2 = new BitmapData(bmp.width, bmp.height, true, FlxColor.TRANSPARENT); - var fullBmp:BitmapData = fullFrame.pixels.clone(); +enum FlxPieDialShape +{ + CIRCLE; + SQUARE; +} - var polygon:Array = [FlxPoint.get(), FlxPoint.get(), FlxPoint.get(), FlxPoint.get(), FlxPoint.get()]; - for (r in 0...rows) +/** + * Set of tools for drawing pie dial graphics + * @since 5.9.0 + */ +class FlxPieDialUtils +{ + static final _rect = new Rectangle(); + static final _zero = new Point(); + static final _point = new Point(); + static var flashGfx = FlxSpriteUtil.flashGfx; + + public static function getPieDialGraphic(radius:Int, color:FlxColor, frames:Int, shape:FlxPieDialShape, clockwise:Bool, innerRadius:Int) + { + final key = 'pie_dial_${color.toHexString()}_${radius}_${frames}_${shape}_${clockwise}_$innerRadius'; + + if (!FlxG.bitmap.checkCache(key)) { - for (c in 0...cols) - { - if (i >= Frames) - { - break; - } - - _flashPoint.setTo(c * W, r * H); - bmp2.copyPixels(fullBmp, fullBmp.rect, _flashPoint); - - if (i <= 0) - { - bmp.fillRect(fullBmp.rect, FlxColor.WHITE); - } - else - { - nextFrame.pixels.copyPixels(fullFrame.pixels, fullFrame.pixels.rect, _flashPointZero); - _flashPoint.setTo(c * W, r * H); - drawSweep(sweep, p, nextFrame, polygon, W, H, back, fore); - bmp.copyPixels(nextFrame.pixels, nextFrame.pixels.rect, _flashPoint); - } - - sweep += degrees; - p.rotateByDegrees(degrees); - - i++; - } - - if (i >= Frames) - { - break; - } + final bmp = renderPieDial(shape, radius, innerRadius, frames, clockwise, color); + FlxG.bitmap.add(bmp, true, key); } - - fullBmp.dispose(); - fullFrame.destroy(); - nextFrame.destroy(); - - var shapeChannel = new BitmapData(bmp.width, bmp.height, false); - shapeChannel.copyChannel(bmp2, bmp2.rect, _flashPointZero, BitmapDataChannel.ALPHA, BitmapDataChannel.RED); - shapeChannel.copyChannel(bmp2, bmp2.rect, _flashPointZero, BitmapDataChannel.ALPHA, BitmapDataChannel.GREEN); - shapeChannel.copyChannel(bmp2, bmp2.rect, _flashPointZero, BitmapDataChannel.ALPHA, BitmapDataChannel.BLUE); - - shapeChannel.draw(bmp, null, null, BlendMode.MULTIPLY, null, true); - bmp2.copyChannel(shapeChannel, shapeChannel.rect, _flashPointZero, BitmapDataChannel.RED, BitmapDataChannel.ALPHA); - - shapeChannel.dispose(); - bmp.dispose(); - - return bmp2; + + return FlxG.bitmap.get(key); } - - function makeFullFrame(Radius:Int, Color:Int, Frames:Int, Shape:FlxPieDialShape, Clockwise:Bool, InnerRadius):FlxSprite + + public static function getRadialGaugeGraphic(shape:FlxPieDialShape, radius:Int, innerRadius = 0, color = FlxColor.WHITE) { - var W = Radius * 2; - var H = Radius * 2; - - var fullFrame = new FlxSprite().makeGraphic(W, H, FlxColor.TRANSPARENT, true); - if (InnerRadius > Radius) - { - InnerRadius = 0; - } - - var dR = Radius - InnerRadius; - - if (Shape == SQUARE) + final key = 'radial_gauge_${shape}_${color.toHexString()}_${radius}_$innerRadius'; + + if (!FlxG.bitmap.checkCache(key)) { - fullFrame.pixels.fillRect(fullFrame.pixels.rect, Color); - if (InnerRadius > 0) - { - _flashRect.setTo(dR, dR, InnerRadius * 2, InnerRadius * 2); - fullFrame.pixels.fillRect(_flashRect, FlxColor.TRANSPARENT); - } + final bmp = renderRadialGauge(shape, radius, innerRadius, color); + FlxG.bitmap.add(bmp, true, key); } - else if (Shape == CIRCLE) + + return FlxG.bitmap.get(key); + } + + /** + * Draws an animated pie dial graphic where each frame shows a more full amount, + * however the full gauge frame is on frame 0 + * + * @param radius The radius of the shape + * @param color The color of the shape + * @param shape The shape, Either `SQUARE` or `CIRCLE` + * @param innerRadius The radius of the inner hollow portion, where `0` means completely filled + */ + public static function renderRadialGauge(shape:FlxPieDialShape, radius:Int, innerRadius = 0, color = FlxColor.WHITE):BitmapData + { + return renderPieDial(shape, radius, innerRadius, 1, true, color); + } + + /** + * Draws an animated pie dial graphic where each frame shows a more full amount, + * however the full gauge frame is on frame 0 + * + * @param radius The radius of the shape + * @param color The color of the shape + * @param frames + * @param shape The shape, Either `SQUARE` or `CIRCLE` + * @param clockwise The direction the gauge + * @param innerRadius The radius of the inner hollow portion, where `0` means completely filled + */ + public static function renderPieDial(shape:FlxPieDialShape, radius:Int, innerRadius:Int, frames:Int, clockwise = true, color = FlxColor.WHITE):BitmapData + { + final W = radius * 2; + final H = radius * 2; + + final rows = Math.ceil(Math.sqrt(frames)); + final cols = Math.ceil(frames / rows); + + final maskFrame = FlxBitmapDataPool.get(W, H, true, FlxColor.TRANSPARENT, true); + final fullFrame = FlxBitmapDataPool.get(W, H, true, FlxColor.TRANSPARENT, true); + FlxPieDialUtils.drawShape(fullFrame, radius, color, shape, innerRadius); + + final result = new BitmapData(W * cols, H * rows, true, FlxColor.TRANSPARENT); + final p = FlxPoint.get(); + final degreeInterval = (clockwise ? 1 : -1) * 360 / frames; + + final mask = FlxBitmapDataPool.get(result.width, result.height, result.transparent, FlxColor.TRANSPARENT, true); + + final polygon:Array = [FlxPoint.get(), FlxPoint.get(), FlxPoint.get(), FlxPoint.get(), FlxPoint.get()]; + for (i in 0...frames) { - if (InnerRadius > 0) + _point.setTo((i % cols) * W, Std.int(i / cols) * H); + result.copyPixels(fullFrame, fullFrame.rect, _point);//, null, null, true); + if (i <= 0) { - var alpha = new BitmapData(fullFrame.pixels.width, fullFrame.pixels.height, false, FlxColor.BLACK); - fullFrame.pixels.fillRect(_flashRect, FlxColor.BLACK); - fullFrame.drawCircle(-1, -1, Radius, FlxColor.WHITE, null, {smoothing: true}); - fullFrame.drawCircle(-1, -1, InnerRadius, FlxColor.BLACK, null, {smoothing: true}); - - alpha.copyPixels(fullFrame.pixels, fullFrame.pixels.rect, _flashPointZero, null, null, true); - - fullFrame.pixels.fillRect(fullFrame.pixels.rect, Color); - fullFrame.pixels.copyChannel(alpha, alpha.rect, _flashPointZero, BitmapDataChannel.RED, BitmapDataChannel.ALPHA); - - alpha.dispose(); + mask.fillRect(fullFrame.rect, FlxColor.WHITE); } else { - fullFrame.drawCircle(-1, -1, Radius, Color); + final angle = degreeInterval * i; + maskFrame.fillRect(maskFrame.rect, FlxColor.TRANSPARENT); + FlxPieDialUtils.drawSweep(maskFrame, angle); + mask.copyPixels(maskFrame, maskFrame.rect, _point, null, null, true); } } - return fullFrame; + + result.copyPixels(result, result.rect, _zero, mask); + FlxBitmapDataPool.put(mask); + FlxBitmapDataPool.put(maskFrame); + FlxBitmapDataPool.put(fullFrame); + + return result; } - - function drawSweep(sweep:Float, p:FlxPoint, nextFrame:FlxSprite, polygon:Array, W:Int, H:Int, back:FlxColor, fore:FlxColor) + + /** + * Draws the specified shape onto the bitmap + * + * @param dest The bitmap to draw to + * @param radius The radius of the shape + * @param color The color of the shape + * @param shape The shape, Either `SQUARE` or `CIRCLE` + * @param innerRadius The radius of the inner hollow portion, where `0` means completely filled + */ + public static inline function drawShape(dest:BitmapData, radius:Int, color:FlxColor, shape:FlxPieDialShape, innerRadius = 0):BitmapData { - var halfW = W / 2; - var halfH = H / 2; - - nextFrame.pixels.fillRect(nextFrame.pixels.rect, back); - polygon[0].set(halfW, halfH); - - if (sweep < 45) + final W = radius << 1; + final H = radius << 1; + + switch (shape) { - polygon[1].set(halfW, 0); - polygon[2].set(halfW + W * p.x, halfH + H * p.y); - polygon[3].set(halfW, halfH); + case SQUARE if (innerRadius > 0 && innerRadius < radius): + final thickness = radius - innerRadius; + _rect.setTo(0, 0, W, thickness); + dest.fillRect(_rect, color); + _rect.setTo(0, 0, thickness, H); + dest.fillRect(_rect, color); + _rect.setTo(W - thickness, 0, thickness, H); + dest.fillRect(_rect, color); + _rect.setTo(0, H - thickness, W, thickness); + dest.fillRect(_rect, color); + + case SQUARE: + dest.fillRect(dest.rect, color); + + case CIRCLE if (innerRadius > 0 && innerRadius < radius): + final alpha = FlxBitmapDataPool.get(W, H, false, FlxColor.BLACK, true); + alpha.fillRect(alpha.rect, FlxColor.BLACK); + drawCircle(alpha, radius, FlxColor.WHITE, null, {smoothing: true}); + drawCircle(alpha, innerRadius, FlxColor.BLACK, null, {smoothing: true}); + + alpha.copyPixels(dest, dest.rect, _zero, null, null, true); + + dest.fillRect(dest.rect, color); + dest.copyChannel(alpha, alpha.rect, _zero, BitmapDataChannel.RED, BitmapDataChannel.ALPHA); + + FlxBitmapDataPool.put(alpha); + + case CIRCLE: + drawCircle(dest, radius, color); } - else if (sweep < 90) + return dest; + } + + /** + * Used via `drawSweep` + */ + static final sweepPoints = [for (i in 0...4) FlxPoint.get()]; + + /** + * Draws a wedge section of a bitmap, used in `FlxPieDial` + * @param dest The btimap to draw to + * @param degrees The angle of the wedge + * @param color The color to fill the wedge + */ + public static function drawSweep(dest:BitmapData, degrees:Float, color = FlxColor.WHITE) + { + degrees %= 360; + final p = sweepPoints; + final radius = dest.width >> 1; + final center = p[0].set(radius, radius); + final cornerLength = center.length; + + if (degrees >= 270) { - polygon[1].set(halfW, 0); - polygon[2].set(W, 0); - polygon[3].set(halfW + W * p.x, halfH + H * p.y); + // fill right half + _rect.setTo(radius, 0, radius, dest.height); + dest.fillRect(_rect, color); + // fill bottom-left quadrant + _rect.setTo(0, radius, radius, radius); + dest.fillRect(_rect, color); } - else if (sweep < 135) + else if (degrees >= 180) { - _flashRect.setTo(halfW, 0, halfW, halfH); - nextFrame.pixels.fillRect(_flashRect, fore); - - polygon[1].set(W, halfH); - polygon[2].set(halfW + W * p.x, halfH + H * p.y); - polygon[3].set(halfW, halfH); + // fill right half + _rect.setTo(radius, 0, radius, dest.height); + dest.fillRect(_rect, color); } - else if (sweep < 180) + else if (degrees >= 90) { - _flashRect.setTo(halfW, 0, halfW, halfH); - nextFrame.pixels.fillRect(_flashRect, fore); - - polygon[1].set(W, halfH); - polygon[2].set(W, H); - polygon[3].set(halfW + W * p.x, halfH + H * p.y); + // fill top-right quadrant + _rect.setTo(radius, 0, radius, radius); + dest.fillRect(_rect, color); } - else if (sweep < 225) + else if (degrees <= -270) { - _flashRect.setTo(halfW, 0, halfW, H); - nextFrame.pixels.fillRect(_flashRect, fore); - - polygon[1].set(halfW, H); - polygon[2].set(halfW + W * p.x, halfH + H * p.y); - polygon[3].set(halfW, halfH); + // fill left half + _rect.setTo(0, 0, radius, dest.height); + dest.fillRect(_rect, color); + // fill bottom-right quadrant + _rect.setTo(radius, radius, radius, radius); + dest.fillRect(_rect, color); } - else if (sweep < 270) + else if (degrees <= -180) { - _flashRect.setTo(halfW, 0, halfW, H); - nextFrame.pixels.fillRect(_flashRect, fore); - - polygon[1].set(halfW, H); - polygon[2].set(0, H); - polygon[3].set(halfW + W * p.x, halfH + H * p.y); + // fill left half + _rect.setTo(0, 0, radius, dest.height); + dest.fillRect(_rect, color); } - else if (sweep < 315) + else if (degrees <= -90) { - _flashRect.setTo(halfW, 0, halfW, H); - nextFrame.pixels.fillRect(_flashRect, fore); - _flashRect.setTo(0, halfH, halfW, halfH); - nextFrame.pixels.fillRect(_flashRect, fore); - - polygon[1].set(0, halfH); - polygon[2].set(halfW + W * p.x, halfH + H * p.y); - polygon[3].set(halfW, halfH); + // fill top-left quadrant + _rect.setTo(0, 0, radius, radius); + dest.fillRect(_rect, color); } - else if (sweep < 360) + + // draw the interesting quadrant + if (Math.abs(degrees % 90) < 45) { - _flashRect.setTo(halfW, 0, halfW, H); - nextFrame.pixels.fillRect(_flashRect, fore); - _flashRect.setTo(0, halfH, halfW, halfH); - nextFrame.pixels.fillRect(_flashRect, fore); - - polygon[1].set(0, halfH); - polygon[2].set(0, 0); - polygon[3].set(halfW + W * p.x, halfH + H * p.y); + p[1].setPolarDegrees(radius, -90 + Std.int(degrees / 90) * 90).addPoint(center); + p[2].setPolarDegrees(cornerLength, -90 + degrees).addPoint(center); + p[3].copyFrom(center); } - - polygon[4].set(halfW, halfH); - - nextFrame.drawPolygon(polygon, fore); + else + { + final quadDegreesStart = Std.int(degrees / 90) * 90; + final cornerDegrees = quadDegreesStart + (degrees < 0 ? -45 : 45); + p[1].setPolarDegrees(radius, -90 + quadDegreesStart).addPoint(center); + p[2].setPolarDegrees(cornerLength, -90 + cornerDegrees).addPoint(center); + p[3].setPolarDegrees(cornerLength, -90 + degrees).addPoint(center); + } + + drawPolygon(dest, p, color); } - - function set_amount(f:Float):Float + + /** + * This function draws a circle on a FlxSprite at position X,Y with the specified color. + * + * @param bitmap The BitmapData to manipulate + * @param X X coordinate of the circle's center (automatically centered on the sprite if -1) + * @param Y Y coordinate of the circle's center (automatically centered on the sprite if -1) + * @param radius Radius of the circle (makes sure the circle fully fits on the sprite's graphic if < 1, assuming and and y are centered) + * @param color The ARGB color to fill this circle with. FlxColor.TRANSPARENT (0x0) means no fill. + * @param lineStyle A LineStyle typedef containing the params of Graphics.lineStyle() + * @param drawStyle A DrawStyle typedef containing the params of BitmapData.draw() + * @return The FlxSprite for chaining + */ + public static function drawCircle(bitmap:BitmapData, ?radius:Float, color = FlxColor.WHITE, ?lineStyle:LineStyle, ?drawStyle:DrawStyle):BitmapData { - amount = FlxMath.bound(f, 0.0, 1.0); - var frame:Int = Std.int(f * pieFrames); - animation.frameIndex = frame; - if (amount == 1.0) + final x = bitmap.width * 0.5; + final y = bitmap.height * 0.5; + + if (radius == null) + radius = Math.min(bitmap.width, bitmap.height) * 0.5; + + beginDraw(color, lineStyle); + flashGfx.drawCircle(x, y, radius); + endDraw(bitmap, drawStyle); + return bitmap; + } + + /** + * This function draws a polygon on a FlxSprite. + * + * @param graphic The FlxSprite to manipulate + * @param Vertices Array of Vertices to use for drawing the polygon + * @param FillColor The ARGB color to fill this polygon with. FlxColor.TRANSPARENT (0x0) means no fill. + * @param lineStyle A LineStyle typedef containing the params of Graphics.lineStyle() + * @param drawStyle A DrawStyle typedef containing the params of BitmapData.draw() + * @return The FlxSprite for chaining + */ + public static function drawPolygon(bitmap:BitmapData, vertices:Array, fillColor = FlxColor.WHITE, ?lineStyle:LineStyle, + ?drawStyle:DrawStyle):BitmapData + { + beginDraw(fillColor, lineStyle); + final p:FlxPoint = vertices.shift(); + flashGfx.moveTo(p.x, p.y); + for (p in vertices) { - animation.frameIndex = 0; // special case for full frame + flashGfx.lineTo(p.x, p.y); } - return amount; + endDraw(bitmap, drawStyle); + vertices.unshift(p); + return bitmap; } -} - -enum FlxPieDialShape -{ - CIRCLE; - SQUARE; -} + + static inline function beginDraw(color:FlxColor, ?lineStyle:LineStyle):Void + { + flashGfx.clear(); + FlxSpriteUtil.setLineStyle(lineStyle); + + if (color != FlxColor.TRANSPARENT) + flashGfx.beginFill(color.rgb, color.alphaFloat); + } + + static inline function endDraw(bitmap:BitmapData, ?style:DrawStyle):BitmapData + { + flashGfx.endFill(); + if (style == null) + style = {smoothing: false}; + else if (style.smoothing == null) + style.smoothing = false; + + final sprite = FlxSpriteUtil.flashGfxSprite; + bitmap.draw(sprite, style.matrix, style.colorTransform, style.blendMode, style.clipRect, style.smoothing); + return bitmap; + } +} \ No newline at end of file diff --git a/flixel/addons/display/FlxRadialGauge.hx b/flixel/addons/display/FlxRadialGauge.hx new file mode 100644 index 00000000..67ba25e4 --- /dev/null +++ b/flixel/addons/display/FlxRadialGauge.hx @@ -0,0 +1,155 @@ +package flixel.addons.display; + +import flixel.FlxSprite; +import flixel.addons.display.FlxPieDial; +import flixel.util.FlxColor; + +#if !flash +/** + * A dynamic shape that fills up radially (like a pie chart). Useful for timers and other things. + * `FlxRadialGauge` uses `FlxRadialWipeShader` to fill the gauge portion, where `FlxPieDial` + * creates an animation. This also works with any graphic, unlike `FlxPieDial` + * @since 5.9.0 + */ +class FlxRadialGauge extends FlxSprite +{ + /** A value between 0.0 (empty) and 1.0 (full) */ + public var amount(get, set):Float; + inline function get_amount():Float + { + return _sweepShader.amount; + } + inline function set_amount(value:Float):Float + { + return _sweepShader.amount = value; + } + + /** The angle in degrees to start the dial fill */ + public var start(get, set):Float; + inline function get_start():Float + { + return _sweepShader.start; + } + inline function set_start(value:Float):Float + { + return _sweepShader.start = value; + } + + /** The angle in degrees to end the dial fill */ + public var end(get, set):Float; + inline function get_end():Float + { + return _sweepShader.end; + } + inline function set_end(value:Float):Float + { + return _sweepShader.end = value; + } + + var _sweepShader(get, never):FlxRadialWipeShader; + inline function get__sweepShader() return cast shader; + + public function new(x = 0.0, y = 0.0, ?simpleGraphic) + { + super(x, y, simpleGraphic); + + shader = new FlxRadialWipeShader(); + this.amount = 1; + } + + public function makeShapeGraphic(shape:FlxRadialGaugeShape, radius:Int, innerRadius = 0, color = FlxColor.WHITE) + { + final graphic = FlxPieDialUtils.getRadialGaugeGraphic(shape, radius, innerRadius, color); + loadGraphic(graphic, true, radius * 2, radius * 2); + } + + public function setOrientation(start = -90.0, end = 270.0) + { + this.start = start; + this.end = end; + } +} + +typedef FlxRadialGaugeShape = FlxPieDialShape; + +/** + * A shader that masks a static sprite radially, based on the `start` and `end` angles + */ +class FlxRadialWipeShader extends flixel.system.FlxAssets.FlxShader +{ + /** The current fill amount, where `0.0` is empty and `1.0` is full */ + public var amount(get, set):Float; + inline function get_amount():Float return _amount.value[0]; + inline function set_amount(value:Float):Float + { + _amount.value = [value]; + return value; + } + + /** The angle in degrees to start the dial fill */ + public var start(get, set):Float; + inline function get_start():Float return _start.value[0]; + inline function set_start(value:Float):Float + { + _start.value = [value]; + return value; + } + + /** The angle in degrees to end the dial fill */ + public var end(get, set):Float; + inline function get_end():Float return _end.value[0]; + inline function set_end(value:Float):Float + { + _end.value = [value]; + return value; + } + + @:glFragmentSource(' + #pragma header + + const float TAU = 6.2831853072; + + uniform float _amount; + uniform float _start; + uniform float _end; + + float getGradiant(in vec2 dist) + { + float start = _start / 360.0; + float delta = (_end - _start) / 360.0; + float angle = atan(dist.y, dist.x) / TAU; + if (_end > _start) + return mod(angle - start, 1.0) / delta; + else + return mod(start - angle, 1.0) / -delta; + } + + float wedge(in vec2 uv, in float ratio) + { + vec2 dist = uv - vec2(0.5); + float grad = getGradiant(dist); + return step(ratio, grad < 0.0 ? 1.0 : grad); + } + + void main() + { + if (_amount > 0.0) + { + float amount = min(1.0, max(0.0, _amount)); + vec4 bitmap = flixel_texture2D(bitmap, openfl_TextureCoordv); + gl_FragColor = mix(bitmap, vec4(0.0), wedge(openfl_TextureCoordv, amount)); + } + else + gl_FragColor = vec4(0.0); + }') + public function new() + { + super(); + amount = 1.0; + start = -90; + end = 270; + } +} +#elseif FLX_NO_COVERAGE_TEST +#error "FlxRadialGauge is not supported on flash targets" +#end \ No newline at end of file From 07c3f07581ce8698fcbac4adbe64fcc3b7572ecc Mon Sep 17 00:00:00 2001 From: George Kurelic Date: Wed, 2 Oct 2024 11:14:41 -0500 Subject: [PATCH 61/69] break update into separate methods + general cleanup (#447) --- flixel/addons/effects/FlxTrail.hx | 246 +++++++++++++++--------------- 1 file changed, 120 insertions(+), 126 deletions(-) diff --git a/flixel/addons/effects/FlxTrail.hx b/flixel/addons/effects/FlxTrail.hx index e7caef35..2969fe5f 100644 --- a/flixel/addons/effects/FlxTrail.hx +++ b/flixel/addons/effects/FlxTrail.hx @@ -95,28 +95,28 @@ class FlxTrail extends #if (flixel < "5.7.0") FlxSpriteGroup #else FlxSpriteCont /** * Creates a new FlxTrail effect for a specific FlxSprite. * - * @param Target The FlxSprite the trail is attached to. - * @param Graphic The image to use for the trailsprites. Optional, uses the sprite's graphic if null. - * @param Length The amount of trailsprites to create. - * @param Delay How often to update the trail. 0 updates every frame. - * @param Alpha The alpha value for the very first trailsprite. - * @param Diff How much lower the alpha of the next trailsprite is. + * @param target The FlxSprite the trail is attached to. + * @param graphic The image to use for the trailsprites. Optional, uses the sprite's graphic if null. + * @param length The amount of trailsprites to create. + * @param delay How often to update the trail. 0 updates every frame. + * @param alpha The alpha value for the very first trailsprite. + * @param diff How much lower the alpha of the next trailsprite is. */ - public function new(Target:FlxSprite, ?Graphic:FlxGraphicAsset, Length:Int = 10, Delay:Int = 3, Alpha:Float = 0.4, Diff:Float = 0.05):Void + public function new(target:FlxSprite, ?graphic:FlxGraphicAsset, length = 10, delay = 3, alpha = 0.4, diff = 0.05):Void { super(); - _spriteOrigin = FlxPoint.get().copyFrom(Target.origin); + _spriteOrigin = FlxPoint.get().copyFrom(target.origin); // Sync the vars - target = Target; - delay = Delay; - _graphic = Graphic; - _transp = Alpha; - _difference = Diff; + this.target = target; + this.delay = delay; + _graphic = graphic; + _transp = alpha; + _difference = diff; // Create the initial trailsprites - increaseLength(Length); + increaseLength(length); solid = false; } @@ -147,100 +147,94 @@ class FlxTrail extends #if (flixel < "5.7.0") FlxSpriteGroup #else FlxSpriteCont { // Count the frames _counter++; - + // Update the trail in case the intervall and there actually is one. if (_counter >= delay && _trailLength >= 1) { _counter = 0; - - // Push the current position into the positons array and drop one. - var spritePosition:FlxPoint = null; - if (_recentPositions.length == _trailLength) - { - spritePosition = _recentPositions.pop(); - } - else - { - spritePosition = FlxPoint.get(); - } - - spritePosition.set(target.x - target.offset.x, target.y - target.offset.y); - _recentPositions.unshift(spritePosition); - - // Also do the same thing for the Sprites angle if rotationsEnabled + addTrailFrame(); + + // Now we need to update the all the Trailsprites' values + redrawTrailSprites(); + } + + super.update(elapsed); + } + + inline function recyclePoint(list:Array, x:Float, y:Float) + { + final pos = if (list.length >= _trailLength) + list.pop().set(x, y); + else + FlxPoint.get(x, y); + + list.unshift(pos); + } + + function addTrailFrame() + { + // Push the current position into the positons array and drop one. + recyclePoint(_recentPositions, target.x - target.offset.x, target.y - target.offset.y); + + // Also do the same thing for the Sprites angle if rotationsEnabled + if (rotationsEnabled) + { + cacheValue(_recentAngles, target.angle); + } + + // Again the same thing for Sprites scales if scalesEnabled + if (scalesEnabled) + { + recyclePoint(_recentScales, target.scale.x, target.scale.y); + } + + // Again the same thing for Sprites frames if framesEnabled + if (framesEnabled && _graphic == null) + { + cacheValue(_recentFrames, target.animation.frameIndex); + cacheValue(_recentFlipX, target.flipX); + cacheValue(_recentFlipY, target.flipY); + cacheValue(_recentAnimations, target.animation.curAnim); + } + } + + function redrawTrailSprites() + { + for (i in 0..._recentPositions.length) + { + final trailSprite = members[i]; + trailSprite.x = _recentPositions[i].x; + trailSprite.y = _recentPositions[i].y; + + // And the angle... if (rotationsEnabled) { - cacheValue(_recentAngles, target.angle); + trailSprite.angle = _recentAngles[i]; + trailSprite.origin.x = _spriteOrigin.x; + trailSprite.origin.y = _spriteOrigin.y; } - - // Again the same thing for Sprites scales if scalesEnabled + + // the scale... if (scalesEnabled) { - var spriteScale:FlxPoint = null; // sprite.scale; - if (_recentScales.length == _trailLength) - { - spriteScale = _recentScales.pop(); - } - else - { - spriteScale = FlxPoint.get(); - } - - spriteScale.set(target.scale.x, target.scale.y); - _recentScales.unshift(spriteScale); + trailSprite.scale.copyFrom(_recentScales[i]); } - - // Again the same thing for Sprites frames if framesEnabled + + // and frame... if (framesEnabled && _graphic == null) { - cacheValue(_recentFrames, target.animation.frameIndex); - cacheValue(_recentFlipX, target.flipX); - cacheValue(_recentFlipY, target.flipY); - cacheValue(_recentAnimations, target.animation.curAnim); - } - - // Now we need to update the all the Trailsprites' values - var trailSprite:FlxSprite; - - for (i in 0..._recentPositions.length) - { - trailSprite = members[i]; - trailSprite.x = _recentPositions[i].x; - trailSprite.y = _recentPositions[i].y; - - // And the angle... - if (rotationsEnabled) - { - trailSprite.angle = _recentAngles[i]; - trailSprite.origin.x = _spriteOrigin.x; - trailSprite.origin.y = _spriteOrigin.y; - } - - // the scale... - if (scalesEnabled) - { - trailSprite.scale.x = _recentScales[i].x; - trailSprite.scale.y = _recentScales[i].y; - } - - // and frame... - if (framesEnabled && _graphic == null) - { - trailSprite.animation.frameIndex = _recentFrames[i]; - trailSprite.flipX = _recentFlipX[i]; - trailSprite.flipY = _recentFlipY[i]; - - trailSprite.animation.curAnim = _recentAnimations[i]; - } - - // Is the trailsprite even visible? - trailSprite.exists = true; + trailSprite.animation.frameIndex = _recentFrames[i]; + trailSprite.flipX = _recentFlipX[i]; + trailSprite.flipY = _recentFlipY[i]; + + trailSprite.animation.curAnim = _recentAnimations[i]; } + + // Is the trailsprite even visible? + trailSprite.exists = true; } - - super.update(elapsed); } - + function cacheValue(array:Array, value:T) { array.unshift(value); @@ -250,13 +244,13 @@ class FlxTrail extends #if (flixel < "5.7.0") FlxSpriteGroup #else FlxSpriteCont public function resetTrail():Void { - _recentPositions.splice(0, _recentPositions.length); - _recentAngles.splice(0, _recentAngles.length); - _recentScales.splice(0, _recentScales.length); - _recentFrames.splice(0, _recentFrames.length); - _recentFlipX.splice(0, _recentFlipX.length); - _recentFlipY.splice(0, _recentFlipY.length); - _recentAnimations.splice(0, _recentAnimations.length); + FlxDestroyUtil.putArray(_recentPositions); + FlxDestroyUtil.putArray(_recentScales); + _recentAngles.resize(0); + _recentFrames.resize(0); + _recentFlipX.resize(0); + _recentFlipY.resize(0); + _recentAnimations.resize(0); for (i in 0...members.length) { @@ -266,27 +260,27 @@ class FlxTrail extends #if (flixel < "5.7.0") FlxSpriteGroup #else FlxSpriteCont } } } - + /** * A function to add a specific number of sprites to the trail to increase its length. * - * @param Amount The amount of sprites to add to the trail. + * @param amount The amount of sprites to add to the trail. */ - public function increaseLength(Amount:Int):Void + public function increaseLength(amount:Int):Void { // Can't create less than 1 sprite obviously - if (Amount <= 0) + if (amount <= 0) { return; } - - _trailLength += Amount; - + + _trailLength += amount; + // Create the trail sprites - for (i in 0...Amount) + for (i in 0...amount) { - var trailSprite = new FlxSprite(0, 0); - + final trailSprite = new FlxSprite(0, 0); + if (_graphic == null) { trailSprite.loadGraphicFromSprite(target); @@ -301,42 +295,42 @@ class FlxTrail extends #if (flixel < "5.7.0") FlxSpriteGroup #else FlxSpriteCont trailSprite.alpha = _transp; _transp -= _difference; trailSprite.solid = solid; - + if (trailSprite.alpha <= 0) { trailSprite.kill(); } } } - + /** * In case you want to change the trailsprite image in runtime... * - * @param Image The image the sprites should load + * @param image The image the sprites should load */ - public function changeGraphic(Image:Dynamic):Void + public function changeGraphic(image:Dynamic):Void { - _graphic = Image; - + _graphic = image; + for (i in 0..._trailLength) { - members[i].loadGraphic(Image); + members[i].loadGraphic(image); } } /** * Handy little function to change which events affect the trail. * - * @param Angle Whether the trail reacts to angle changes or not. - * @param X Whether the trail reacts to x changes or not. - * @param Y Whether the trail reacts to y changes or not. - * @param Scale Wheater the trail reacts to scale changes or not. + * @param angle Whether the trail reacts to angle changes or not. + * @param x Whether the trail reacts to x changes or not. + * @param y Whether the trail reacts to y changes or not. + * @param scale Wheater the trail reacts to scale changes or not. */ - public function changeValuesEnabled(Angle:Bool, X:Bool = true, Y:Bool = true, Scale:Bool = true):Void + public function changeValuesEnabled(angle:Bool, x = true, y = true, scale = true):Void { - rotationsEnabled = Angle; - xEnabled = X; - yEnabled = Y; - scalesEnabled = Scale; + rotationsEnabled = angle; + xEnabled = x; + yEnabled = y; + scalesEnabled = scale; } } From 0a790968e85ad778640b92197ca93d0d144e2640 Mon Sep 17 00:00:00 2001 From: Ahmet Kaya <88967833+neondev27@users.noreply.github.com> Date: Wed, 2 Oct 2024 19:21:35 +0300 Subject: [PATCH 62/69] Turkish README.md (#446) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Create README_TR.md * Update README_TR.md * Update README_TR.md * Update README_TR.md * Update README_TR.md * Update README.md * Update README_TR.md Completely Turkish README * turkish -> türkçe * orijinal -> english --------- Co-authored-by: George Kurelic --- README.md | 2 +- README_TR.md | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 README_TR.md diff --git a/README.md b/README.md index ea60016a..68035f91 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ![](https://raw.github.com/HaxeFlixel/haxeflixel.com/master/src/files/images/flixel-logos/flixel-addons.png) -[flixel](https://github.com/HaxeFlixel/flixel) | [addons](https://github.com/HaxeFlixel/flixel-addons) | [ui](https://github.com/HaxeFlixel/flixel-ui) | [demos](https://github.com/HaxeFlixel/flixel-demos) | [tools](https://github.com/HaxeFlixel/flixel-tools) | [templates](https://github.com/HaxeFlixel/flixel-templates) | [docs](https://github.com/HaxeFlixel/flixel-docs) | [haxeflixel.com](https://github.com/HaxeFlixel/haxeflixel.com) +[flixel](https://github.com/HaxeFlixel/flixel) | [addons](https://github.com/HaxeFlixel/flixel-addons) | [ui](https://github.com/HaxeFlixel/flixel-ui) | [demos](https://github.com/HaxeFlixel/flixel-demos) | [tools](https://github.com/HaxeFlixel/flixel-tools) | [templates](https://github.com/HaxeFlixel/flixel-templates) | [docs](https://github.com/HaxeFlixel/flixel-docs) | [haxeflixel.com](https://github.com/HaxeFlixel/haxeflixel.com) | [türkçe](/README_TR.md) [![CI](https://img.shields.io/github/actions/workflow/status/HaxeFlixel/flixel-addons/main.yml?branch=dev&logo=github)](https://github.com/HaxeFlixel/flixel/actions?query=workflow%3ACI) [![Discord](https://img.shields.io/discord/162395145352904705.svg?logo=discord)](https://discordapp.com/invite/rqEBAgF) diff --git a/README_TR.md b/README_TR.md new file mode 100644 index 00000000..2b06d9dd --- /dev/null +++ b/README_TR.md @@ -0,0 +1,28 @@ +![](https://raw.github.com/HaxeFlixel/haxeflixel.com/master/src/files/images/flixel-logos/flixel-addons.png) + +[flixel](https://github.com/HaxeFlixel/flixel) | [uzantılar](https://github.com/HaxeFlixel/flixel-addons) | [ui](https://github.com/HaxeFlixel/flixel-ui) | [demolar](https://github.com/HaxeFlixel/flixel-demos) | [araçlar](https://github.com/HaxeFlixel/flixel-tools) | [şablonlar](https://github.com/HaxeFlixel/flixel-templates) | [dökümanlar](https://github.com/HaxeFlixel/flixel-docs) | [haxeflixel.com](https://github.com/HaxeFlixel/haxeflixel.com) | [english](/README.md) + +[![CI](https://img.shields.io/github/actions/workflow/status/HaxeFlixel/flixel-addons/main.yml?branch=dev&logo=github)](https://github.com/HaxeFlixel/flixel/actions?query=workflow%3ACI) +[![Discord](https://img.shields.io/discord/162395145352904705.svg?logo=discord)](https://discordapp.com/invite/rqEBAgF) +[![Haxelib Version](https://badgen.net/haxelib/v/flixel-addons)](https://lib.haxe.org/p/flixel-addons) +[![Haxelib Downloads](https://badgen.net/haxelib/d/flixel-addons?color=blue)](https://lib.haxe.org/p/flixel-addons) +[![Haxelib License](https://badgen.net/haxelib/license/flixel-addons)](LICENSE.md) +[![Patreon](https://img.shields.io/badge/donate-patreon-blue.svg)](https://www.patreon.com/haxeflixel) + + + +## Hakkında + +[HaxeFlixel](https://github.com/HaxeFlixel/flixel) | [HaxeFlixel](https://github.com/HaxeFlixel/flixel) için kullanışlı ancak isteğe bağlı, topluluk tarafından oluşturulan bir takım sınıf seti. [Flixel Power Tools](https://github.com/photonstorm/Flixel-Power-Tools)'tan bazı sınıflar dahildir. + +## Geliştiriciler için + +Eğer katkıda bulunmak isterseniz, aşağıdaki dökümanları inceleyin (İngilizce): + +- [Kod katkıları](http://haxeflixel.com/documentation/code-contributions) +- [Kod Tarzı](http://haxeflixel.com/documentation/code-style) +- [Geliştirici flixel'i indirin](http://haxeflixel.com/documentation/install-development-flixel/) + +Eğer bir sorunuz varsa veya daha önce hiç Github'dan katkıda bulunmadıysanız, toplulukta [forumlarda](http://haxeflixel.com/documentation/community/) yardım edecek arkadaş canlısı insanlar var. + +Git'i Github ile kullanmak için, değişikliklerinizi yönetebileceğiniz [SourceTree](http://www.sourcetreeapp.com/) gibi bir GUI kullanmanızı öneririz. From 73856c9610dadc404774cd7642d3cc65f814f19c Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Mon, 7 Oct 2024 12:02:56 -0400 Subject: [PATCH 63/69] fix: add "Point" objectType to TiledObject from Tiled 1.1 update (#448) --- flixel/addons/editors/tiled/TiledObject.hx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/flixel/addons/editors/tiled/TiledObject.hx b/flixel/addons/editors/tiled/TiledObject.hx index d0abac4b..c6e52962 100644 --- a/flixel/addons/editors/tiled/TiledObject.hx +++ b/flixel/addons/editors/tiled/TiledObject.hx @@ -27,6 +27,7 @@ class TiledObject public static inline var POLYGON = 2; public static inline var POLYLINE = 3; public static inline var TILE = 4; + public static inline var POINT = 5; public var x:Int; public var y:Int; @@ -148,6 +149,10 @@ class TiledObject objectType = POLYLINE; getPoints(source.node.polyline); } + else if (source.hasNode.point) + { + objectType = POINT; + } } function getPoints(node:Access):Void From 0d0775252726a8f20f7da95d74073fdcc3778878 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Mon, 7 Oct 2024 17:47:22 -0400 Subject: [PATCH 64/69] fix: use `parallaxx` and `parallaxy` from the tiled tmx (#449) parallax typo fix --- flixel/addons/editors/tiled/TiledLayer.hx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/flixel/addons/editors/tiled/TiledLayer.hx b/flixel/addons/editors/tiled/TiledLayer.hx index ca39fe80..38e07724 100644 --- a/flixel/addons/editors/tiled/TiledLayer.hx +++ b/flixel/addons/editors/tiled/TiledLayer.hx @@ -1,7 +1,7 @@ package flixel.addons.editors.tiled; -import openfl.utils.ByteArray; import haxe.xml.Access; +import openfl.utils.ByteArray; /** * Base class for Tiled object and tile layers @@ -24,6 +24,9 @@ class TiledLayer /** @since 2.1.0 */ public var offsetY:Float; + public var parallaxX:Float; + public var parallaxY:Float; + function new(source:Access, parent:TiledMap) { properties = new TiledPropertySet(); @@ -33,6 +36,8 @@ class TiledLayer opacity = (source.has.opacity) ? Std.parseFloat(source.att.opacity) : 1.0; offsetX = (source.has.offsetx) ? Std.parseFloat(source.att.offsetx) : 0.0; offsetY = (source.has.offsety) ? Std.parseFloat(source.att.offsety) : 0.0; + parallaxX = (source.has.parallaxx) ? Std.parseFloat(source.att.parallaxx) : 1.0; + parallaxY = (source.has.parallaxy) ? Std.parseFloat(source.att.parallaxy) : 1.0; loadProperties(source); } From 4d9dc50ff6d38808defb7ca72aa7086f73ced230 Mon Sep 17 00:00:00 2001 From: George Kurelic Date: Mon, 9 Dec 2024 15:04:40 -0600 Subject: [PATCH 65/69] remove implicit casts of int to/from directions (#451) --- flixel/addons/display/FlxExtendedMouseSprite.hx | 16 ++++++++-------- flixel/addons/display/FlxNestedSprite.hx | 3 ++- flixel/addons/effects/FlxClothSprite.hx | 8 ++++---- .../addons/plugin/control/FlxControlHandler.hx | 6 ++++-- flixel/addons/util/FlxScene.hx | 3 ++- 5 files changed, 20 insertions(+), 16 deletions(-) diff --git a/flixel/addons/display/FlxExtendedMouseSprite.hx b/flixel/addons/display/FlxExtendedMouseSprite.hx index a2cebd3d..eaf5e7b4 100644 --- a/flixel/addons/display/FlxExtendedMouseSprite.hx +++ b/flixel/addons/display/FlxExtendedMouseSprite.hx @@ -455,11 +455,11 @@ class FlxExtendedMouseSprite extends FlxSprite if (acceleration.x < 0) { // Gravity is pulling them left - if ((touching & WALL) != 0) + if (touching.has(WALL)) { drag.y = frictionY; - if ((wasTouching & WALL) == 0) + if (!wasTouching.has(WALL)) { if (velocity.x < toleranceX) { @@ -475,12 +475,12 @@ class FlxExtendedMouseSprite extends FlxSprite else if (acceleration.x > 0) { // Gravity is pulling them right - if ((touching & WALL) != 0) + if (touching.has(WALL)) { // Stop them sliding like on ice drag.y = frictionY; - if ((wasTouching & WALL) == 0) + if (!wasTouching.has(WALL)) { if (velocity.x > -toleranceX) { @@ -501,11 +501,11 @@ class FlxExtendedMouseSprite extends FlxSprite if (acceleration.y < 0) { // Gravity is pulling them up (velocity is negative) - if ((touching & CEILING) != 0) + if (touching.has(CEILING)) { drag.x = frictionX; - if ((wasTouching & CEILING) == 0) + if (!wasTouching.has(CEILING)) { if (velocity.y < toleranceY) { @@ -521,12 +521,12 @@ class FlxExtendedMouseSprite extends FlxSprite else if (acceleration.y > 0) { // Gravity is pulling them down (velocity is positive) - if ((touching & FLOOR) != 0) + if (touching.has(FLOOR)) { // Stop them sliding like on ice drag.x = frictionX; - if ((wasTouching & FLOOR) == 0) + if (!wasTouching.has(FLOOR)) { if (velocity.y > -toleranceY) { diff --git a/flixel/addons/display/FlxNestedSprite.hx b/flixel/addons/display/FlxNestedSprite.hx index 1d71abb0..a6c91ce3 100644 --- a/flixel/addons/display/FlxNestedSprite.hx +++ b/flixel/addons/display/FlxNestedSprite.hx @@ -1,5 +1,6 @@ package flixel.addons.display; +import flixel.util.FlxDirectionFlags; import openfl.geom.ColorTransform; import flixel.FlxBasic; import flixel.FlxG; @@ -401,7 +402,7 @@ class FlxNestedSprite extends FlxSprite return color; } - override function set_facing(Direction:Int):Int + override function set_facing(Direction:FlxDirectionFlags):FlxDirectionFlags { super.set_facing(Direction); if (children != null) diff --git a/flixel/addons/effects/FlxClothSprite.hx b/flixel/addons/effects/FlxClothSprite.hx index 500d1677..28f558ef 100644 --- a/flixel/addons/effects/FlxClothSprite.hx +++ b/flixel/addons/effects/FlxClothSprite.hx @@ -303,10 +303,10 @@ class FlxClothSprite extends FlxSprite y: r * heightInTiles, oldx: c * widthInTiles, oldy: r * heightInTiles, - pinned: ((r == 0 && pinnedSide & UP != 0) - || (r == rows - 1 && pinnedSide & DOWN != 0) - || (c == 0 && pinnedSide & LEFT != 0) - || (c == columns - 1 && pinnedSide & RIGHT != 0)) + pinned: ((r == 0 && pinnedSide.has(UP)) + || (r == rows - 1 && pinnedSide.has(DOWN)) + || (c == 0 && pinnedSide.has(LEFT)) + || (c == columns - 1 && pinnedSide.has(RIGHT))) }); _vertices.push(c * widthInTiles); diff --git a/flixel/addons/plugin/control/FlxControlHandler.hx b/flixel/addons/plugin/control/FlxControlHandler.hx index 8cdb4c42..70d28401 100644 --- a/flixel/addons/plugin/control/FlxControlHandler.hx +++ b/flixel/addons/plugin/control/FlxControlHandler.hx @@ -12,6 +12,7 @@ import flixel.sound.FlxSound; #else import flixel.system.FlxSound; #end +import flixel.util.FlxDirectionFlags; /** * @@ -173,7 +174,7 @@ class FlxControlHandler // Internal time of when they last collided with a valid jumpSurface var _extraSurfaceTime:Int; // The surfaces they can jump from (i.e. FLOOR) - var _jumpSurface:Int; + var _jumpSurface:FlxDirectionFlags; // A function to call every time they jump var _jumpCallback:Void->Void; @@ -612,7 +613,8 @@ class FlxControlHandler * @param callback A user defined function to call when the Sprite jumps * @param altKey Specify an alternative jump key that works AS WELL AS the primary jump key (TODO) */ - public function setJumpButton(key:String, keymode:Int, height:Int, surface:Int, repeatDelay:Int = 250, jumpFromFall:Int = 0, ?callback:Void->Void, + public function setJumpButton(key:String, keymode:Int, height:Int, surface:FlxDirectionFlags, repeatDelay:Int = 250, jumpFromFall:Int = 0, + ?callback:Void->Void, altKey:String = ""):Void { _jumpKey = key; diff --git a/flixel/addons/util/FlxScene.hx b/flixel/addons/util/FlxScene.hx index c4e6151b..910726a5 100644 --- a/flixel/addons/util/FlxScene.hx +++ b/flixel/addons/util/FlxScene.hx @@ -10,6 +10,7 @@ import flixel.tile.FlxTilemap; import flixel.ui.FlxButton; import flixel.util.FlxAxes; import flixel.util.FlxColor; +import flixel.util.FlxDirectionFlags; import haxe.xml.Parser; import openfl.Assets; @@ -250,7 +251,7 @@ class FlxScene case "tile": var id = Std.parseInt(element.att.id); - var collision = Std.parseInt(element.att.collision); + var collision:FlxDirectionFlags = cast Std.parseInt(element.att.collision); tilemap.setTileProperties(id, collision); } From 8eac8160b25bc3654ed362ab5cc96437938cefee Mon Sep 17 00:00:00 2001 From: George FunBook Date: Mon, 9 Dec 2024 15:05:48 -0600 Subject: [PATCH 66/69] update changelog --- CHANGELOG.md | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 669b753e..e0f72459 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,22 @@ -3.2.4 (TBD) +3.3.0 (TBD) ------------------------------ #### Changes and improvements: -- Compatibility with Flixel 5.9.0 ([431](https://github.com/HaxeFlixel/flixel-addons/pull/431)) +- Compatibility with Flixel 5.9.0 ([431](https://github.com/HaxeFlixel/flixel-addons/pull/431))([432](https://github.com/HaxeFlixel/flixel-addons/pull/432))([433](https://github.com/HaxeFlixel/flixel-addons/pull/433))([436](https://github.com/HaxeFlixel/flixel-addons/pull/436))([437](https://github.com/HaxeFlixel/flixel-addons/pull/437))([440](https://github.com/HaxeFlixel/flixel-addons/pull/440))([441](https://github.com/HaxeFlixel/flixel-addons/pull/441)) - Deprecated `FlxRayCastTilemap` - - Minor upkeep for `FlxTilemapExt`, `FlxOgmo3Loader`, `FlxOgmo3Loader` + - Minor upkeep for `FlxTilemapExt`, `FlxOgmo3Loader`, `FlxOgmo3Loader`, `FlxWeapon`, `FlxNapeTilemap`, `FlxTrail`, `FlxExtendedMouseSprite`, `FlxSlider`, `FlxTransitionSprite` +- `FlxTiledSprite`: Honor `clipRect` ([435](https://github.com/HaxeFlixel/flixel-addons/pull/435)) +- `FlxRuntimeShader`: Refactor and improve readibility ([442](https://github.com/HaxeFlixel/flixel-addons/pull/442)) +- Assets: Ran oxipng on all images ([445](https://github.com/HaxeFlixel/flixel-addons/pull/445)) +- `FlxTrail`: Organize logic into various methods to allow overriding particular behavior ([447](https://github.com/HaxeFlixel/flixel-addons/pull/447)) +- `TiledObject`: Add `POINT` type ([448](https://github.com/HaxeFlixel/flixel-addons/pull/448)) +- `TiledLayer`: Add `parallaxX` and `parallaxY` ([449](https://github.com/HaxeFlixel/flixel-addons/pull/449)) +- Remove all implicit `Int` casts from/to `FlxDirectionFlags` ([451](https://github.com/HaxeFlixel/flixel-addons/pull/451)) + +#### New Features: +- `FlxRadialGauge`: Refactor `FlxPieDial` add replacement ([444](https://github.com/HaxeFlixel/flixel-addons/pull/444)) + - `FlxRadialWipeShader`: Shader that masks sprite radially, can be applied to of any static sprite (doesn't work with animations, yet, but neither did FlxPieDial). Shaders only work on non-Flash targets + - `FlxRadialGauge`: Same as `FlxPieDial` but uses less memory, shows more percentages, and performs better + - `FlxPieDialUtils`: Moved all logic from `FlxPieDial` to a shared util 3.2.3 (May 15, 2024) ------------------------------ From fb8d7d6a621efa51f1f3cdd9b94ae14947c9496e Mon Sep 17 00:00:00 2001 From: George FunBook Date: Mon, 9 Dec 2024 15:06:23 -0600 Subject: [PATCH 67/69] update haxelib.json --- haxelib.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/haxelib.json b/haxelib.json index 137b228a..481c1b70 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.4", + "version": "3.3.0", "releasenote": "Compatibility with flixel 5.9.0", "contributors": ["haxeflixel", "Gama11", "GeoKureli"] } From 2e10d0c3cad4500339c8e70e0dd6291be6440cd0 Mon Sep 17 00:00:00 2001 From: George Kurelic Date: Tue, 10 Dec 2024 09:15:36 -0600 Subject: [PATCH 68/69] FlxTypeText resetText to prefix (#395) --- flixel/addons/text/FlxTypeText.hx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flixel/addons/text/FlxTypeText.hx b/flixel/addons/text/FlxTypeText.hx index 2774ef5f..237b1c64 100644 --- a/flixel/addons/text/FlxTypeText.hx +++ b/flixel/addons/text/FlxTypeText.hx @@ -325,7 +325,7 @@ class FlxTypeText extends FlxText */ public function resetText(Text:String):Void { - text = ""; + text = prefix; _finalText = Text; _typing = false; _erasing = false; From b35055352e43d57bb80db178c8a5ea4e3a7377a2 Mon Sep 17 00:00:00 2001 From: George FunBook Date: Tue, 10 Dec 2024 09:21:36 -0600 Subject: [PATCH 69/69] changelog --- CHANGELOG.md | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e0f72459..5d3a9c8f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ -3.3.0 (TBD) +3.3.0 (December 10, 2024) ------------------------------ +#### New Features: +- `FlxRadialGauge`: Refactor `FlxPieDial` add replacement ([444](https://github.com/HaxeFlixel/flixel-addons/pull/444)) + - `FlxRadialWipeShader`: Shader that masks sprite radially, can be applied to of any static sprite (doesn't work with animations, yet, but neither did FlxPieDial). Shaders only work on non-Flash targets + - `FlxRadialGauge`: Same as `FlxPieDial` but uses less memory, shows more percentages, and performs better + - `FlxPieDialUtils`: Moved all logic from `FlxPieDial` to a shared util + #### Changes and improvements: - Compatibility with Flixel 5.9.0 ([431](https://github.com/HaxeFlixel/flixel-addons/pull/431))([432](https://github.com/HaxeFlixel/flixel-addons/pull/432))([433](https://github.com/HaxeFlixel/flixel-addons/pull/433))([436](https://github.com/HaxeFlixel/flixel-addons/pull/436))([437](https://github.com/HaxeFlixel/flixel-addons/pull/437))([440](https://github.com/HaxeFlixel/flixel-addons/pull/440))([441](https://github.com/HaxeFlixel/flixel-addons/pull/441)) - Deprecated `FlxRayCastTilemap` @@ -12,11 +18,8 @@ - `TiledLayer`: Add `parallaxX` and `parallaxY` ([449](https://github.com/HaxeFlixel/flixel-addons/pull/449)) - Remove all implicit `Int` casts from/to `FlxDirectionFlags` ([451](https://github.com/HaxeFlixel/flixel-addons/pull/451)) -#### New Features: -- `FlxRadialGauge`: Refactor `FlxPieDial` add replacement ([444](https://github.com/HaxeFlixel/flixel-addons/pull/444)) - - `FlxRadialWipeShader`: Shader that masks sprite radially, can be applied to of any static sprite (doesn't work with animations, yet, but neither did FlxPieDial). Shaders only work on non-Flash targets - - `FlxRadialGauge`: Same as `FlxPieDial` but uses less memory, shows more percentages, and performs better - - `FlxPieDialUtils`: Moved all logic from `FlxPieDial` to a shared util +#### Bugfixes: +- `FlxTypeText`: Honors `prefix` on `reset` calls ([395](https://github.com/HaxeFlixel/flixel-addons/pull/395)) 3.2.3 (May 15, 2024) ------------------------------