当前位置: 首页>>代码示例>>Python>>正文


Python DirectLabel.DirectLabel类代码示例

本文整理汇总了Python中direct.gui.DirectLabel.DirectLabel的典型用法代码示例。如果您正苦于以下问题:Python DirectLabel类的具体用法?Python DirectLabel怎么用?Python DirectLabel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了DirectLabel类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: CogdoMazeBossGui

class CogdoMazeBossGui(DirectFrame):

    def __init__(self, code):
        DirectFrame.__init__(self, relief=None, state=DGG.NORMAL, sortOrder=DGG.BACKGROUND_SORT_INDEX)
        self._code = str(code)
        self._codeLength = len(self._code)
        self._markersShown = 0
        self._markers = []
        self._initModel()
        self.setPos(*Globals.BossGuiPos)
        self.setScale(Globals.BossGuiScale)
        self.hide()

    def destroy(self):
        ToontownIntervals.cleanup('bosscodedoor')
        self._model.removeNode()
        del self._model
        self._titleLabel.removeNode()
        del self._titleLabel
        for marker in self._markers:
            marker.destroy()

        del self._markers
        DirectFrame.destroy(self)

    def _initModel(self):
        codeFrameGap = Globals.BossCodeFrameGap
        codeFrameWidth = Globals.BossCodeFrameWidth
        self._model = CogdoUtil.loadMazeModel('bossCog', group='gui')
        self._model.reparentTo(self)
        self._model.find('**/frame').setBin('fixed', 1)
        titleLabelPos = self._model.find('**/title_label_loc').getPos()
        self._titleLabel = DirectLabel(parent=self, relief=None, scale=Globals.BossGuiTitleLabelScale, text=TTLocalizer.CogdoMazeGameBossGuiTitle.upper(), pos=titleLabelPos, text_align=TextNode.ACenter, text_fg=(0, 0, 0, 1), text_shadow=(0, 0, 0, 0), text_font=ToontownGlobals.getSuitFont())
        self._titleLabel.setBin('fixed', 1)
        bossCard = self._model.find('**/bossCard')
        self._openDoor = self._model.find('**/doorOpen')
        self._closedDoor = self._model.find('**/doorClosed')
        self._openDoor.stash()
        spacingX = codeFrameWidth + codeFrameGap
        startX = -0.5 * ((self._codeLength - 1) * spacingX - codeFrameGap)
        for i in range(self._codeLength):
            marker = CogdoMazeBossCodeFrame(i, self._code[i], bossCard)
            marker.reparentTo(self)
            marker.setPos(bossCard, startX + spacingX * i, 0, 0)
            self._markers.append(marker)

        bossCard.removeNode()

    def showHit(self, bossIndex):
        self._markers[bossIndex].setHit(True)

    def showNumber(self, bossIndex):
        self._markers[bossIndex].setHit(False)
        self._markers[bossIndex].showNumber()
        self._markersShown += 1
        if self._markersShown == self._codeLength:
            self._openDoor.unstash()
            self._closedDoor.stash()
            ToontownIntervals.start(ToontownIntervals.getPulseLargerIval(self._openDoor, 'bosscodedoor'))
开发者ID:Toonerz,项目名称:Toontown-World-Online-Leak,代码行数:59,代码来源:CogdoMazeGameGuis.py

示例2: __init__

