Beispiel #1
0
 def initialise(self):
   
   # Background
   self._background = NGUIImage(0, 0, Sprite(ResourceManager.getTexture("planet5521/data/screen.png")))
   self._background.name = "background"
   self._humanView.getPane().addChild(self._background)
   
   # Buttons
   self._startButton = NGUIBasicButton(500, 350, 200, 75, "Start")
   self._exitButton = NGUIBasicButton(500, 450, 200, 75, "Exit")
   
   self._startButton.style = self._exitButton.style =  "default_title"
   self._startButton.styleFocus = self._exitButton.styleFocus = "default_title_focus"
   self._startButton.stylePrimed = self._exitButton.stylePrimed = "default_title_primed"
   self._startButton.backgroundColour = self._exitButton.backgroundColour = Color(80, 25, 25, 100)
   self._startButton.backgroundColourFocus = self._exitButton.backgroundColourFocus = Color(80, 25, 25, 200)
   self._startButton.backgroundColourPrimed = self._exitButton.backgroundColourPrimed = Color(80, 25, 25, 255)
   
   self._humanView.getPane().addChild(self._startButton)
   self._humanView.getPane().addChild(self._exitButton)
   
   self._startButton.addListener(self)
   self._exitButton.addListener(self)
   # Make humanview visible
   self._pm.processList.append(HumanViewProcess(self._humanView)) 
Beispiel #2
0
class MainMenuState(GameState):
  def __init__(self, humanView):
    GameState.__init__(self)
    self._humanView = humanView
  
    
  def initialise(self):
    
    # Background
    self._background = NGUIImage(0, 0, Sprite(ResourceManager.getTexture("planet5521/data/screen.png")))
    self._background.name = "background"
    self._humanView.getPane().addChild(self._background)
    
    # Buttons
    self._startButton = NGUIBasicButton(500, 350, 200, 75, "Start")
    self._exitButton = NGUIBasicButton(500, 450, 200, 75, "Exit")
    
    self._startButton.style = self._exitButton.style =  "default_title"
    self._startButton.styleFocus = self._exitButton.styleFocus = "default_title_focus"
    self._startButton.stylePrimed = self._exitButton.stylePrimed = "default_title_primed"
    self._startButton.backgroundColour = self._exitButton.backgroundColour = Color(80, 25, 25, 100)
    self._startButton.backgroundColourFocus = self._exitButton.backgroundColourFocus = Color(80, 25, 25, 200)
    self._startButton.backgroundColourPrimed = self._exitButton.backgroundColourPrimed = Color(80, 25, 25, 255)
    
    self._humanView.getPane().addChild(self._startButton)
    self._humanView.getPane().addChild(self._exitButton)
    
    self._startButton.addListener(self)
    self._exitButton.addListener(self)
    # Make humanview visible
    self._pm.processList.append(HumanViewProcess(self._humanView)) 
  
  def terminate(self):
    """Does final computation on this game state before it is removed."""
    self._humanView.getPane().clear()
    
  

  def onMouseDownEvent(self, dispatcher, event):
    if dispatcher == self._exitButton:
      self.done = True
    elif dispatcher == self._startButton:
      self._nextState = PlayState(self._humanView)
      self.done = True