i have mouse disabled during gameplay and i want to re-enable the mouse when the game is paused so i can move the mouse around to use the menu. i have this code
##############################################
# #IMPORT# #
##############################################
from pandac.PandaModules import Mat4
##############################################
# #External Class IMPORT# #
##############################################
##############################################
# #NEW CLASS# #
##############################################
from Menu import *
class ControlHandler():
fsmState = True
def __init__(self, update, bulletDebugNode):
#args
self.update = update
self.debugNP = bulletDebugNode
self.createControls()
self.singleSM(self.pauseGame, self.resumeGame)
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.props.setCursorHidden(False)
#base.win.requestProperties(self.props)
mat = Mat4(camera.getMat())
mat.invertInPlace()
base.mouseInterfaceNode.setMat(mat)
base.enableMouse()
self.menu = Menu(self.escMenu)
taskMgr.remove('update')
self.menu.loadPauseMenu()
def resumeGame(self):
# taskMgr.add(self.playerList["Player1"].ship.taskTimer, 'ShipTaskTimer')
#self.props.setCursorHidden(True)
# base.win.requestProperties(self.props)
try:
self.menu.destroyAllMenus()
except AttributeError:
print("Nothing to destroy!")
taskMgr.add(self.update, 'update')
base.disableMouse()
def debugBullet(self):
if self.debugNP.isHidden():
self.debugNP.show()
else:
self.debugNP.hide()
def createControls(self):
#Sets up the controls
base.accept("escape", self.escMenu)
base.accept("f1", self.debugBullet)
but when i pause the mouse is still disabled. Any ideas?