Advertisement
EconomicSerg

Main Menu

Aug 3rd, 2021
2,607
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Haxe 1.17 KB | None | 0 0
  1. // Main Menu
  2. // MenuState.hx
  3. package;
  4.  
  5. import flixel.FlxG;
  6. import flixel.FlxState;
  7. import flixel.text.FlxText;
  8. import flixel.ui.FlxButton;
  9.  
  10. class MenuState extends FlxState
  11. {
  12.     var playButton:FlxButton;
  13.     var menuText:FlxText;
  14.    
  15.     override public function create()
  16.     {
  17.         super.create();
  18.        
  19.         playButton = new FlxButton(100, 100, "Play", clickPlay);
  20.         menuText = new FlxText(100, 100, 0, "Main Menu", 46);
  21.        
  22.         add(playButton);
  23.         add(menuText);
  24.     }
  25.    
  26.     function clickPlay()
  27.     {
  28.         FlxG.switchState(new PlayState());
  29.     }
  30.    
  31.     override public function update(elapsed:Float)
  32.     {
  33.         super.update(elapsed);
  34.     }
  35. }
  36.  
  37. // PlayState.hx
  38. package;
  39.  
  40. import flixel.FlxState;
  41. import flixel.text.FlxText;
  42.  
  43. class PlayState extends FlxState
  44. {
  45.     var playText:FlxText;
  46.    
  47.     override public function create()
  48.     {
  49.         super.create();
  50.        
  51.         playText = new FlxText(500, 500, "Play Menu", 64);
  52.         playText.screenCenter();
  53.         add(playText);
  54.     }
  55.    
  56.     override public function update(elapsed:Float)
  57.     {
  58.         super.update(elapsed);
  59.     }
  60. }
  61.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement