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


Python DirectLabel.setPos方法代码示例

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


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

示例1: HUD

# 需要导入模块: from direct.gui.DirectLabel import DirectLabel [as 别名]
# 或者: from direct.gui.DirectLabel.DirectLabel import setPos [as 别名]
class HUD(DirectObject):
    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()

    def show(self):
        self.crosshair.show()
        self.nowPlaying.show()
        self.ammo.show()

    def hide(self):
        self.crosshair.hide()
        self.nowPlaying.hide()
        self.ammo.hide()

    def updateAmmo(self, maxAmmo, ammo):
        self.ammo["text"] = "%02d/%02d" % (maxAmmo, ammo)

    def recalcAspectRatio(self, window):
        self.ammo.setPos(base.a2dLeft + 0.025, 0.0, base.a2dBottom + 0.05)
        self.ammo.setPos(base.a2dLeft + 0.025, 0.0, base.a2dTop - 0.05)
开发者ID:grimfang,项目名称:Paintball,代码行数:59,代码来源:hud.py

示例2: HUD

# 需要导入模块: from direct.gui.DirectLabel import DirectLabel [as 别名]
# 或者: from direct.gui.DirectLabel.DirectLabel import setPos [as 别名]

#.........这里部分代码省略.........
            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()
        self.speekLabel.destroy()
        self.points.destroy()
        self.playerWater.destroy()
        self.helpInfo.destroy()

    def showCanPlant(self):
        self.canPlantLabel.show()

    def hideCanPlant(self):
        self.canPlantLabel.hide()

    def setPoints(self, points):
        self.points["text"] = _("Points: %d")%points
        self.points.resetFrameSize()

    def setWater(self, water):
        self.playerWater["text"] = _("Remaining Water: %d")%water
        self.playerWater.resetFrameSize()

    def setStory(self, storytext):
        self.storyText["text"] = storytext
        self.storyText.resetFrameSize()

    def showSpeekText(self, text, newPos):
        self.speekLabel.setPos(newPos)
        self.speekLabel["text"] = text
        self.speekLabel.resetFrameSize()
        self.speekLabel.show()

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


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