class ScavengerHuntEffect:
    images = None

    def __init__(self, beanAmount):
        if not ScavengerHuntEffect.images:
            ScavengerHuntEffect.images = loader.loadModel('phase_4/models/props/tot_jar')

        self.npRoot = DirectFrame(parent=aspect2d, relief=None, scale=0.75, pos=(0, 0, 0.6))

        if beanAmount > 0:
            self.npRoot.setColorScale(VBase4(1, 1, 1, 0))
            self.jar = DirectFrame(parent=self.npRoot, relief=None, image=ScavengerHuntEffect.images.find('**/tot_jar'))
            self.jar.hide()
            self.eventImage = NodePath('EventImage')
            self.eventImage.reparentTo(self.npRoot)
            self.countLabel = DirectLabel(parent=self.jar, relief=None, text='+0', text_pos=(0.02, -0.2), text_scale=0.25, text_fg=(0.95, 0.0, 0, 1), text_font=ToontownGlobals.getSignFont())

            def countUp(t, startVal, endVal):
                beanCountStr = startVal + t * (endVal - startVal)
                self.countLabel['text'] = '+' + `(int(beanCountStr))`

            def setCountColor(color):
                self.countLabel['text_fg'] = color

            self.track = Sequence(LerpColorScaleInterval(self.npRoot, 1, colorScale=VBase4(1, 1, 1, 1), startColorScale=VBase4(1, 1, 1, 0)), Wait(1), Func(self.jar.show), LerpColorScaleInterval(self.eventImage, 1, colorScale=VBase4(1, 1, 1, 0), startColorScale=VBase4(1, 1, 1, 1)), Parallel(LerpScaleInterval(self.npRoot, 1, scale=0.5, startScale=0.75), LerpPosInterval(self.npRoot, 1, pos=VBase3(-0.9, 0, -0.83))), LerpFunc(countUp, duration=2, extraArgs=[0, beanAmount]), Func(setCountColor, VBase4(0.95, 0.95, 0, 1)), Wait(3), Func(self.destroy))
        else:
            self.npRoot.setColorScale(VBase4(1, 1, 1, 0))
            self.attemptFailedMsg()
            self.track = Sequence(LerpColorScaleInterval(self.npRoot, 1, colorScale=VBase4(1, 1, 1, 1), startColorScale=VBase4(1, 1, 1, 0)), Wait(5), LerpColorScaleInterval(self.npRoot, 1, colorScale=VBase4(1, 1, 1, 0), startColorScale=VBase4(1, 1, 1, 1)), Func(self.destroy))

    def play(self):
        if self.npRoot:
            self.track.start()

    def stop(self):
        if self.track != None and self.track.isPlaying():
            self.track.finish()

    def destroy(self):
        self.stop()
        self.track = None

        if hasattr(self, 'eventImage') and self.eventImage:
            self.eventImage.detachNode()
            del self.eventImage
        if hasattr(self, 'countLabel') and self.countLabel:
            self.countLabel.destroy()
            del self.countLabel
        if hasattr(self, 'jar') and self.jar:
            self.jar.destroy()
            del self.jar
        if hasattr(self, 'npRoot') and self.npRoot:
            self.npRoot.destroy()
            del self.npRoot
开发者ID:ToontownBattlefront,项目名称:Toontown-Battlefront,代码行数:54,代码来源:ScavengerHuntEffects.py

示例3: __init__

    def __init__(self):
        #
        # Player status section
        #
        heartscale = (0.1, 1, 0.1)
        self.heart1 = OnscreenImage(
            image = "HeartIcon.png",
            scale = heartscale,
            pos = (0.2, 0, -0.15))
        self.heart1.setTransparency(True)
        self.heart1.reparentTo(base.a2dTopLeft)
        self.heart2 = OnscreenImage(
            image = "HeartIcon.png",
            scale = heartscale,
            pos = (0.45, 0, -0.15))
        self.heart2.setTransparency(True)
        self.heart2.reparentTo(base.a2dTopLeft)
        self.heart3 = OnscreenImage(
            image = "HeartIcon.png",
            scale = heartscale,
            pos = (0.7, 0, -0.15))
        self.heart3.setTransparency(True)
        self.heart3.reparentTo(base.a2dTopLeft)

        self.keys = DirectLabel(
            text = "x0",
            frameColor = (0, 0, 0, 0),
            text_fg = (1, 1, 1, 1),
            text_scale = 1.8,
            text_pos = (1, -0.25, 0),
            text_align = TextNode.ALeft,
            image = "Keys.png",
            pos = (0.2, 0, -0.4))
        self.keys.setScale(0.085)
        self.keys.setTransparency(True)
        self.keys.reparentTo(base.a2dTopLeft)

        self.actionKey = DirectLabel(
            frameColor = (0, 0, 0, 0),
            text_fg = (1, 1, 1, 1),
            scale = 0.15,
            pos = (0, 0, 0.15),
            text = _("Action: E/Enter"))
        self.actionKey.setTransparency(True)
        self.actionKey.reparentTo(base.a2dBottomCenter)
        self.actionKey.hide()
开发者ID:grimfang,项目名称:owp_ajaw,代码行数:46,代码来源:hud.py

