本文整理汇总了Python中panda3d.core.TextNode.setText方法的典型用法代码示例。如果您正苦于以下问题:Python TextNode.setText方法的具体用法?Python TextNode.setText怎么用?Python TextNode.setText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类panda3d.core.TextNode
的用法示例。
在下文中一共展示了TextNode.setText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: renderClickableModel
# 需要导入模块: from panda3d.core import TextNode [as 别名]
# 或者: from panda3d.core.TextNode import setText [as 别名]
def renderClickableModel(self, showModel=True, showName=False):
''' Render just the clickable (reference) model '''
# Hide all non clickable objects
self.nonClickable.clearColor()
self.nonClickable.hide()
# Show the clickable model with the original texture and color
self.clickableModel.clearColor()
self.clickableModel.clearColorScale()
if showModel:
# Place it in front of the user, face-to-face (we try to randomly parametrize the position and orientation of the reference model but in a way that the user can clearly see it face-to-face)
self.clickableModel.setPos(0,40,0)
self.clickableModel = self.normalizeModelSize(self.clickableModel, self.minModelSize, self.maxModelSize, self.clickableModelSize) # set size (normalize size and set a random size in the normalized range)
self.clickableModel.setHpr(random.uniform(-45, 45), random.uniform(-15, 15), 0)
self.clickableModel.setColorScale(random.random(), random.random(), random.random(), 1.0)
else:
self.clickable.hide()
if showName:
if not hasattr(self, 'clickableText') or self.clickableText != self.clickableModelName:
if hasattr(self, 'clickableText'):
self.clickableText.remove()
text = TextNode('reference model name')
text.setText(self.clickableModelName)
text.setAlign(TextNode.ACenter)
self.clickableText = render2d.attachNewNode(text)
self.clickableText.setScale( 0.2 )
self.clickableText.setPos( 0, 0, -0.8 )
示例2: addAvatar
# 需要导入模块: from panda3d.core import TextNode [as 别名]
# 或者: from panda3d.core.TextNode import setText [as 别名]
def addAvatar(self, avId, name, damage):
if self.currentIndex == 0:
self.addLeaderboardLabel()
self.avId2Names[avId] = name
self.avId2Damage[avId] = damage
text = TextNode('leaderboard-%d' % avId)
text.setAlign(TextNode.ACenter)
text.setFlattenFlags(TextNode.FFMedium)
text.setFont(getSuitFont())
text.setTextScale(0.05)
text.setTextColor(*TEXT_WHITE)
text.setText(name + ': ' + str(damage))
textNodePath = aspect2d.attachNewNode(text)
textNodePath.reparentTo(base.a2dTopRight)
if self.currentIndex:
self.index2Pos[self.currentIndex] = (-0.35, 0.0, (TEXT_HEIGHT * self.currentIndex) - 0.1)
textNodePath.setPos(*self.index2Pos[self.currentIndex])
else:
self.index2Pos[0] = (-0.35, 0.0, -0.20)
textNodePath.setPos(*self.index2Pos[0])
self.currentIndex += 1
self.avId2Nodes[avId] = [textNodePath, text]
示例3: loadSign
# 需要导入模块: from panda3d.core import TextNode [as 别名]
# 或者: from panda3d.core.TextNode import setText [as 别名]
def loadSign(self):
actNameForSign = self.activityName
if self.activityId == PartyGlobals.ActivityIds.PartyJukebox40:
actNameForSign = PartyGlobals.ActivityIds.getString(PartyGlobals.ActivityIds.PartyJukebox)
elif self.activityId == PartyGlobals.ActivityIds.PartyDance20:
actNameForSign = PartyGlobals.ActivityIds.getString(PartyGlobals.ActivityIds.PartyDance)
self.sign = self.root.attachNewNode('%sSign' % self.activityName)
self.signModel = self.party.defaultSignModel.copyTo(self.sign)
self.signFlat = self.signModel.find('**/sign_flat')
self.signFlatWithNote = self.signModel.find('**/sign_withNote')
self.signTextLocator = self.signModel.find('**/signText_locator')
textureNodePath = getPartyActivityIcon(self.party.activityIconsModel, actNameForSign)
textureNodePath.setPos(0.0, -0.02, 2.2)
textureNodePath.setScale(2.35)
textureNodePath.copyTo(self.signFlat)
textureNodePath.copyTo(self.signFlatWithNote)
text = TextNode('noteText')
text.setTextColor(0.2, 0.1, 0.7, 1.0)
text.setAlign(TextNode.ACenter)
text.setFont(OTPGlobals.getInterfaceFont())
text.setWordwrap(10.0)
text.setText('')
self.noteText = self.signFlatWithNote.attachNewNode(text)
self.noteText.setPosHpr(self.signTextLocator, 0.0, 0.0, 0.2, 0.0, 0.0, 0.0)
self.noteText.setScale(0.2)
self.signFlatWithNote.stash()
self.signTextLocator.stash()
示例4: loadGUI
# 需要导入模块: from panda3d.core import TextNode [as 别名]
# 或者: from panda3d.core.TextNode import setText [as 别名]
def loadGUI(self):
self.gui = loader.loadModel('phase_13/models/parties/trampolineGUI')
self.gui.reparentTo(base.a2dTopLeft)
self.gui.setPos(0.115, 0, -1)
self.gui.hide()
self.toonIndicator = self.gui.find('**/trampolineGUI_MovingBar')
jumpLineLocator = self.gui.find('**/jumpLine_locator')
guiBean = self.gui.find('**/trampolineGUI_GreenJellyBean')
self.gui.find('**/trampolineGUI_GreenJellyBean').stash()
self.guiBeans = [ guiBean.instanceUnderNode(jumpLineLocator, self.uniqueName('guiBean%d' % i)) for i in xrange(self.numJellyBeans) ]
self.guiBeans[-1].setScale(1.5)
heightTextNode = TextNode(self.uniqueName('TrampolineActivity.heightTextNode'))
heightTextNode.setFont(ToontownGlobals.getSignFont())
heightTextNode.setAlign(TextNode.ALeft)
heightTextNode.setText('0.0')
heightTextNode.setShadow(0.05, 0.05)
heightTextNode.setShadowColor(0.0, 0.0, 0.0, 1.0)
heightTextNode.setTextColor(1.0, 1.0, 1.0, 1.0)
self.heightText = jumpLineLocator.attachNewNode(heightTextNode)
self.heightText.setX(0.15)
self.heightText.setScale(0.1)
self.heightText.setAlphaScale(0.0)
self.quitEarlyButtonModels = loader.loadModel('phase_3.5/models/gui/inventory_gui')
quitEarlyUp = self.quitEarlyButtonModels.find('**//InventoryButtonUp')
quitEarlyDown = self.quitEarlyButtonModels.find('**/InventoryButtonDown')
quitEarlyRollover = self.quitEarlyButtonModels.find('**/InventoryButtonRollover')
self.quitEarlyButton = DirectButton(parent=base.a2dTopRight, relief=None, text=TTLocalizer.PartyTrampolineQuitEarlyButton, text_fg=(1, 1, 0.65, 1), text_pos=(0, -0.23), text_scale=0.7, image=(quitEarlyUp, quitEarlyDown, quitEarlyRollover), image_color=(1, 0, 0, 1), image_scale=(20, 1, 11), pos=(-0.183, 0, -0.4), scale=0.09, command=self.leaveTrampoline)
self.quitEarlyButton.stash()
self.flashText = OnscreenText(text='', pos=(0.0, -0.45), scale=0.2, fg=(1.0, 1.0, 0.65, 1.0), align=TextNode.ACenter, font=ToontownGlobals.getSignFont(), mayChange=True)
self.timer = PartyUtils.getNewToontownTimer()
self.timer.posInTopRightCorner()
return
示例5: draw_mstr
# 需要导入模块: from panda3d.core import TextNode [as 别名]
# 或者: from panda3d.core.TextNode import setText [as 别名]
def draw_mstr(self, mstr, box, identifier="", parameters=None):
self.aspect = True
if box.mode == "pixels":
parent2d = self.get_parent_pixel2d()
elif box.mode == "standard":
parent2d = self.get_parent_render2d()
elif box.mode == "aspect":
parent2d = self.get_parent_aspect2d()
tnode = TextNode(identifier)
tnode.setText(mstr.value)
# TODO: use more parameters
if hasattr(parameters, "cardcolor"):
tnode.setCardColor(*parameters.cardcolor)
tnode.setCardAsMargin(0, 0, 0, 0)
tnode.setCardDecal(True)
if hasattr(parameters, "aspect"):
self.aspect = parameters.aspect
node = NodePath(tnode)
self._scale(tnode, node, box.x, box.y, box.sizex, box.sizey)
node.setBin("fixed", self.get_next_sortid())
node.setDepthTest(False)
node.setDepthWrite(False)
node.reparentTo(parent2d)
return (mstr, node, tnode, box, parameters)
示例6: setupCoins2
# 需要导入模块: from panda3d.core import TextNode [as 别名]
# 或者: from panda3d.core.TextNode import setText [as 别名]
def setupCoins2(self):
# display coins = 0
textN = TextNode('coin-score')
textN.setText(str("Coins: " + str(self.coinsCollected2)))
textN.setSlant(0.1)
textNodePath = self.aspect2d.attachNewNode(textN)
textNodePath.setPos(0, 0.95, 0.9)
textNodePath.setScale(0.08)
randNum = random.sample(range(0, 1500, 200), 6)
# coins
for i in range(6):
randX = random.uniform(-3.0, 3.2)
randY = float(randNum[i])
shape = BulletSphereShape(0.3)
coinNode = BulletGhostNode('Coin-' + str(i))
coinNode.addShape(shape)
np = self.render.attachNewNode(coinNode)
np.setCollideMask(BitMask32.allOff())
np.setPos(randX, randY, 2)
# Adding sphere model
sphereNp = loader.loadModel('models/smiley.egg')
sphereNp_tex = loader.loadTexture("models/sky/coin_2_tex.jpg")
sphereNp.setTexture(sphereNp_tex, 1)
sphereNp.reparentTo(np)
sphereNp.setScale(0.45)
sphereNp.hprInterval(2.5, Vec3(360, 0, 0)).loop()
self.world2.attachGhost(coinNode)
self.coins2.append(coinNode)
print "node name:" + str(coinNode.getName())
示例7: attachHostNameToSign
# 需要导入模块: from panda3d.core import TextNode [as 别名]
# 或者: from panda3d.core.TextNode import setText [as 别名]
def attachHostNameToSign(self, locator):
if self.hostName == '':
return
nameText = TextNode('nameText')
nameText.setCardAsMargin(0.1, 0.1, 0.1, 0.1)
nameText.setCardDecal(True)
nameText.setCardColor(1.0, 1.0, 1.0, 0.0)
r = 232.0 / 255.0
g = 169.0 / 255.0
b = 23.0 / 255.0
nameText.setTextColor(r, g, b, 1)
nameText.setAlign(nameText.ACenter)
nameText.setFont(ToontownGlobals.getBuildingNametagFont())
nameText.setShadowColor(0, 0, 0, 1)
nameText.setBin('fixed')
if TTLocalizer.BuildingNametagShadow:
nameText.setShadow(*TTLocalizer.BuildingNametagShadow)
nameWordWrap = 11.0
nameText.setWordwrap(nameWordWrap)
scaleMult = 0.48
houseName = self.hostName
nameText.setText(houseName)
textWidth = nameText.getWidth()
xScale = 1.0 * scaleMult
if textWidth > nameWordWrap:
xScale = nameWordWrap / textWidth * scaleMult
sign_origin = locator
namePlate = sign_origin.attachNewNode(nameText)
namePlate.setDepthWrite(0)
namePlate.setPos(0, 0, 0)
namePlate.setScale(xScale)
示例8: EndScreenHUD
# 需要导入模块: from panda3d.core import TextNode [as 别名]
# 或者: from panda3d.core.TextNode import setText [as 别名]
class EndScreenHUD(DirectObject):
def __init__(self, gameScreenFSM, winnerPlayer):
self.gameScreenFSM = gameScreenFSM
self.endScreenFrame = None
self.isoScale = 3.2
self.scale = (self.isoScale,1,self.isoScale)
self.winnerName = winnerPlayer
def __del__(self):
if (self.endScreenFrame != None):
self.endScreenFrame.destroy()
def initHUD(self):
self.endScreenFrame = DirectFrame(HUD_models,
image = '../HUD images/winnerScreen.png',
frameColor=(0,0,0,0.0),
frameSize=(-1, 1, -1, 1),
scale = self.scale,
)
self.winner = TextNode('Winner Name')
self.winner.setText(self.winnerName)
self.winner.setTextColor(255, 255, 0, 1)
self.winner.setAlign(TextNode.ALeft)
textNodePath = aspect2d.attachNewNode(self.winner)
textNodePath.setScale(0.1)
textNodePath.setPos(-0.1,0,0)
#button = DirectButton(HUD_models, image='../HUD images/creditsButton.png', image_scale = (3.75,1,1) , pos = [-0.0/self.isoScale,0,-0.80/self.isoScale], scale = 0.06/self.isoScale , command= self.changeScene)
def changeScene(self):
clickButtonSound.play()
self.gameScreenFSM.request("CreditScreen")
def update(self):
return
示例9: drawBuilding
# 需要导入模块: from panda3d.core import TextNode [as 别名]
# 或者: from panda3d.core.TextNode import setText [as 别名]
def drawBuilding(self, building, field):
model = self.loader.loadModel('models/house')
# model.setScale(0.05)
model.reparentTo(field.model)
building.model = model
self.modelToBuilding[model.getKey()] = building
player = self.game.currentPlayer()
model.setTag('clickable', 'true')
cs = CollisionSphere(0, 0, 0, 2)
cnodePath = model.attachNewNode(CollisionNode('cnode'))
cnodePath.node().addSolid(cs)
# cnodePath.show()
col = 256 * int(player.color)
# set building title
title = TextNode(str(building.model.getKey()) + '_title')
title.setText(building.building)
title.setCardColor(col, col, col, 1)
title.setCardAsMargin(0.1, 0.1, 0.1, 0.1)
title.setCardDecal(True)
titleNode = self.render.attachNewNode(title)
titleNode.reparentTo(building.model)
titleNode.setScale(1.5)
titleNode.setPos(0, 0, 3)
titleNode.setBillboardPointEye()
示例10: getSpaceGap
# 需要导入模块: from panda3d.core import TextNode [as 别名]
# 或者: from panda3d.core.TextNode import setText [as 别名]
def getSpaceGap(gap, font=None):
txtn = TextNode('tt')
if font: txtn.setFont(font)
s = ''
txtn.setText(s)
while txtn.getWidth() < gap:
s += ' '
txtn.setText(s)
return s
示例11: drawFigures
# 需要导入模块: from panda3d.core import TextNode [as 别名]
# 或者: from panda3d.core.TextNode import setText [as 别名]
def drawFigures(self):
for player in self.game.players:
for figure in player.figures:
if hasattr(figure, 'model'):
continue
if type(figure) == Ship:
field = figure.field
figure.model = self.loader.loadModel('models/ship')
figure.model.reparentTo(field.model)
cs = CollisionSphere(1.5, 0, 1, 1.3)
cnodePath = figure.model.attachNewNode(
CollisionNode('cnode'))
cnodePath.node().addSolid(cs)
# cnodePath.show()
cs = CollisionSphere(0, 0, 1.4, 1.3)
cnodePath = figure.model.attachNewNode(
CollisionNode('cnode'))
cnodePath.node().addSolid(cs)
# cnodePath.show()
cs = CollisionSphere(-1.8, 0, 1, 1)
cnodePath = figure.model.attachNewNode(
CollisionNode('cnode'))
cnodePath.node().addSolid(cs)
# cnodePath.show()
figure.model.setScale(1.4)
figure.model.setHpr(90, 0, 0)
# figure.model.setTag('highlightable', 'true')
figure.model.setTag('clickable', 'true')
self.modelToFigure[figure.model.getKey()] = figure
else:
field = figure.field
figure.model = self.loader.loadModel('models/warrior100')
figure.model.reparentTo(field.model)
cs = CollisionSphere(0, -.35, 7, 1)
cnodePath = figure.model.attachNewNode(
CollisionNode('cnode'))
cnodePath.node().addSolid(cs)
figure.model.setScale(0.35)
figure.model.setTag('highlightable', 'true')
figure.model.setTag('clickable', 'true')
self.modelToFigure[figure.model.getKey()] = figure
col = 256 * int(player.color)
# set figure title
title = TextNode(str(figure.model.getKey()) + '_title')
title.setText(type(figure).__name__)
title.setCardColor(col, col, col, 1)
title.setCardAsMargin(0.1, 0.1, 0.1, 0.1)
title.setCardDecal(True)
titleNode = self.render.attachNewNode(title)
titleNode.reparentTo(figure.model)
titleNode.setScale(3)
titleNode.setPos(0, 3, 10)
if type(figure) == Ship:
titleNode.setScale(1.5)
titleNode.setPos(-1.5, 0, 3)
titleNode.setBillboardPointEye()
示例12: _show
# 需要导入模块: from panda3d.core import TextNode [as 别名]
# 或者: from panda3d.core.TextNode import setText [as 别名]
def _show(self, ctb, identifier, parentnode):
if self.node is not None: self.node.removeNode()
tnode = TextNode(identifier)
tnode.setText(ctb.text)
r, g, b, a = ctb.textcolor.r / 255.0, ctb.textcolor.g / 255.0, ctb.textcolor.b / 255.0, ctb.textcolor.a / 255.0
tnode.setTextColor(r, g, b, a)
node = NodePath(tnode)
self._scale(tnode, node)
node.reparentTo(parentnode)
self.node = node
示例13: addText
# 需要导入模块: from panda3d.core import TextNode [as 别名]
# 或者: from panda3d.core.TextNode import setText [as 别名]
def addText(self,name,text,xpos,ypos,r,g,b,align):
textNode=TextNode(name)
textNode.setText(text)
textNode.setFont(self.font)
textNode.setTextColor(r,g,b,1.0)
textNode.setAlign(align)
textNodePath=self.containerNode.attachNewNode(textNode)
textNodePath.setScale(self.fontScale)
textNodePath.setPos((2.0/self.characterWidth*xpos)-1,0.0,(2.0/self.characterHeight*ypos)-1)
return textNode
示例14: draw
# 需要导入模块: from panda3d.core import TextNode [as 别名]
# 或者: from panda3d.core.TextNode import setText [as 别名]
def draw(self):
# stuffandeer stuffandeer otus
for card in self.hand:
textn = TextNode(card.name)
textn.setText(card.name)
textnp = card.model.attachNewNode(textn)
textnp.setScale(0.3)
textnp.setPos(card.model, -2, 0, 1)
textnp.setHpr(card.model, 0, -90, -90)
textn.setAlign(TextNode.ACenter)
示例15: displayText
# 需要导入模块: from panda3d.core import TextNode [as 别名]
# 或者: from panda3d.core.TextNode import setText [as 别名]
def displayText(self,text):
newTextNode = TextNode('text')
newTextNode.setText(text)
newTextNode.setAlign(TextNode.ACenter)
newTextNode.setWordwrap(16.0)
text_generate = newTextNode.generate()
newTextNodePath = render.attachNewNode(text_generate)
newTextNodePath.setPos(0,1000,190)
newTextNodePath.setScale(30,30,30)
self.textEffects(newTextNodePath)
return newTextNodePath