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


Python DirectLabel.show方法代码示例

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


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

示例1: HUD

# 需要导入模块: from direct.gui.DirectLabel import DirectLabel [as 别名]
# 或者: from direct.gui.DirectLabel.DirectLabel import show [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: __init__

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

#.........这里部分代码省略.........
    return False

  def _step(self,task):
    """
    Update the vehicle's position using a simple point-mass physics
    model based on self._steeringforce, self.maxforce, self.mass, and
    self.maxspeed, and applying the steering behavior indicated by
    self._steeringbehavior.

    """
    dt = task.time - self._prevtime

    steeringbehavior = self._steeringbehavior
    if self.avoidObstacles:
      steeringbehavior = ['AvoidObstacles'] + steeringbehavior
    if self.avoidVehicles:
      steeringbehavior = ['AvoidVehicles'] + steeringbehavior
    if (self.container is not None) or (container is not None):
      steeringbehavior = ['Containment'] + steeringbehavior

    # Set self._steeringforce to be the result of the first method in
    # steeringbehavior that does not return None.
    self._steeringforce = SteerVec(0,0)
    self.label['text'] = 'no steering'
    for steeringmethod in steeringbehavior:
      method_name = '_steerFor' + steeringmethod
      method = getattr(self, method_name)
      steeringforce = method()
      if steeringforce is not None:
        self.label['text'] = steeringmethod
        self._steeringforce = steeringforce
        break

    global show
    if show:
      self.label.show()
      #self.tubenp.show()
      #self.spherenp.show()
    else:
      self.label.hide()
      #self.tubenp.hide()
      #self.spherenp.hide()

    # Compute new velocity according to point-mass physics.

    steering_force = self._steeringforce.truncate(self.maxforce)
    acceleration = steering_force/self.mass
    self._velocity = (self._velocity+acceleration).truncate(self.maxspeed)

    # Add a small random component to the velocity. The component is too
    # small to produce any visible result. It is added to avoid a bug in
    # the obstacle avoidance behavior: if a vehicle heads precisely
    # toward an obstacle then the surface normal at the point of
    # collision on the surface of the obstacle is parallel to the forward
    # direction of the vehicle. So the perpendicular component of the
    # surface normal to the vehicle's forward direction is zero, and hence
    # the steering force is zero, and the vehicle plows straight into the
    # obstacle. With a random element to the vehicle's velocity, this
    # precise situation will not exist for consecutive simulation frames.
    x = (random.random()-0.5)*0.01
    y = (random.random()-0.5)*0.01
    self._velocity.setX(self._velocity.getX()+self._velocity.getX()*x)
    self._velocity.setY(self._velocity.getY()+self._velocity.getY()*y)

    # Update vehicle's position.
    self._pos += self._velocity*(dt*50)
开发者ID:kengleason,项目名称:PandaSteer,代码行数:70,代码来源:vehicle.py

示例3: HUD

# 需要导入模块: from direct.gui.DirectLabel import DirectLabel [as 别名]
# 或者: from direct.gui.DirectLabel.DirectLabel import show [as 别名]
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,代码行数:103,代码来源:hud.py

示例4: PlayerHUD

# 需要导入模块: from direct.gui.DirectLabel import DirectLabel [as 别名]
# 或者: from direct.gui.DirectLabel.DirectLabel import show [as 别名]
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,代码行数:79,代码来源:hud.py


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