本文整理匯總了Python中recorder.Recorder.addFrame方法的典型用法代碼示例。如果您正苦於以下問題:Python Recorder.addFrame方法的具體用法?Python Recorder.addFrame怎麽用?Python Recorder.addFrame使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類recorder.Recorder
的用法示例。
在下文中一共展示了Recorder.addFrame方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: Broadway
# 需要導入模塊: from recorder import Recorder [as 別名]
# 或者: from recorder.Recorder import addFrame [as 別名]
class Broadway(spyral.scene.Scene):
def __init__(self):
"""Initializes cameras"""
spyral.scene.Scene.__init__(self)
self.rootCamera = spyral.director.get_camera()
self.screenCamera= self.rootCamera.make_child();
self.theaterCamera= self.rootCamera.make_child(virtual_size= geom['theater'].size,
real_size= geom['theater'].size,
offset= geom['theater'].topleft,
layers=['upstage','stage','faces','downstage']);
self.recorder= Recorder()
self.preventEscapeLock = False
def on_enter(self):
"""Create the Theater"""
# The theater is the Sypral Group responsible for holding the
# backdrop, actors, and subtitler. It is held by the Script.
self.theater = spyral.sprite.Group(self.theaterCamera)
bg = spyral.util.new_surface(geom['screen'].size)
bg.fill(colors['bg'])
self.screenCamera.set_background(bg)
self.script= script.Script();
self.script.setTheater(self.theater);
self.script.setRecorder(self.recorder)
self.script.default();
self.gui = gui.App(theme=pgu['theme'])
self.guiContainer = gui.Container(align=-1,
valign=-1)
if geom['frame'] != geom['screen']:
images['main-background']= spyral.util.load_image(images['main-background']);
croppedFrame= spyral.util.new_surface(geom['screen'].size);
croppedFrame.blit(images['main-background'], geom['frame'], area=geom['screen']);
images['main-background']= croppedFrame;
self.guiContainer.add(gui.Image(images['main-background']),
*geom['screen'].topleft);
self.guiContainer.add(gui.Image(images['main-tab']),
*geom['tab'].topleft);
# Tab is used to switch between the different panels
self.tab= tab.Tab(self.script);
# Add the tab and panel holder to the screen
self.guiContainer.add(self.tab, *geom['tab'].topleft);
self.guiContainer.add(self.tab.panelHolder, *geom['panel'].topleft);
self.script.gui = self.gui
self.gui.init(self.guiContainer);
#self.recorder.startRecording()
def render(self):
"""
The render function should call .draw() on the scene's group(s) and
camera(s). Unless your game logic should be bound by framerate,
logic should go elsewhere.
"""
self.theater.draw()
if self.recorder.recording == 'Video':
changes = self.rootCamera.draw(True)
self.recorder.addFrame(changes)
else:
self.rootCamera.draw(False)
dirtyGui= self.gui.update(pygame.display.get_surface());
if dirtyGui:
pygame.display.update(dirtyGui);
def confirmQuit(self, okayCallback):
self.script.disableControls()
def quit():
self.script.enableControls()
self.script.refreshTheater()
self.preventEscapeLock= False
d= gui.ConfirmDialog(_("Confirm Quit"), [_("You have unsaved changes!"),
_("If you quit now, you'll lose them forever!"),
_("Are you sure you want to quit?")])
d.connect(gui.CLOSE, quit);
d.okayButton.connect(gui.CLICK, okayCallback)
self.preventEscapeLock= True
d.open();
def update(self, tick):
for event in pygame.event.get():
if event.type == pygame.QUIT:
# Check if quit
if self.script.unsaved:
self.confirmQuit(spyral.director.pop)
else:
spyral.director.pop()
elif event.type == KEYDOWN:
if event.key == K_ESCAPE:
if self.script.unsaved:
self.confirmQuit(spyral.director.pop)
else:
spyral.director.pop()
#.........這裏部分代碼省略.........