示例4: __init__

 def __init__(self, phaseNames):
     self.phaseNames = phaseNames
     self.model = loader.loadModel('models/gui/pir_m_gui_gen_loadingBar')
     bar = self.model.findTexture('pir_t_gui_gen_loadingBar')
     self.model.find('**/loading_bar').hide()
     self.topFrame = DirectFrame(parent = base.a2dTopRight, pos = (-0.80000000000000004, 0, -0.10000000000000001), sortOrder = NO_FADE_SORT_INDEX + 1)
     self.text = DirectLabel(relief = None, parent = self.topFrame, guiId = 'DownloadWatcherText', pos = (0, 0, 0), text = '                     ', text_fg = (1, 1, 1, 1), text_shadow = (0, 0, 0, 1), text_scale = 0.040000000000000001, textMayChange = 1, text_align = TextNode.ARight, text_pos = (0.17000000000000001, 0), sortOrder = 2)
     self.bar = DirectWaitBar(relief = None, parent = self.topFrame, guiId = 'DownloadWatcherBar', pos = (0, 0, 0), frameSize = (-0.40000000000000002, 0.38, -0.044999999999999998, 0.065000000000000002), borderWidth = (0.02, 0.02), range = 100, frameColor = (1, 1, 1, 1), barColor = (0, 0.29999999999999999, 0, 1), barTexture = bar, geom = self.model, geom_scale = 0.089999999999999997, geom_pos = (-0.014, 0, 0.01), text = '0%', text_scale = 0.040000000000000001, text_fg = (1, 1, 1, 1), text_align = TextNode.ALeft, text_pos = (0.19, 0), sortOrder = 1)
     self.bgFrame = DirectFrame(relief = DGG.FLAT, parent = self.topFrame, pos = (0, 0, 0), frameColor = (0.5, 0.27000000000000002, 0.35999999999999999, 0.20000000000000001), frameSize = (-0.44, 0.39000000000000001, -0.035999999999999997, 0.056000000000000001), borderWidth = (0.02, 0.02), scale = 0.90000000000000002, sortOrder = 0)
     self.accept('launcherPercentPhaseComplete', self.update)
开发者ID:Puggyblue999,项目名称:PiratesOfTheCarribeanOnline,代码行数:10,代码来源:PiratesDownloadWatcher.py

示例5: PiratesDownloadWatcher

class PiratesDownloadWatcher(DownloadWatcher.DownloadWatcher):
    positions = [
        (Point3(1, 0, 0.90000000000000002), Point3(1, 0, 0.90000000000000002)),
        (Point3(1, 0, 0.90000000000000002), Point3(1, 0, 0.90000000000000002)),
        (Point3(1, 0, 0.90000000000000002), Point3(1, 0, 0.90000000000000002))]
    
    def __init__(self, phaseNames):
        self.phaseNames = phaseNames
        self.model = loader.loadModel('models/gui/pir_m_gui_gen_loadingBar')
        bar = self.model.findTexture('pir_t_gui_gen_loadingBar')
        self.model.find('**/loading_bar').hide()
        self.topFrame = DirectFrame(parent = base.a2dTopRight, pos = (-0.80000000000000004, 0, -0.10000000000000001), sortOrder = NO_FADE_SORT_INDEX + 1)
        self.text = DirectLabel(relief = None, parent = self.topFrame, guiId = 'DownloadWatcherText', pos = (0, 0, 0), text = '                     ', text_fg = (1, 1, 1, 1), text_shadow = (0, 0, 0, 1), text_scale = 0.040000000000000001, textMayChange = 1, text_align = TextNode.ARight, text_pos = (0.17000000000000001, 0), sortOrder = 2)
        self.bar = DirectWaitBar(relief = None, parent = self.topFrame, guiId = 'DownloadWatcherBar', pos = (0, 0, 0), frameSize = (-0.40000000000000002, 0.38, -0.044999999999999998, 0.065000000000000002), borderWidth = (0.02, 0.02), range = 100, frameColor = (1, 1, 1, 1), barColor = (0, 0.29999999999999999, 0, 1), barTexture = bar, geom = self.model, geom_scale = 0.089999999999999997, geom_pos = (-0.014, 0, 0.01), text = '0%', text_scale = 0.040000000000000001, text_fg = (1, 1, 1, 1), text_align = TextNode.ALeft, text_pos = (0.19, 0), sortOrder = 1)
        self.bgFrame = DirectFrame(relief = DGG.FLAT, parent = self.topFrame, pos = (0, 0, 0), frameColor = (0.5, 0.27000000000000002, 0.35999999999999999, 0.20000000000000001), frameSize = (-0.44, 0.39000000000000001, -0.035999999999999997, 0.056000000000000001), borderWidth = (0.02, 0.02), scale = 0.90000000000000002, sortOrder = 0)
        self.accept('launcherPercentPhaseComplete', self.update)

    
    def update(self, phase, percent, reqByteRate, actualByteRate):
        phaseName = self.phaseNames[phase]
        self.text['text'] = OTPLocalizer.DownloadWatcherUpdate % phaseName + '  -'
        self.bar['text'] = '%s %%' % percent
        self.bar['value'] = percent

    
    def foreground(self):
        self.topFrame.reparentTo(base.a2dpTopRight)
        self.topFrame.setBin('gui-fixed', 55)
        self.topFrame['sortOrder'] = NO_FADE_SORT_INDEX + 1

    
    def background(self):
        self.topFrame.reparentTo(base.a2dTopRight)
        self.topFrame.setBin('unsorted', 49)
        self.topFrame['sortOrder'] = -1

    
    def cleanup(self):
        self.text.destroy()
        self.bar.destroy()
        self.bgFrame.destroy()
        self.topFrame.destroy()
        self.ignoreAll()
