本文整理汇总了Python中pandac.PandaModules.TextNode.setText方法的典型用法代码示例。如果您正苦于以下问题:Python TextNode.setText方法的具体用法?Python TextNode.setText怎么用?Python TextNode.setText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pandac.PandaModules.TextNode
的用法示例。
在下文中一共展示了TextNode.setText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: AddMessage
# 需要导入模块: from pandac.PandaModules import TextNode [as 别名]
# 或者: from pandac.PandaModules.TextNode import setText [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: addball
# 需要导入模块: from pandac.PandaModules import TextNode [as 别名]
# 或者: from pandac.PandaModules.TextNode import setText [as 别名]
def addball(self, NUM):
X = "Person_pics/" + NUM + '.jpeg'
tex = loader.loadTexture(X)
f = loader.loadModel("models/ball1.egg")
f.setTexGen(TextureStage.getDefault(), TexGenAttrib.MEyeSphereMap)
a = random.uniform((-8 + (self.addx)), (8 + self.addx))
b = random.uniform((-8 + (self.addy)), (8 + self.addy))
c = random.uniform((-8 + (self.addz)), (8 + self.addz))
pos = Vec3(a,b,c)
f.setTexture(tex, 1)
f.setPos(pos)
f.setScale(.8)
f.reparentTo(render)
f.setCollideMask(0)
text = NUM
newTextNode = TextNode('text') # Create a new TextNode
newTextNode.setText(text) # Set the TextNode text
newTextNode.setAlign(TextNode.ACenter) # Set the text align
newTextNode.setWordwrap(6.0) # Set the word wrap
text_generate = newTextNode.generate() # Generate a NodePath
newTextNodePath = render.attachNewNode(text_generate) # Attach the NodePath to the render tree
newTextNodePath.setPos(a,b,(c + 0.6))
newTextNodePath.setColor(255, 0, 0,1)
newTextNodePath.setScale(.5)
return pos
示例3: loadMenu
# 需要导入模块: from pandac.PandaModules import TextNode [as 别名]
# 或者: from pandac.PandaModules.TextNode import setText [as 别名]
def loadMenu(self):
#Load main menu
#Add play icon
click = loader.loadSfx("./sounds/correct.ogg")
self.playicon = DirectButton(image="./GUI/cloud.png", scale=.3, pos=(-0.38,0,0.21), relief=None, state=DGG.NORMAL, command=self.playGame, clickSound=click)
self.playicon.setScale(0.3)
self.playicon.setTransparency(TransparencyAttrib.MAlpha)
#Play text
play = TextNode('Play')
play.setText("\1menu\1 Play! \2")
self.playNP = aspect2d.attachNewNode(play)
self.playNP.setScale(0.18)
self.playNP.setPos(-0.7,0,0.13)
self.playerGUI.controls()
#Exit text and icon
self.exiticon = DirectButton(image="./GUI/cloud.png", scale=.3, pos=(0.48,0,0.21), relief=None, state=DGG.NORMAL, command=exit, clickSound=click)
self.exiticon.setScale(0.3)
self.exiticon.setTransparency(TransparencyAttrib.MAlpha)
exitx = TextNode('Exit')
exitx.setText("\1menu\1 Exit \2")
self.exitxNP = aspect2d.attachNewNode(exitx)
self.exitxNP.setScale(0.18)
self.exitxNP.setPos(0.22,0,0.13)
示例4: addball
# 需要导入模块: from pandac.PandaModules import TextNode [as 别名]
# 或者: from pandac.PandaModules.TextNode import setText [as 别名]
def addball(self, NUM):
#pos = Vec3(random.uniform(-7, 7), random.uniform(-7, 7), random.uniform(-7, 7))
a = random.uniform((-8 + (self.addx)), (8 + self.addx))
b = random.uniform((-8 + (self.addy)), (8 + self.addy))
c = random.uniform((-8 + (self.addz)), (8 + self.addz))
pos = Vec3(a,b,c)
f = loader.loadModel("models/ball")
f.setPos(pos)
f.setScale(.8)
f.reparentTo(render)
f.setCollideMask(0)
text = NUM
newTextNode = TextNode('text') # Create a new TextNode
newTextNode.setText(text) # Set the TextNode text
newTextNode.setAlign(TextNode.ACenter) # Set the text align
newTextNode.setWordwrap(6.0) # Set the word wrap
text_generate = newTextNode.generate() # Generate a NodePath
newTextNodePath = render.attachNewNode(text_generate) # Attach the NodePath to the render tree
newTextNodePath.setPos(a,b,(c + 0.6))
newTextNodePath.setColor(255, 0, 0,1)
newTextNodePath.setScale(2)
#self.V = self.V + 1
#self.negy = (10%(self.V))*(-7)
#self.posy = (10%(self.V)+3)*(-7)
return pos
示例5: __init__
# 需要导入模块: from pandac.PandaModules import TextNode [as 别名]
# 或者: from pandac.PandaModules.TextNode import setText [as 别名]
def __init__(self,bat_np,t,x,y,col):
rate = 2
z = 20
scale = 12
scale_up = 15
text_node = TextNode("battle_text")
text_node.setText(t)
text_node_path = bat_np.attachNewNode(text_node)
text_node_path.reparentTo(render)
text_node_path.setPos(x,y,0)
text_node_path.setHpr(0,-90,0)
text_node_path.setScale(scale)
text_node_path.setTransparency(TransparencyAttrib.MAlpha)
text_node.setTextColor(col)
text_node.setAlign(TextNode.ACenter)
node_scl_up = text_node_path.scaleInterval(rate, Point3(scale_up, scale_up, scale_up))
node_z_up = text_node_path.posInterval(rate, Point3(x, y, z*2))
node_z_up2 = text_node_path.posInterval(rate, Point3(x, y, z*2))
node_fade_down = text_node_path.colorScaleInterval(rate, (col[0],col[1],col[2],0))
node_func_death = Func(self.destroy)
t_para = Parallel(node_scl_up,node_z_up,node_fade_down)
t_seq = Sequence(t_para,node_func_death)
t_seq.start()
self.tnp = text_node_path
示例6: __init__
# 需要导入模块: from pandac.PandaModules import TextNode [as 别名]
# 或者: from pandac.PandaModules.TextNode import setText [as 别名]
def __init__(self, mainReference):
self.mainRef = mainReference
self.winSizeX = self.mainRef.win.getProperties().getXSize()
self.winSizeY = self.mainRef.win.getProperties().getYSize()
# parent of all sprites
sprites_root = self.createSpritesNodeSetup()
# crosshair init
self.crosshairSprite = self.createSprite('../../textures/crosshair.png', self.winSizeX/2, self.winSizeY/2, 16, 16, 1)
self.crosshairSprite.reparentTo(sprites_root)
# health points
hpText=TextNode('hp')
hpText.setText( "HP: "+str(self.mainRef.player.healthPoints) )
self.guiHp = self.mainRef.aspect2d.attachNewNode(hpText)
self.guiHp.setScale(0.07)
self.guiHp.setPos(-1.2,0,-0.9)
# Ammo
ammoText=TextNode('ammo')
ammoText.setText( "AMMO: "+str(self.mainRef.player.activeWeapon.bullets) )
self.guiAmmo = self.mainRef.aspect2d.attachNewNode(ammoText)
self.guiAmmo.setScale(0.07)
self.guiAmmo.setPos(-1.2,0,-0.9+0.1)
示例7: loadSign
# 需要导入模块: from pandac.PandaModules import TextNode [as 别名]
# 或者: from pandac.PandaModules.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()
示例8: loadGUI
# 需要导入模块: from pandac.PandaModules import TextNode [as 别名]
# 或者: from pandac.PandaModules.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
示例9: attachHostNameToSign
# 需要导入模块: from pandac.PandaModules import TextNode [as 别名]
# 或者: from pandac.PandaModules.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)
示例10: addball
# 需要导入模块: from pandac.PandaModules import TextNode [as 别名]
# 或者: from pandac.PandaModules.TextNode import setText [as 别名]
def addball(self, NUM):
# pos = Vec3(random.uniform(-7, 7), random.uniform(-7, 7), random.uniform(-7, 7))
if self.model == True and self.text == True:
self.f.remove()
self.newTextNodePath2.remove()
a = random.uniform(-7, 7)
b = random.uniform(-7, 7)
c = random.uniform(-7, 7)
pos = Vec3(a, b, c)
tex = loader.loadTexture("cra/textures/e.jpeg")
self.f = loader.loadModel("cra/models/ball1.egg")
self.f.setTexGen(TextureStage.getDefault(), TexGenAttrib.MEyeSphereMap)
self.f.setTexture(tex, 1)
self.f.setPos(pos)
self.f.setScale(1.5)
self.f.reparentTo(render)
self.f.setCollideMask(0)
text = NUM
newTextNode = TextNode("text") # Create a new TextNode
newTextNode.setText(text) # Set the TextNode text
newTextNode.setAlign(TextNode.ACenter) # Set the text align
newTextNode.setWordwrap(6.0) # Set the word wrap
text_generate = newTextNode.generate() # Generate a NodePath
self.newTextNodePath2 = render.attachNewNode(text_generate) # Attach the NodePath to the render tree
self.newTextNodePath2.setPos(a, b, (c + 0.3))
self.newTextNodePath2.setColor(255, 0, 0, 1)
self.newTextNodePath2.setScale(0.6)
return pos
示例11: place_markers
# 需要导入模块: from pandac.PandaModules import TextNode [as 别名]
# 或者: from pandac.PandaModules.TextNode import setText [as 别名]
def place_markers(self,nodes):
for n in range(len(nodes)):
town_node = NodePath("town")
town = loader.loadModel("models/infantry_counter.egg")
x = (nodes[n+1]["x"]-map_center[0])*amplification
y = (nodes[n+1]["y"]-map_center[1])*amplification
town.setPos(x,y,0)
if nodes[n+1]["type"] == "city":
scale = 12
elif nodes[n+1]["type"] == "town":
scale = 7
elif nodes[n+1]["type"] == "village":
scale = 4
town.setScale(scale,scale,scale)
town.reparentTo(town_node)
town_node.reparentTo(render)
text_node = TextNode("town_text_node")
text_node.setText(nodes[n+1]["name"])
text_node_path = town.attachNewNode(text_node)
text_node_path.setPos(1,0,0)
text_node_path.setHpr(0,-90,0)
text_node_path.setScale(scale/2)
text_node_path.setTransparency(TransparencyAttrib.MAlpha)
text_node.setTextColor(0.8, 0.1, 0.1, 1)
text_node.setAlign(TextNode.ALeft)
示例12: printText
# 需要导入模块: from pandac.PandaModules import TextNode [as 别名]
# 或者: from pandac.PandaModules.TextNode import setText [as 别名]
def printText(name, message, color):
text = TextNode(name)
text.setText(message)
x,y,z = color
text.setTextColor(x,y,z, 1)
text3d = NodePath(text)
text3d.reparentTo(render)
return text3d
示例13: center
# 需要导入模块: from pandac.PandaModules import TextNode [as 别名]
# 或者: from pandac.PandaModules.TextNode import setText [as 别名]
def center(self, prsn_name , m):
if (m < 5):
self.i = self.i + 1
X = 'Person_pics/' + prsn_name + '.jpeg'
tex = loader.loadTexture(X)
self.sphere = loader.loadModel("models/ball1")
self.sphere.setTexGen(TextureStage.getDefault(), TexGenAttrib.MEyeSphereMap)
self.sphere.setTexture(tex, 1)
self.sphere.reparentTo(render)
gx = self.sx
y = self.sy
z = self.sz
pos = (gx,y,z)
self.addx =gx
self.addy =y
self.addz =z
self.sphere.setPos(1, self.sy, 1)
self.sphere.setScale(.9)
self.sy = -14*(self.i)
else :
x = m/5
j = m%5
if ( j == 0):
self.sy = 1
self.i = 1
else :
self.sy = -14*(self.i)
self.sx = 40*(x)
self.sphere = loader.loadModel("models/ball1")
self.sphere.reparentTo(render)
gx = self.sx
y = self.sy
z = self.sz
self.addx =gx
self.addy =y
self.addz =z
pos = (gx, y, 1)
self.sphere.setPos(pos)
#self.sphere.setScale(.9)
self.i = self.i + 1
self.sphere.setScale(.9)
text = prsn_name
newTextNode = TextNode('text') # Create a new TextNode
newTextNode.setText(text) # Set the TextNode text
newTextNode.setAlign(TextNode.ACenter) # Set the text align
newTextNode.setWordwrap(6.0) # Set the word wrap
text_generate = newTextNode.generate() # Generate a NodePath
newTextNodePath = render.attachNewNode(text_generate) # Attach the NodePath to the render tree
newTextNodePath.setPos(gx, y, (z + 2))
newTextNodePath.setColor(0, 0, 255,1)
newTextNodePath.setScale(.5)
return pos
示例14: printText
# 需要导入模块: from pandac.PandaModules import TextNode [as 别名]
# 或者: from pandac.PandaModules.TextNode import setText [as 别名]
def printText(self, name, message, color, parent=render):
text = TextNode(
name
) # create a TextNode. Note that 'name' is not the text, rather it is a name that identifies the object.
text.setText(message) # Here we set the text of the TextNode
x, y, z = color # break apart the color tuple
text.setTextColor(x, y, z, 1) # Set the text color from the color tuple
text3d = NodePath(text) # Here we create a NodePath from the TextNode, so that we can manipulate it 'in world'
text3d.reparentTo(parent)
return text3d # return the NodePath for further use
示例15: createDistanceLabel
# 需要导入模块: from pandac.PandaModules import TextNode [as 别名]
# 或者: from pandac.PandaModules.TextNode import setText [as 别名]
def createDistanceLabel(self, number, color):
text = TextNode('distanceText-%d' % number)
text.setAlign(TextNode.ACenter)
text.setTextColor(color)
text.setFont(ToontownGlobals.getSignFont())
text.setText('10 ft')
node = self.root.attachNewNode(text)
node.setBillboardPointEye()
node.setScale(2.5)
node.setZ(5.0)
return (node, text)