当前位置: 首页>>代码示例>>Python>>正文


Python Menu.loadPauseMenu方法代码示例

本文整理汇总了Python中Menu.loadPauseMenu方法的典型用法代码示例。如果您正苦于以下问题:Python Menu.loadPauseMenu方法的具体用法?Python Menu.loadPauseMenu怎么用?Python Menu.loadPauseMenu使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Menu的用法示例。


在下文中一共展示了Menu.loadPauseMenu方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: ControlHandler

# 需要导入模块: import Menu [as 别名]
# 或者: from Menu import loadPauseMenu [as 别名]
class ControlHandler():
    fsmState = True


    def __init__(self, update, bulletDebugNode, camera, windowProps, player, timerTask, bulletWorld, collisions, music):
        #args
        self.update = update
        self.debugNP = bulletDebugNode
        self.camera = camera
        self.music = music
        #self.cameraTask = camera.thisTask - ill need some camera shit later prolly
        self.wp = windowProps
        self.player = player
        #self.level = level
        self.timerTask = timerTask
        self.world = bulletWorld
        self.collisions = collisions
        self.filters = Filters()

        self.frustumIsEnabled = False

        self.parseControlFile()
        self.createControls()
        self.singleSM(self.pauseGame, self.resumeGame)
        base.messenger.send("1")

    def parseControlFile(self):
        self.f = open("./controls/ControlsFileConfig.txt")
        self.lines = self.f.readlines()
        self.f.close()

        #validLetters = "abcdefghijklmnopqrstuvwxyz"

        #for x in range(len(self.lines)):
         #   for char in self.lines[x]:
          #      for char in validLetters:
           #         self.lines[x] += char

                    #gotta figure out how aND WHY THE NEWLINES ARENT GOIGN AWAY!

        print(self.lines)

        for x in range(len(self.lines)):
            if self.lines[x].strip() == "forward":
                self.forward = str(self.lines[x + 1].rstrip("\n"))

            if self.lines[x].strip() == "reverse":
                self.reverse = str(self.lines[x + 1].rstrip("\n"))

            if self.lines[x].strip() == "left":
                self.left = str(self.lines[x + 1].rstrip("\n"))

            if self.lines[x].strip() == "right":
                self.right = str(self.lines[x + 1].rstrip("\n"))

    def singleSM(self, onFunction, offFunction):
        '''"Single State Machine"
        Takes two methods as args, runs onFunction
        when self.fsmState = False(Default state),
        runs offFunction when self.fsmState = True'''
        if self.fsmState:
            self.fsmState = False
            offFunction()
        else:
            self.fsmState = True
            onFunction()

    def escMenu(self):
        '''Runs functions when escape is pressed'''
        self.singleSM(self.pauseGame, self.resumeGame)

    def pauseGame(self):
        '''Pauses the game by removing any taskmgr'''
        self.wp.setCursorHidden(False)
        base.win.requestProperties(self.wp)

        mat = Mat4(camera.getMat())
        mat.invertInPlace()
        base.mouseInterfaceNode.setMat(mat)
        base.enableMouse()

        self.menu = Menu(self.escMenu, self.wp, self.collisions)
        taskMgr.remove('update')
        taskMgr.remove('timerTask')
        self.menu.loadPauseMenu()

    def resumeGame(self):
        self.wp.setCursorHidden(True)
        base.win.requestProperties(self.wp)
        try:
            self.menu.destroyAllMenus("meh")
        except AttributeError:
            print("Nothing to destroy!")
        taskMgr.add(self.update, 'update')
        taskMgr.add(self.timerTask, 'timerTask')
        base.disableMouse()

    def debugBullet(self):
        if self.debugNP.isHidden():
            self.debugNP.show()
#.........这里部分代码省略.........
开发者ID:flips30240,项目名称:VoxelDash,代码行数:103,代码来源:ControlHandler.py


注:本文中的Menu.loadPauseMenu方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。