Advertisement
Guest User

Untitled

a guest
Jan 31st, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Haxe 1.42 KB | None | 0 0
  1. package screens;
  2. import openfl.display.Sprite;
  3. import openfl.display.Stage;
  4. import openfl.Lib;
  5.  
  6. import openfl.events.Event;
  7. /**
  8.  * ...
  9.  * @author ...
  10.  */
  11. class Screen extends Sprite
  12. {
  13.     var currentStage : Stage;
  14.  
  15.     private function new()
  16.     {
  17.         super();
  18.     }
  19.    
  20.     public function OnLoad(){
  21.         //currentStage = Lib.current.stage;
  22.     }
  23.    
  24.     public function OnDestroy(){
  25.        
  26.     }
  27.    
  28. }
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35. package screens;
  36.  
  37. import openfl.Assets;
  38. import openfl.Lib;
  39.  
  40. import openfl.display.Sprite;
  41. import openfl.display.Bitmap;
  42.  
  43. /**
  44.  * ...
  45.  * @author Gin
  46.  */
  47. class MenuScreen extends Screen
  48. {
  49.  
  50.     public function new()
  51.     {
  52.         super();
  53.         trace("Menu Loaded");
  54.     }
  55.    
  56.     public override function OnLoad(){
  57.  
  58.         ////Background
  59.         currentStage = Lib.current.stage;
  60.         var backgroundImage = new Bitmap(Assets.getBitmapData("assets/img/CG1.png"));
  61.         backgroundImage.height = currentStage.stageHeight;
  62.         backgroundImage.width = currentStage.stageWidth;
  63.         addChild(backgroundImage);
  64.        
  65.         var toGame:Button = new Button(
  66.             Assets.getBitmapData("assets/img/Button.png"),
  67.             Assets.getBitmapData("assets/img/Button_over.png"),
  68.             Assets.getBitmapData("assets/img/Button_pressed.png"),
  69.             "Play",
  70.             onPlayClick );
  71.            
  72.         toGame.x = (currentStage.stageWidth-toGame.width) / 2;
  73.         toGame.y = currentStage.stageHeight / 3;
  74.         addChild( toGame );
  75.        
  76.     }
  77.    
  78.     private function onPlayClick()
  79.     {
  80.         LevelManager.get_instance().NextLevel();
  81.     }
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement