本文整理汇总了Python中pandac.PandaModules.TextNode.calcWidth方法的典型用法代码示例。如果您正苦于以下问题:Python TextNode.calcWidth方法的具体用法?Python TextNode.calcWidth怎么用?Python TextNode.calcWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pandac.PandaModules.TextNode
的用法示例。
在下文中一共展示了TextNode.calcWidth方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: AddMessage
# 需要导入模块: from pandac.PandaModules import TextNode [as 别名]
# 或者: from pandac.PandaModules.TextNode import calcWidth [as 别名]
def AddMessage(self, prefix, prefixColor, message):
parent = self.displayFrame.attachNewNode('messageParent')
prefixTextNode = TextNode('prefixMessage')
prefixTextNode.setText(prefix)
prefixTextNode.setTextColor(prefixColor)
prefixTextNode.setShadow(0.05, 0.05)
prefixTextNode.setShadowColor(Globals.COLOR_BLACK)
prefixTextNodePath = parent.attachNewNode(prefixTextNode)
prefixTextNodePath.setScale(Settings.CHAT_HEIGHT)
messageTextNode = TextNode('prefixMessage')
messageTextNode.setText(message)
messageTextNode.setTextColor(1, 1, 1, 1)
messageTextNode.setShadow(0.05, 0.05)
messageTextNode.setShadowColor(Globals.COLOR_BLACK)
messageTextNodePath = parent.attachNewNode(messageTextNode)
messageTextNodePath.setScale(Settings.CHAT_HEIGHT)
messageTextNodePath.setPos(Vec3(prefixTextNode.calcWidth(prefix) * Settings.CHAT_HEIGHT, 0, 0))
taskMgr.remove('HideMessageLog')
taskMgr.doMethodLater(ChatBox.MESSAGE_LIFE, self.HideMessageLog, 'HideMessageLog')
self.ShowMessageLog()
self.textNodes.append(parent)
if(len(self.textNodes) > ChatBox.MAX_NUM_MESSAGES):
self.RemoveMessage(self.textNodes[0])
self.RedrawMessages()
示例2: AddMessage
# 需要导入模块: from pandac.PandaModules import TextNode [as 别名]
# 或者: from pandac.PandaModules.TextNode import calcWidth [as 别名]
def AddMessage(self, victimName, attackerName, itemName, attackerColor = Globals.COLOR_WHITE, victimColor = Globals.COLOR_WHITE):
parent = self.displayFrame.attachNewNode('messageParent')
attackerTextNode = TextNode('attackerTextNode')
attackerTextNode.setText(attackerName)
attackerTextNode.setTextColor(attackerColor)
attackerTextNode.setShadow(0.05, 0.05)
attackerTextNode.setShadowColor(Globals.COLOR_BLACK)
attackerTextNodePath = parent.attachNewNode(attackerTextNode)
attackerTextNodePath.setScale(Settings.CHAT_HEIGHT)
attackerTextNodePath.setPos(Vec3(-attackerTextNode.calcWidth('%s [%s] %s' % (attackerName, itemName, victimName)) * Settings.CHAT_HEIGHT, 0, 0))
itemNameTextNode = TextNode('itemNameTextNode')
itemNameTextNode.setText('[%s]' % (itemName))
itemNameTextNode.setTextColor(Globals.COLOR_WHITE)
itemNameTextNode.setShadow(0.05, 0.05)
itemNameTextNode.setShadowColor(Globals.COLOR_BLACK)
itemNameTextNodePath = parent.attachNewNode(itemNameTextNode)
itemNameTextNodePath.setScale(Settings.CHAT_HEIGHT)
itemNameTextNodePath.setPos(Vec3(-attackerTextNode.calcWidth('[%s] %s' % (itemName, victimName)) * Settings.CHAT_HEIGHT, 0, 0))
victimTextNode = TextNode('prefixMessage')
victimTextNode.setText(victimName)
victimTextNode.setTextColor(victimColor)
victimTextNode.setShadow(0.05, 0.05)
victimTextNode.setShadowColor(Globals.COLOR_BLACK)
victimTextNodePath = parent.attachNewNode(victimTextNode)
victimTextNodePath.setScale(Settings.CHAT_HEIGHT)
victimTextNodePath.setPos(Vec3(-attackerTextNode.calcWidth(victimName) * Settings.CHAT_HEIGHT, 0, 0))
taskMgr.remove('HideMessageLog')
taskMgr.doMethodLater(DeathNotifications.MESSAGE_LIFE, self.RemoveMessage, 'RemoveMessage', extraArgs = [parent])
self.textNodes.append(parent)
if(len(self.textNodes) > DeathNotifications.MAX_NUM_MESSAGES):
self.RemoveMessage(self.textNodes[0])
self.RedrawMessages()