开发者ID:Puggyblue999,项目名称:PiratesOfTheCarribeanOnline,代码行数:43,代码来源:PiratesDownloadWatcher.py

示例6: __init__

    def __init__(self):

        self.winXhalf = base.win.getXSize() / 2
        self.winYhalf = base.win.getYSize() / 2

        croshairsize = 0.05#17.0

        self.crosshair = OnscreenImage(
            image = os.path.join("..", "data", "crosshair.png"),
            scale = (croshairsize, 1, croshairsize),
            #pos = (self.winXhalf - croshairsize/2.0, 0, -self.winYhalf - croshairsize/2.0)
            pos = (0, 0, 0)
            )
        self.crosshair.setTransparency(1)

        self.ammo = DirectLabel(
            scale = 0.15,
            text = "100/100",
            pos = (base.a2dLeft + 0.025, 0.0, base.a2dBottom + 0.05),
            text_align = TextNode.ALeft,
            frameColor = (0, 0, 0, 0),
            text_fg = (1,1,1,1),
            text_shadow = (0, 0, 0, 1),
            text_shadowOffset = (0.05, 0.05)
            )
        self.ammo.setTransparency(1)

        self.nowPlaying = DirectLabel(
            scale = 0.05,
            text = "Now Playing: Echovolt - Nothing to Fear",
            pos = (base.a2dLeft + 0.025, 0.0, base.a2dTop - 0.05),
            text_align = TextNode.ALeft,
            frameColor = (0, 0, 0, 0),
            text_fg = (1,1,1,1)
            )
        self.nowPlaying.setTransparency(1)

        self.accept("window-event", self.recalcAspectRatio)
        self.hide()
开发者ID:grimfang,项目名称:Paintball,代码行数:39,代码来源:hud.py

示例7: __init__

    def __init__(self):
        #self.accept("RatioChanged", self.recalcAspectRatio)
        self.accept("window-event", self.recalcAspectRatio)

        self.frameMain = DirectFrame(
            # size of the frame
            frameSize = (base.a2dLeft, base.a2dRight,
                         base.a2dTop, base.a2dBottom),
            # position of the frame
            pos = (0, 0, 0),
            # tramsparent bg color
            frameColor = (0, 0, 0, 0),
            sortOrder = 0)

        self.background = OnscreenImage("MenuBGLogo.png")
        self.background.reparentTo(self.frameMain)

        self.nowPlaying = DirectLabel(
            scale = 0.05,
            text = "Now Playing: Eraplee Noisewall Orchestra - Bermuda Fire",
            pos = (base.a2dLeft + 0.025, 0.0, base.a2dBottom + 0.05),
            text_align = TextNode.ALeft,
            frameColor = (0, 0, 0, 0),
            text_fg = (1,1,1,1)
            )
        self.nowPlaying.setTransparency(1)
        self.nowPlaying.reparentTo(self.frameMain)

        maps = loader.loadModel('button_maps.egg')
        btnGeom = (maps.find('**/ButtonReady'),
                    maps.find('**/ButtonClick'),
                    maps.find('**/ButtonRollover'),
                    maps.find('**/ButtonDisabled'))

        self.btnStart = self.createButton("Start", btnGeom, 0.25, self.btnStart_Click)
        self.btnStart.reparentTo(self.frameMain)

        self.btnQuit = self.createButton("Quit", btnGeom, -0.25, self.btnQuit_Click)
        self.btnQuit.reparentTo(self.frameMain)

        self.recalcAspectRatio(base.win)

        # hide all buttons at startup
        self.hide()
开发者ID:grimfang,项目名称:Paintball,代码行数:44,代码来源:menu.py

