本文整理汇总了Python中loader.Loader.preload方法的典型用法代码示例。如果您正苦于以下问题:Python Loader.preload方法的具体用法?Python Loader.preload怎么用?Python Loader.preload使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类loader.Loader
的用法示例。
在下文中一共展示了Loader.preload方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Core
# 需要导入模块: from loader import Loader [as 别名]
# 或者: from loader.Loader import preload [as 别名]
class Core(FSM):
"""knows Menu, Scenario and Loading."""
def __init__(self):
FSM.__init__(self, "Core Game Control")
self.loader = Loader(self.enterScenario)
self.accept('f1', base.toggleWireframe)
self.accept('f2', base.toggleTexture)
self.accept('f3', self.toggleDebug)
self.accept('r', self.clearScene)
def toggleDebug(self):
if self.debugNP.isHidden():
self.debugNP.show()
else:
self.debugNP.hide()
# def popen(self, onExit, popenArgs):
# def runInThread(onExit, popenArgs):
# proc = subprocess.Popen(popenArgs)
# proc.wait()
# onExit()
# return
# thread = threading.Thread(target=runInThread, args=(onExit, popenArgs))
# thread.start()
# # returns immediately after the thread starts
# return thread
def mainLoop(self,task):
dt = self.getDt()
self.doPhysics(dt)
return task.cont
'''FSM'''
def enterLoading(self, scenario):
print 'Loading', scenario
self.loader.preload(scenario)
def exitLoading(self):
pass
# self.loading.destroy()
# del self.loading
# del self.preloader
def enterScenario(self, scene):
self.scene = scene
print 'Enter Scenario'
self.doPhysics = scene.physicsMgr.world.doPhysics
self.getDt = globalClock.getDt
self.debugNP = scene.physicsMgr.debug()
self.scene = scene
self.scene.begin()
self.mainLoop = taskMgr.add( self.mainLoop, 'mainLoop' )
def clearScene(self):
self.debugNP.hide()
taskMgr.remove( self.mainLoop )
del self.mainLoop
del self.scene
self.debugNP.remove()
del self.debugNP
self.demand("Loading", 'scenario01')
def exitScenario(self):
pass
# for child in render.getChildren():
# #if child != base.camera:
# print child, 'removed'
# child.removeNode()
def enterMenu(self, menu, *args):
self.menu = MenuProxy(menu, *args)
#import game.gui as gui
#self.menu = getattr(gui, menu)()
def exitMenu(self):
print 'Exit Menu'