def updateTurnView(self): self.whoseTurnView.clearSubviews() # Remove all objects already on the whosturnView, as we want a clean slate to draw onto turnIcon = NWPi.UIView((0, 0), self.whoseTurnView, (236, 236, 236)) # Create an empty UIView to load the turnview onto if self.turn == "PLAYER1": # Check who's turn it is, and set the background image corresponding. Easy as pi. turnIcon.setBackgroundImage('cross.png') turnIcon.rect.centerx = self.whoseTurnView.rect.width / 2 turnIcon.rect.y = 15 turnText = NWPi.textObject("Player 1 To Move") # Also set the text. turnText.rect.centerx = self.whoseTurnView.rect.width / 2 turnText.rect.y = 85 elif self.turn == "PLAYER2": turnIcon.setBackgroundImage('circle.png') turnIcon.rect.centerx = self.whoseTurnView.rect.width / 2 turnIcon.rect.y = 15 turnText = NWPi.textObject("Player 2 To Move") turnText.rect.centerx = self.whoseTurnView.rect.width / 2 turnText.rect.y = 85 self.whoseTurnView.addSubView(turnIcon) # Add all the subViews, and win. self.whoseTurnView.addSubView(turnText) self.whoseTurnView.updateView() # Finally, update the view so everything blits, and we're good to go :D
def customInitial(self): self.constants = NWPi.constants() text = NWPi.textObject("Layout One", False, True) text.rect.centerx = self.canvas.get_rect().centerx text.rect.y = 200 self.addSubView(text) def backToHome(self, event, caller): if event.type == pygame.MOUSEBUTTONUP: caller.navigationController.makeKeyAndVisible("HOMEVIEWCONTROLLER") homeButton = NWPi.fancyButton(self) homeButton.setText("Go Home!") homeButton.rect.centerx = self.canvas.get_rect().centerx homeButton.rect.y = 450 homeButton.setCustomCallback(backToHome) self.addSubView(homeButton, True)