示例8: _initModel

    def _initModel(self):
        codeFrameGap = Globals.BossCodeFrameGap
        codeFrameWidth = Globals.BossCodeFrameWidth
        self._model = CogdoUtil.loadMazeModel('bossCog', group='gui')
        self._model.reparentTo(self)
        self._model.find('**/frame').setBin('fixed', 1)
        titleLabelPos = self._model.find('**/title_label_loc').getPos()
        self._titleLabel = DirectLabel(parent=self, relief=None, scale=Globals.BossGuiTitleLabelScale, text=TTLocalizer.CogdoMazeGameBossGuiTitle.upper(), pos=titleLabelPos, text_align=TextNode.ACenter, text_fg=(0, 0, 0, 1), text_shadow=(0, 0, 0, 0), text_font=ToontownGlobals.getSuitFont())
        self._titleLabel.setBin('fixed', 1)
        bossCard = self._model.find('**/bossCard')
        self._openDoor = self._model.find('**/doorOpen')
        self._closedDoor = self._model.find('**/doorClosed')
        self._openDoor.stash()
        spacingX = codeFrameWidth + codeFrameGap
        startX = -0.5 * ((self._codeLength - 1) * spacingX - codeFrameGap)
        for i in range(self._codeLength):
            marker = CogdoMazeBossCodeFrame(i, self._code[i], bossCard)
            marker.reparentTo(self)
            marker.setPos(bossCard, startX + spacingX * i, 0, 0)
            self._markers.append(marker)

        bossCard.removeNode()
开发者ID:Toonerz,项目名称:Toontown-World-Online-Leak,代码行数:22,代码来源:CogdoMazeGameGuis.py

示例9: __init__

    def __init__(self):
        self.canPlantLabel = DirectLabel(
            frameColor=(0, 0, 0, 0.25),
            text_fg=(1, 1, 1, 1),
            scale=0.15,
            pos=(0, 0, 0.25),
            pad=(0.2,0.2),
            text=_("Plant Seed"))
        self.canPlantLabel.setTransparency(True)
        self.canPlantLabel.reparentTo(base.a2dBottomCenter)
        self.canPlantLabel.hide()

        self.speekLabel = DirectLabel(
            frameColor=(0, 0, 0, 0.25),
            text_fg=(1, 1, 1, 1),
            scale=0.15,
            pos=(0, 0, 0.5),
            pad=(0.2,0.2),
            text="...")
        self.speekLabel.reparentTo(render)
        self.speekLabel.hide()
        self.speekLabel.setTransparency(True)
        self.speekLabel.setEffect(BillboardEffect.makePointEye())
        self.speekLabel.setBin("fixed", 11)
        self.speekLabel.setDepthWrite(False)

        self.storyText = DirectLabel(
            frameColor=(0, 0, 0, 0.25),
            text_fg=(1, 1, 1, 1),
            scale=0.08,
            pos=(0, 0, 0.25),
            pad=(0.2,0.2),
            text="Story text")
        self.storyText.setTransparency(True)
        self.storyText.reparentTo(base.a2dBottomCenter)
        self.storyText.hide()

        self.points = DirectLabel(
            frameColor=(0, 0, 0, 0.25),
            text_fg=(1, 1, 1, 1),
            scale=0.075,
            pos=(0.05, 0, -0.1),
            pad=(0.2,0.2),
            text_align=TextNode.ALeft,
            text=_("Points: %d")%0)
        self.points.setTransparency(True)
        self.points.reparentTo(base.a2dTopLeft)

        self.playerWater = DirectLabel(
            frameColor=(0, 0, 0, 0.25),
            text_fg=(1, 1, 1, 1),
            scale=0.075,
            pos=(0.05, 0, -0.2),
            pad=(0.2,0.2),
            text_align=TextNode.ALeft,
            text=_("Remaining Water: %d")%100)
        self.playerWater.setTransparency(True)
        self.playerWater.reparentTo(base.a2dTopLeft)


        self.helpInfo = DirectLabel(
            frameColor=(0, 0, 0, 0.25),
            text_fg=(1, 1, 1, 1),
            scale=0.075,
            pos=(-0.05, 0, -0.1),
            pad=(0.2,0.2),
            text_align=TextNode.ARight,
            text=_("F1 - show help"))
        self.helpInfo.setTransparency(True)
        self.helpInfo.reparentTo(base.a2dTopRight)

        self.hide()
开发者ID:grimfang,项目名称:pyweek21,代码行数:72,代码来源:hud.py

示例10: HUD

