本文整理汇总了Python中scheduler.Scheduler.tick方法的典型用法代码示例。如果您正苦于以下问题:Python Scheduler.tick方法的具体用法?Python Scheduler.tick怎么用?Python Scheduler.tick使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scheduler.Scheduler
的用法示例。
在下文中一共展示了Scheduler.tick方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Typist
# 需要导入模块: from scheduler import Scheduler [as 别名]
# 或者: from scheduler.Scheduler import tick [as 别名]
class Typist(object):
TARGETS = { 'paper': {
'model': 'paper',
'textureRoot': 'Front',
'scale': Point3(0.85, 0.85, 1),
'hpr' : Point3(0, 0, 0),
}
}
def __init__(self, base, typewriterNP, underDeskClip, sounds):
self.base = base
self.sounds = sounds
self.underDeskClip = underDeskClip
self.typeIndex = 0
self.typewriterNP = typewriterNP
self.rollerAssemblyNP = typewriterNP.find("**/roller assembly")
assert self.rollerAssemblyNP
self.rollerNP = typewriterNP.find("**/roller")
assert self.rollerNP
self.carriageNP = typewriterNP.find("**/carriage")
assert self.carriageNP
self.baseCarriagePos = self.carriageNP.getPos()
self.carriageBounds = self.carriageNP.getTightBounds()
self.font = base.loader.loadFont('Harting.ttf', pointSize=32)
self.pnmFont = PNMTextMaker(self.font)
self.fontCharSize, _, _ = fonts.measureFont(self.pnmFont, 32)
print "font char size: ",self.fontCharSize
self.pixelsPerLine = int(round(self.pnmFont.getLineHeight()))
self.target = None
""" panda3d.core.NodePath """
self.targetRoot = None
""" panda3d.core.NodePath """
self.paperY = 0.0
""" range from 0 to 1 """
self.paperX = 0.0
""" range from 0 to 1 """
self.createRollerBase()
self.tex = None
self.texImage = None
self.setupTexture()
self.scheduler = Scheduler()
task = self.base.taskMgr.add(self.tick, 'timerTask')
task.setDelay(0.01)
def tick(self, task):
self.scheduler.tick(globalClock.getRealTime())
return task.cont
def setupTexture(self):
"""
This is the overlay/decal/etc. which contains the typed characters.
The texture size and the font size are currently tied together.
:return:
"""
self.texImage = PNMImage(1024, 1024)
self.texImage.addAlpha()
self.texImage.fill(1.0)
self.texImage.alphaFill(1.0)
self.tex = Texture('typing')
self.tex.setMagfilter(Texture.FTLinear)
self.tex.setMinfilter(Texture.FTLinear)
self.typingStage = TextureStage('typing')
self.typingStage.setMode(TextureStage.MModulate)
self.tex.load(self.texImage)
# ensure we can quickly update subimages
self.tex.setKeepRamImage(True)
# temp for drawing chars
self.chImage = PNMImage(*self.fontCharSize)
def drawCharacter(self, ch, px, py):
"""
Draw a character onto the texture
:param ch:
:param px: paperX
:param py: paperY
:return: the paper-relative size of the character
"""
h = self.fontCharSize[1]
if ch != ' ':
# position -> pixel, applying margins
x = int(self.tex.getXSize() * (px * 0.8 + 0.1))
y = int(self.tex.getYSize() * (py * 0.8 + 0.1))
#.........这里部分代码省略.........