@@ -3,7 +3,7 @@ import flixel.text.FlxText;
33import flixel .text .FlxTextBorderStyle ;
44import flixel .util .FlxAxes ;
55
6- var pixelScript : Script ;
6+ var pixelScript : Script = game . scripts . getByName ( " pixel.hx " ) ;
77var pauseCam = new FlxCamera ();
88
99var bg : FlxSprite ;
@@ -19,47 +19,40 @@ function create(event) {
1919
2020 event .music = isThorns ? " pixel/LunchboxScary" : " pixel/Lunchbox" ;
2121
22- cameras = [];
23-
24- pixelScript = game .scripts .getByName (" pixel.hx" );
25- pixelScript .call (" pixelCam" , [pauseCam ]);
22+ // allowing this pause script even if the pixel script is not loaded - Nex
23+ pixelScript ?. call (" pixelCam" , [pauseCam ]);
2624
2725 FlxG .cameras .add (pauseCam , false );
26+ cameras = [pauseCam ];
2827
2928 pauseCam .bgColor = isThorns ? 0x88000000 : 0x88FF99CC ;
3029 pauseCam .alpha = 0 ;
3130
32- bg = new FlxSprite (44 * 6 , 14 * 6 );
33- bg .loadGraphic (Paths .image (' stages/school/pause/bg' ));
34- if (isThorns )
35- bg .color = 0xFF000000 ;
31+ bg = new FlxSprite (44 * 6 , 14 * 6 , Paths .image (' stages/school/pause/bg' ));
32+ bg .antialiasing = false ;
33+ if (isThorns ) bg .color = 0xFF000000 ;
3634 bg .scale .set (6 , 6 );
3735 bg .updateHitbox ();
3836 bg .scale .y = 4 ;
39- bg .cameras = [pauseCam ];
4037 add (bg );
4138
4239 songText = new FlxText (0 , 22 * 6 , 0 , " Pause" , 8 , false );
4340 confText (songText );
4441 add (songText );
4542
46- var i = 2 ;
47- for (e in menuItems ) {
48- text = new FlxText (0 , (22 * 6 ) + (i * 9 * 6 ), 0 , e , 8 , false );
43+ for (i => e in menuItems ) {
44+ text = new FlxText (0 , (22 * 6 ) + ((i + 2 ) * 9 * 6 ), 0 , e , 8 , false );
4945 confText (text );
50- add (text );
51- texts .push (text );
52- i ++ ;
5346 }
5447
5548 hand = new FlxSprite ().loadGraphic (Paths .image (' stages/school/ui/hand_textbox' ));
49+ hand .antialiasing = false ;
5650 hand .scale .set (6 , 6 );
5751 hand .updateHitbox ();
5852 add (hand );
5953
60- FlxTween .tween (bg , {" scale.y " : 6 }, 0.75 , {ease : FlxEase .elasticOut });
54+ FlxTween .tween (bg . scale , {y : 6 }, 0.75 , {ease : FlxEase .elasticOut });
6155
62- cameras = [pauseCam ];
6356
6457 FlxG .sound .play (Paths .sound (isThorns ? ' pixel/ANGRY' : ' pixel/clickText' ));
6558}
@@ -70,55 +63,50 @@ function confText(text) {
7063 text .screenCenter (FlxAxes .X );
7164 text .borderStyle = FlxTextBorderStyle .OUTLINE ;
7265 if (! isThorns ) text .borderColor = 0xFF953E3E ;
73- }
7466
75- function destroy () {
76- if ( FlxG . cameras . list . contains ( pauseCam ))
77- FlxG . cameras . remove ( pauseCam );
67+ text . antialiasing = false ;
68+ texts . push ( text );
69+ add ( text );
7870}
7971
72+ function destroy () if (FlxG .cameras .list .contains (pauseCam ))
73+ FlxG .cameras .remove (pauseCam );
74+
8075var canDoShit = true ;
8176var time : Float = 0 ;
8277function update (elapsed ) {
83- pixelScript .call (" postUpdate" , [elapsed ]);
78+ pixelScript ? .call (" postUpdate" , [elapsed ]);
8479
8580 pauseCam .alpha = lerp (pauseCam .alpha , 1 , 0.25 );
8681 time + = elapsed ;
8782
88- var curText = texts [curSelected ];
83+ var curText = texts [curSelected + 1 ];
8984 hand .setPosition (curText .x - hand .width - 18 + (Math .sin (time * Math .PI * 2 ) * 12 ), curText .y + (text .height - hand .height ) - 6 );
9085 hand .x - = hand .x % 6 ;
9186 hand .y - = hand .y % 6 ;
9287
93- if (! canDoShit ) return ;
94- var oldSec = curSelected ;
95-
9688 changeSelection ((controls. UP_P ? - 1 : 0 ) + (controls. DOWN_P ? 1 : 0 ) - FlxG .mouse .wheel );
9789
98- if (oldSec != curSelected )
99- FlxG .sound .play (Paths .sound (isThorns ? ' pixel/type' : ' pixel/pixelText' ));
90+ if (controls. ACCEPT ) enterOption ();
91+ }
92+
93+ var scrollSFX = FlxG .sound .load (Paths .sound (isThorns ? ' pixel/type' : ' pixel/pixelText' ));
94+ function changeSelection (change ) if (canDoShit ) { // this overrides the function inside of the normal pause btw, so no event gets called - Nex
95+ curSelected = FlxMath .wrap (curSelected + change , 0 , menuItems .length - 1 );
96+ if (change != 0 ) scrollSFX .play ();
97+ }
10098
101- if (controls. ACCEPT ) {
102- FlxG .sound .play (Paths .sound (isThorns ? ' pixel/ANGRY' : ' pixel/clickText' ));
103- var option = menuItems [curSelected ];
104- if (option == " Resume" || option == " Exit to menu" ) {
99+ var enterSFX = FlxG .sound .load (Paths .sound (isThorns ? ' pixel/ANGRY' : ' pixel/clickText' ));
100+ function enterOption () if (canDoShit ) {
101+ var option = menuItems [curSelected ];
102+ enterSFX .play ();
103+
104+ switch (option ) {
105+ case " Resume" , " Exit to menu" :
105106 canDoShit = false ;
106107 for (t in texts ) t .visible = false ;
107108 hand .visible = songText .visible = false ;
108- FlxTween .tween (bg , {" scale.y" : 0 }, 0.125 , {ease : FlxEase .cubeOut , onComplete : function () {
109- selectOption ();
110- }});
111- } else {
112- selectOption ();
113- }
109+ FlxTween .tween (bg .scale , {y : 0 }, 0.125 , {ease : FlxEase .cubeOut , onComplete : selectOption });
110+ default : selectOption ();
114111 }
115112}
116-
117- function changeSelection (change ) { // this overrides the function inside of the normal pause btw, so no event gets called - Nex
118- curSelected + = change ;
119-
120- if (curSelected < 0 )
121- curSelected = menuItems .length - 1 ;
122- if (curSelected >= menuItems .length )
123- curSelected = 0 ;
124- }
0 commit comments