class HUD():
    def __init__(self):
        self.canPlantLabel = DirectLabel(
            frameColor=(0, 0, 0, 0.25),
            text_fg=(1, 1, 1, 1),
            scale=0.15,
            pos=(0, 0, 0.25),
            pad=(0.2,0.2),
            text=_("Plant Seed"))
        self.canPlantLabel.setTransparency(True)
        self.canPlantLabel.reparentTo(base.a2dBottomCenter)
        self.canPlantLabel.hide()

        self.speekLabel = DirectLabel(
            frameColor=(0, 0, 0, 0.25),
            text_fg=(1, 1, 1, 1),
            scale=0.15,
            pos=(0, 0, 0.5),
            pad=(0.2,0.2),
            text="...")
        self.speekLabel.reparentTo(render)
        self.speekLabel.hide()
        self.speekLabel.setTransparency(True)
        self.speekLabel.setEffect(BillboardEffect.makePointEye())
        self.speekLabel.setBin("fixed", 11)
        self.speekLabel.setDepthWrite(False)

        self.storyText = DirectLabel(
            frameColor=(0, 0, 0, 0.25),
            text_fg=(1, 1, 1, 1),
            scale=0.08,
            pos=(0, 0, 0.25),
            pad=(0.2,0.2),
            text="Story text")
        self.storyText.setTransparency(True)
        self.storyText.reparentTo(base.a2dBottomCenter)
        self.storyText.hide()

        self.points = DirectLabel(
            frameColor=(0, 0, 0, 0.25),
            text_fg=(1, 1, 1, 1),
            scale=0.075,
            pos=(0.05, 0, -0.1),
            pad=(0.2,0.2),
            text_align=TextNode.ALeft,
            text=_("Points: %d")%0)
        self.points.setTransparency(True)
        self.points.reparentTo(base.a2dTopLeft)

        self.playerWater = DirectLabel(
            frameColor=(0, 0, 0, 0.25),
            text_fg=(1, 1, 1, 1),
            scale=0.075,
            pos=(0.05, 0, -0.2),
            pad=(0.2,0.2),
            text_align=TextNode.ALeft,
            text=_("Remaining Water: %d")%100)
        self.playerWater.setTransparency(True)
        self.playerWater.reparentTo(base.a2dTopLeft)


        self.helpInfo = DirectLabel(
            frameColor=(0, 0, 0, 0.25),
            text_fg=(1, 1, 1, 1),
            scale=0.075,
            pos=(-0.05, 0, -0.1),
            pad=(0.2,0.2),
            text_align=TextNode.ARight,
            text=_("F1 - show help"))
        self.helpInfo.setTransparency(True)
        self.helpInfo.reparentTo(base.a2dTopRight)

        self.hide()

    def show(self):
        self.points.show()
        self.playerWater.show()
        self.helpInfo.show()

    def hide(self):
        self.points.hide()
        self.playerWater.hide()
        self.helpInfo.hide()

    def hideAll(self):
        self.canPlantLabel.hide()
        self.speekLabel.hide()
        self.points.hide()
        self.playerWater.hide()
        self.helpInfo.hide()

    def showStory(self):
        self.storyText.show()

    def hideStory(self):
        self.storyText.hide()

    def cleanup(self):
        self.hideAll()
        self.canPlantLabel.destroy()
#.........这里部分代码省略.........
开发者ID:grimfang,项目名称:pyweek21,代码行数:101,代码来源:hud.py

