本文整理汇总了Python中direct.gui.DirectLabel.reparentTo方法的典型用法代码示例。如果您正苦于以下问题:Python DirectLabel.reparentTo方法的具体用法?Python DirectLabel.reparentTo怎么用?Python DirectLabel.reparentTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类direct.gui.DirectLabel
的用法示例。
在下文中一共展示了DirectLabel.reparentTo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from direct.gui import DirectLabel [as 别名]
# 或者: from direct.gui.DirectLabel import reparentTo [as 别名]
class RaceGUI:
GagPie = 0
gagRoot = 'phase_3.5/maps/inventory_'
class RacerInfo:
def __init__(self, face, mapSpot):
self.curvetime = 0
self.maxlaphit = 0
self.face = face
self.mapspot = mapSpot
self.place = 1
self.enabled = True
self.finished = False
self.gag = None
return
def update(self, curvetime = None, maxlaphit = None, faceX = None, mapspotPt = None, place = None, finished = None):
if self.enabled:
if not curvetime == None:
self.curvetime = curvetime
if not maxlaphit == None:
self.maxlaphit = maxlaphit
if not faceX == None:
self.face.setX(faceX)
if not mapspotPt == None:
self.mapspot.setPos(mapspotPt)
if not place == None:
self.place = place
if not finished == None:
self.finished = finished
return
def disable(self):
self.enabled = False
if not self.finished:
self.face.hide()
self.mapspot.hide()
def enable(self):
self.enabled = True
self.face.show()
self.mapspot.show()
def __init__(self, distRace):
self.race = distRace
self.timerEnabled = False
self.maxLapHit = 0
self.photoFinish = False
toonInteriorTextures = loader.loadModel('phase_3.5/models/modules/toon_interior_textures')
invTextures = loader.loadModel('phase_3.5/models/gui/inventory_icons')
racingTextures = loader.loadModel('phase_6/models/karting/racing_textures')
self.gagTextures = [toonInteriorTextures.find('**/couch'),
invTextures.find('**/inventory_bannana_peel'),
racingTextures.find('**/boost_arrow'),
invTextures.find('**/inventory_anvil'),
invTextures.find('**/inventory_creampie')]
self.gagTextures[1].setScale(7.5)
self.gagTextures[3].setScale(7.5)
self.gagTextures[4].setScale(7.5)
self.cardMaker = CardMaker('card')
self.racerDict = {}
self.render2dRoot = render2d.attachNewNode('RaceGuiRender2dRoot')
self.render2dRoot.setDepthWrite(1)
self.directObjList = []
self.aspect2dRoot = aspect2d.attachNewNode('RaceGuiAspect2dRoot')
self.aspect2dRoot.setDepthWrite(1)
self.raceModeRoot = self.aspect2dRoot.attachNewNode('RaceModeRoot')
gui = loader.loadModel('phase_3.5/models/gui/avatar_panel_gui')
self.closeButton = DirectButton(image=(gui.find('**/CloseBtn_UP'),
gui.find('**/CloseBtn_DN'),
gui.find('**/CloseBtn_Rllvr'),
gui.find('**/CloseBtn_UP')), relief=None, scale=1.05, text=TTLocalizer.KartRace_Leave, text_scale=0.04, text_pos=(0, -0.07), text_fg=VBase4(1, 1, 1, 1), pos=(-0.99, 0, 0.925), command=self.race.leaveRace)
self.closeButton.reparentTo(self.aspect2dRoot)
self.directObjList.append(self.closeButton)
self.raceTimeDelta = 0
self.raceModeReady = False
self.resultModeReady = False
self.gagCycleSound = base.loadSfx('phase_3.5/audio/sfx/tick_counter.ogg')
if hasattr(self.gagCycleSound, 'setPlayRate'):
self.gagCycleSound.setPlayRate(0.2)
self.gagCycleSound.setLoop(1)
self.gagAcquireSound = base.loadSfx('phase_6/audio/sfx/SZ_MM_gliss.ogg')
self.disable()
return
def initRaceMode(self):
self.mapScene = base.a2dTopRight.attachNewNode('MapScene')
self.mapScene.setPos(-0.2, 0, -0.2)
self.mapScene.setScale(0.25, 0.001, 0.25)
maxT = self.race.curve.getMaxT()
pt = Vec3(0, 0, 0)
ls = LineSegs('MapLines')
ls.setColor(1, 1, 1, 1)
ls.setThickness(2)
for x in xrange(101):
self.race.curve.getPoint(x / 100.0 * maxT, pt)
if x == 0:
ls.moveTo(pt[0], pt[1], pt[2])
else:
#.........这里部分代码省略.........
示例2: initRaceMode
# 需要导入模块: from direct.gui import DirectLabel [as 别名]
# 或者: from direct.gui.DirectLabel import reparentTo [as 别名]
def initRaceMode(self):
self.mapScene = base.a2dTopRight.attachNewNode('MapScene')
self.mapScene.setPos(-0.2, 0, -0.2)
self.mapScene.setScale(0.25, 0.001, 0.25)
maxT = self.race.curve.getMaxT()
pt = Vec3(0, 0, 0)
ls = LineSegs('MapLines')
ls.setColor(1, 1, 1, 1)
ls.setThickness(2)
for x in xrange(101):
self.race.curve.getPoint(x / 100.0 * maxT, pt)
if x == 0:
ls.moveTo(pt[0], pt[1], pt[2])
else:
ls.drawTo(pt[0], pt[1], pt[2])
self.mapLines = self.mapScene.attachNewNode(ls.create())
self.mapLines.setScale(0.00025 * RaceGlobals.TrackDict[self.race.trackId][6])
self.mapLines.setP(90)
self.faceStartPos = Vec3(-0.8, 0, 0.93)
self.faceEndPos = Vec3(0.8, 0, 0.93)
self.placeLabelNum = DirectLabel(relief=None, pos=TTLocalizer.RGUIplaceLabelNumPos, text='1', text_scale=0.35, text_fg=(0.95, 0.95, 0, 1), text_font=ToontownGlobals.getSignFont())
self.placeLabelNum.reparentTo(base.a2dBottomLeft)
self.directObjList.append(self.placeLabelNum)
self.placeLabelStr = DirectLabel(relief=None, pos=TTLocalizer.RGUIplaceLabelStrPos, text=TTLocalizer.KartRace_FirstSuffix, text_scale=0.1, text_fg=(0.95, 0.95, 0, 1), text_font=ToontownGlobals.getSignFont())
self.placeLabelStr.reparentTo(base.a2dBottomLeft)
self.directObjList.append(self.placeLabelStr)
self.lapLabel = DirectLabel(relief=None, pos=(-0.22, 0, -0.5), text='1/' + str(self.race.lapCount), text_scale=0.1, text_fg=(0.95, 0.95, 0, 1), text_font=ToontownGlobals.getSignFont())
self.lapLabel.reparentTo(base.a2dTopRight)
self.directObjList.append(self.lapLabel)
self.photoFinishLabel = DirectLabel(relief=None, pos=(0, 0, -0.1), text=TTLocalizer.KartRace_PhotoFinish, text_scale=TTLocalizer.RGUIphotoFinish, text_fg=(0.95, 0.95, 0, 1), text_font=ToontownGlobals.getSignFont())
self.photoFinishLabel.hide()
self.directObjList.append(self.photoFinishLabel)
self.wrongWayLabel = DirectLabel(relief=None, pos=(-0.22, 0, -0.2), text=TTLocalizer.KartRace_WrongWay, text_scale=0.1, text_fg=(0.95, 0, 0, 1), text_font=ToontownGlobals.getSignFont())
self.wrongWayLabel.reparentTo(base.a2dTopRight)
self.directObjList.append(self.wrongWayLabel)
self.wrongWayLabel.setColorScale(Vec4(1, 1, 1, 0))
self.wrongWaySeq = Sequence(self.wrongWayLabel.colorScaleInterval(0.25, colorScale=Vec4(1, 1, 1, 1), startColorScale=Vec4(1, 1, 1, 0)), self.wrongWayLabel.colorScaleInterval(0.25, colorScale=Vec4(1, 1, 1, 0), startColorScale=Vec4(1, 1, 1, 1)))
interpolateFacePos = lambda x: self.faceStartPos * (1.0 - x) + self.faceEndPos * x
self.timeLabels = []
for x in xrange(self.race.lapCount):
minLabel = DirectLabel(relief=None, pos=(interpolateFacePos((2.0 * x + 1) / (self.race.lapCount * 2))[0] - 0.06, 0, 0.84), text="0'", text_scale=0.06, text_fg=(0.95, 0.95, 0, 1), text_font=ToontownGlobals.getSignFont(), text_align=TextNode.ARight)
minLabel.reparentTo(self.raceModeRoot)
self.directObjList.append(minLabel)
secLabel = DirectLabel(relief=None, pos=(interpolateFacePos((2.0 * x + 1) / (self.race.lapCount * 2))[0] + 0.06, 0, 0.84), text="00''", text_scale=0.06, text_fg=(0.95, 0.95, 0, 1), text_font=ToontownGlobals.getSignFont(), text_align=TextNode.ARight)
secLabel.reparentTo(self.raceModeRoot)
self.directObjList.append(secLabel)
fractionLabel = DirectLabel(relief=None, pos=(interpolateFacePos((2.0 * x + 1) / (self.race.lapCount * 2))[0] + 0.14, 0, 0.84), text='00', text_scale=0.06, text_fg=(0.95, 0.95, 0, 1), text_font=ToontownGlobals.getSignFont(), text_align=TextNode.ARight)
fractionLabel.reparentTo(self.raceModeRoot)
self.directObjList.append(fractionLabel)
self.timeLabels.append((minLabel, secLabel, fractionLabel))
self.cardMaker.reset()
self.cardMaker.setName('GagIndicator')
self.cardMaker.setFrame(-0.5, 0.5, -0.5, 0.5)
self.cardMaker.setColor(1, 1, 1, 1)
self.gagPanel = DirectFrame(parent=base.a2dBottomLeft, relief=None, image=loader.loadModel('phase_6/models/karting/gag_panel'), image_scale=0.25, pos=(0.2, 0, 0.55))
self.directObjList.append(self.gagPanel)
self.gag = self.gagPanel.attachNewNode('gag')
self.gag.setScale(0.2)
for gag in self.gagTextures:
gag.reparentTo(self.gag)
gag.hide()
self.cardMaker.reset()
self.cardMaker.setName('RaceProgressLine')
self.cardMaker.setFrame(-0.5, 0.5, -0.5, 0.5)
line = self.raceModeRoot.attachNewNode(self.cardMaker.generate())
line.setScale(self.faceEndPos[0] - self.faceStartPos[0], 1, 0.01)
line.setPos(0, 0, self.faceStartPos[2])
self.cardMaker.setName('RaceProgressLineHash')
for n in xrange(self.race.lapCount + 1):
hash = self.raceModeRoot.attachNewNode(self.cardMaker.generate())
hash.setScale(line.getScale()[2], 1, line.getScale()[2] * 5)
t = float(n) / self.race.lapCount
hash.setPos(self.faceStartPos[0] * (1 - t) + self.faceEndPos[0] * t, self.faceStartPos[1], self.faceStartPos[2])
self.raceModeReady = True
self.disable()
return