From dae67f5a4ce215202048a0210c75fa4a0d640427 Mon Sep 17 00:00:00 2001 From: NeeEoo Date: Mon, 12 Jun 2023 19:01:10 +0200 Subject: [PATCH 01/12] 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 02/12] 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 03/12] 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 04/12] 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 05/12] 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<)`0ozd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fbWS$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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BlM$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~*=Ldzu5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^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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Vx!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 06/12] 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 07/12] 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 08/12] 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 09/12] 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 10/12] 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 11/12] 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 12/12] 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))