本文整理汇总了Python中direct.gui.DirectLabel.DirectLabel.setScale方法的典型用法代码示例。如果您正苦于以下问题:Python DirectLabel.setScale方法的具体用法?Python DirectLabel.setScale怎么用?Python DirectLabel.setScale使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类direct.gui.DirectLabel.DirectLabel
的用法示例。
在下文中一共展示了DirectLabel.setScale方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PlayerHUD
# 需要导入模块: from direct.gui.DirectLabel import DirectLabel [as 别名]
# 或者: from direct.gui.DirectLabel.DirectLabel import setScale [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