本文整理汇总了Python中Game.Game.keyRelease方法的典型用法代码示例。如果您正苦于以下问题:Python Game.keyRelease方法的具体用法?Python Game.keyRelease怎么用?Python Game.keyRelease使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Game.Game
的用法示例。
在下文中一共展示了Game.keyRelease方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ViewMain
# 需要导入模块: from Game import Game [as 别名]
# 或者: from Game.Game import keyRelease [as 别名]
#.........这里部分代码省略.........
else:
None
def giveHint(self):
"""If the player has been stuck on a clue, give a hint"""
text = self.game.story.troubleFindingClue()
self.popupMessage(text, 5*ONE_SECOND)
def popupMessage(self, text, time):
"""Displays the given text for the given time in a popup"""
self.gui.popupText.setPlainText(text)
self.popupTimelineWait.setDuration(time)
self.popupTimelineStart.start()
def keyPressEvent(self, event):
"""Get keyboard events no matter what widget has focus"""
if self.game and (self.gui.stackIndex == self.GAME_PAGE):
self.game.keyPress(event)
#Work around to make load work.
if self.useLoadWorkaround and self.gameWasLoaded:
self.game = Game()
self.connectGame()
self.game.load(self.filename)
debug("use work round")
self.useLoadWorkaround = False
self.overlays['latLongOverlay'] = self.addOverlay(
normpath("images/latOverlayNew.png"))
self.overlays['colorOverlay'] = self.addOverlay(
normpath("images/colorOverlay.png"))
self.overlays['legendOverlay'] = self.addOverlay(
normpath("images/legendOverlayNew.png"))
def keyReleaseEvent(self, event):
"""Get keyboard events no matter what widget has focus"""
if self.game and (self.gui.stackIndex == self.GAME_PAGE):
key = event.key()
if key==Qt.Key_Space or key==Qt.Key_Enter or key==Qt.Key_Return:
self.doSearch()
elif key==Qt.Key_L:
debug('Character location is '
+ `self.game.character.getCenter()`)
else:
self.game.keyRelease(event)
def closeEvent(self, event):
"""Remapping the close event to a message box"""
quit_msg = "Are you sure you want to quit?"
reply = QMessageBox()
reply.setWindowTitle("Quit Game")
reply.setText(quit_msg)
reply.setStandardButtons(
QMessageBox.Save | QMessageBox.Discard | QMessageBox.Cancel)
reply.setDefaultButton(QMessageBox.Save)
ret = reply.exec_()
if ret == QMessageBox.Discard:
debug("Accepting close event")
event.accept()
elif ret == QMessageBox.Cancel:
event.ignore()
else:
if (self.saveFileDialog() == False):
debug("Not quit yet, go back to game...")
event.ignore()
else:
debug("Accepting close event")
event.accept()
def addGraphicsObject(self, name, xval, yval, objType):
"""Add graphics object to the person veiw and map view properly and
leave a graphics object in ViewMain to handle it. """
debug("Receiving passLoc")
graphic = Graphic(xval, yval, str(name), str(objType))
graphic.createInitial(self.gui.personView, self.gui.mapView)
self.graphicsObjects[name] = graphic
self.game.places.locList[str(name)].changePos.connect(
self.updateGraphicsObject)
debug("Connecting Loc to Graphic for " + name)
self.game.places.locList[str(name)].emitter()
def updateGraphicsObject(self, xpos, ypos, name):
"""Changes the position of the character on the screen"""
self.graphicsObjects[name].update(xpos, ypos)
def addOverlay(self, filename):
"""Adds an overlay to the map view"""
obj = self.gui.mapView.scene.addPixmap(QPixmap(filename))
obj.setX(-195)
obj.setY(-250)
obj.setVisible(False)
return obj
def frameUpdate(self):
"""One tick of the game clock sent to the character"""
self.game.character.frameUpdate(self.game.FRAME_RATE)