示例11: __init__

  def __init__(self,pos=None,mass=1,maxforce=0.1,maxspeed=1,radius=1,
         avoidVehicles=True,avoidObstacles=True,container=None):
    """Initialise the vehicle."""

    self.mass = mass # mass = 1 means that acceleration = force
    self.maxforce = maxforce
    self.maxspeed = maxspeed
    self.radius = radius
    self.avoidVehicles = avoidVehicles # Avoid colliding with other Vehicles
    self.avoidObstacles = avoidObstacles # Avoid colliding with obstacles
    if pos is None: pos = Point3(0,0,0)
    # The Vehicle controls a primary NodePath to which other NodePath's for
    # CollisionSolids are parented. Other nodes, such as animated Actors,
    # can be attached to this NodePath by user classes.
    self.prime = NodePath('Vehicle primary NodePath')
    self.prime.reparentTo(render)
    self.prime.setPos(pos)
    # If the Vehicle finds itself outside of its container it will turn
    # back toward the container. The vehicle also stays within the global
    # container at all times. The idea is that Vehicle.container can be
    # used to restrict one particular vehicle to a space smaller than the
    # global container.
    self.container = container

    self._pos = SteerVec(pos.getX(),pos.getY()) # 2D pos for steering
                          # calculations

    self._velocity = SteerVec(0,0)
    self._steeringforce = SteerVec(0,0)
    self._steeringbehavior = []

    # Some steering behaviors make use of self._target, which can be
    # another Vehicle or a point in 2-space (SteerVec), or it might be None
    # indicating that no target is currently in use.
    self._target = None

    # Initialise the Vehicle's CollisionRay which is used with a
    # CollisionHandlerFloor to keep the Vehicle on the ground.
    self.raynp = self.prime.attachNewNode(CollisionNode('colNode'))
    self.raynp.node().addSolid(CollisionRay(0,0,3,0,0,-1))
    self.floorhandler = CollisionHandlerFloor()
    self.floorhandler.addCollider(self.raynp,self.prime)
    cTrav.addCollider(self.raynp,self.floorhandler)
    # Uncomment this line to show the CollisionRay:
    #self.raynp.show()

    # We only want our CollisionRay to collide with the collision
    # geometry of the terrain only, se we set a mask here.
    self.raynp.node().setFromCollideMask(floorMASK)
    self.raynp.node().setIntoCollideMask(offMASK)

    # Initialise CollisionTube for detecting oncoming obstacle collisions.
    x,y,z = self.prime.getX(),self.prime.getY(),self.prime.getZ()+3 #FIXME: Don't hardcode how high the tube goes, add height parameter to __init__ for both tube and sphere
    vx,vy = self._velocity.getX(),self._velocity.getY()
    r = self.radius
    f = self.prime.getNetTransform().getMat().getRow3(1)
    s = 10
    self.tube = CollisionTube(x,y,z,x+f.getX()*s,y+f.getY()*s,z,self.radius)
    self.tubenp = self.prime.attachNewNode(CollisionNode('colNode'))
    self.tubenp.node().addSolid(self.tube)
    # The tube should only collide with obstacles (and is an 'into' object)
    self.tubenp.node().setFromCollideMask(offMASK)
    self.tubenp.node().setIntoCollideMask(obstacleMASK)
    # Uncomment this line to show the CollisionTube
    #self.tubenp.show()

    # CollisionSphere for detecting when we've actuallyt collided with
    # something.
    self.sphere = CollisionSphere(x,y,z,self.radius)
    self.spherenp = self.prime.attachNewNode(CollisionNode('cnode'))
    self.spherenp.node().addSolid(self.sphere)
    # Only collide with the CollisionSphere's of other vehicles.
    self.spherenp.node().setFromCollideMask(obstacleMASK) # So the spheres of vehicles will collide with eachother
    self.spherenp.node().setIntoCollideMask(obstacleMASK) # So obstacles will collide into spheres of vehicles
    cTrav.addCollider(self.spherenp,collisionHandler)
    # Uncomment this line to show the CollisionSphere
    #self.spherenp.show()

    # Add a task for this Vehicle to the global task manager.
    self._prevtime = 0
    self.stepTask=taskMgr.add(self._step,"Vehicle step task")

    # Add the Vehicle to the global list of Vehicles
    vehicles.append(self)

    # Initialise the DirectLabel used when annotating the Vehicle
    # FIXME: Needs to be destroyed in self.destroy
    self.text = "no steering"
    self.label = DirectLabel(parent=self.prime,pos=(4,4,4),text=self.text,
                 text_wordwrap=10,relief=None,
                 text_scale=(1.5,1.5),text_frame=(0,0,0,1),
                 text_bg=(1,1,1,1))
    self.label.component('text0').textNode.setCardDecal(1)
    self.label.setBillboardAxis()
    self.label.hide()
    self.label.setLightOff(1)

    # A second label for speaking ('Ouch!', 'Sorry!' etc.)
    self.callout = DirectLabel(parent=self.prime,pos=(4,4,4),text='',
                 text_wordwrap=10,relief=None,
#.........这里部分代码省略.........
开发者ID:kengleason,项目名称:PandaSteer,代码行数:101,代码来源:vehicle.py

示例12: Menu

class Menu(DirectObject):
    def __init__(self):
        #self.accept("RatioChanged", self.recalcAspectRatio)
        self.accept("window-event", self.recalcAspectRatio)

        self.frameMain = DirectFrame(
            # size of the frame
            frameSize = (base.a2dLeft, base.a2dRight,
                         base.a2dTop, base.a2dBottom),
            # position of the frame
            pos = (0, 0, 0),
            # tramsparent bg color
            frameColor = (0, 0, 0, 0),
            sortOrder = 0)

        self.background = OnscreenImage("MenuBGLogo.png")
        self.background.reparentTo(self.frameMain)

        self.nowPlaying = DirectLabel(
            scale = 0.05,
            text = "Now Playing: Eraplee Noisewall Orchestra - Bermuda Fire",
            pos = (base.a2dLeft + 0.025, 0.0, base.a2dBottom + 0.05),
            text_align = TextNode.ALeft,
            frameColor = (0, 0, 0, 0),
            text_fg = (1,1,1,1)
            )
        self.nowPlaying.setTransparency(1)
        self.nowPlaying.reparentTo(self.frameMain)

        maps = loader.loadModel('button_maps.egg')
        btnGeom = (maps.find('**/ButtonReady'),
                    maps.find('**/ButtonClick'),
                    maps.find('**/ButtonRollover'),
                    maps.find('**/ButtonDisabled'))

        self.btnStart = self.createButton("Start", btnGeom, 0.25, self.btnStart_Click)
        self.btnStart.reparentTo(self.frameMain)

        self.btnQuit = self.createButton("Quit", btnGeom, -0.25, self.btnQuit_Click)
        self.btnQuit.reparentTo(self.frameMain)

        self.recalcAspectRatio(base.win)

        # hide all buttons at startup
        self.hide()

    def show(self):
        self.frameMain.show()
        self.recalcAspectRatio(base.win)

    def hide(self):
        self.frameMain.hide()

    def recalcAspectRatio(self, window):
        """get the new aspect ratio to resize the mainframe"""
        screenResMultiplier = window.getXSize() / window.getYSize()
        self.frameMain["frameSize"] = (
            base.a2dLeft, base.a2dRight,
            base.a2dTop, base.a2dBottom)
        self.btnQuit["text_scale"] = (0.5*screenResMultiplier, 0.5, 0.5)
        self.btnStart["text_scale"] = (0.5*screenResMultiplier, 0.5, 0.5)


    def createButton(self, text, btnGeom, yPos, command):
        btn = DirectButton(
            scale = (0.25, 0.25, 0.25),
            # some temp text
            text = text,
            text_scale = (0.5, 0.5, 0.5),
            # set the alignment to right
            text_align = TextNode.ACenter,
            # put the text on the right side of the button
            text_pos = (0, -0.15),
            # set the text color to black
            text_fg = (1,1,0,1),
            text_shadow = (0.3, 0.3, 0.1, 1),
            text_shadowOffset = (0.05, 0.05),
            # set the buttons images
            geom = btnGeom,
            relief = 1,
            frameColor = (0,0,0,0),
            pressEffect = False,
            pos = (0, 0, yPos),
            command = command,
            rolloverSound = None,
            clickSound = None)
        btn.setTransparency(1)
        return btn

    def btnStart_Click(self):
        base.messenger.send("start")

    def btnQuit_Click(self):
        base.messenger.send("quit")
开发者ID:grimfang,项目名称:Paintball,代码行数:94,代码来源:menu.py

示例13: PlayerHUD

class PlayerHUD():
    def __init__(self):
        #
        # Player status section
        #
        heartscale = (0.1, 1, 0.1)
        self.heart1 = OnscreenImage(
            image = "HeartIcon.png",
            scale = heartscale,
            pos = (0.2, 0, -0.15))
        self.heart1.setTransparency(True)
        self.heart1.reparentTo(base.a2dTopLeft)
        self.heart2 = OnscreenImage(
            image = "HeartIcon.png",
            scale = heartscale,
            pos = (0.45, 0, -0.15))
        self.heart2.setTransparency(True)
        self.heart2.reparentTo(base.a2dTopLeft)
        self.heart3 = OnscreenImage(
            image = "HeartIcon.png",
            scale = heartscale,
            pos = (0.7, 0, -0.15))
        self.heart3.setTransparency(True)
        self.heart3.reparentTo(base.a2dTopLeft)

        self.keys = DirectLabel(
            text = "x0",
            frameColor = (0, 0, 0, 0),
            text_fg = (1, 1, 1, 1),
            text_scale = 1.8,
            text_pos = (1, -0.25, 0),
            text_align = TextNode.ALeft,
            image = "Keys.png",
            pos = (0.2, 0, -0.4))
        self.keys.setScale(0.085)
        self.keys.setTransparency(True)
        self.keys.reparentTo(base.a2dTopLeft)

        self.actionKey = DirectLabel(
            frameColor = (0, 0, 0, 0),
            text_fg = (1, 1, 1, 1),
            scale = 0.15,
            pos = (0, 0, 0.15),
            text = _("Action: E/Enter"))
        self.actionKey.setTransparency(True)
        self.actionKey.reparentTo(base.a2dBottomCenter)
        self.actionKey.hide()

    def show(self):
        self.keys.show()

    def hide(self):
        self.heart1.hide()
        self.heart2.hide()
        self.heart3.hide()
        self.keys.hide()
        self.hideActionKey()

    def setHealthStatus(self, value):
        """this function will set the health image in the top righthand corner
        according to the given value, where value is a integer between 0 and 100
        """
        if value >= 1: self.heart1.show()
        else: self.heart1.hide()
        if value >= 2: self.heart2.show()
        else: self.heart2.hide()
        if value >= 3: self.heart3.show()
        else: self.heart3.hide()

    def showActionKey(self):
        self.actionKey.show()

    def hideActionKey(self):
        self.actionKey.hide()

    def updateKeyCount(self, numKeys):
        self.keys["text"] = "x%d" % numKeys
开发者ID:grimfang,项目名称:owp_ajaw,代码行数:77,代码来源:hud.py


注:本文中的direct.gui.DirectLabel.DirectLabel类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。