本文整理汇总了Python中panda3d.core.TextNode类的典型用法代码示例。如果您正苦于以下问题:Python TextNode类的具体用法?Python TextNode怎么用?Python TextNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TextNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: loadActor
def loadActor(self):
if self.actor:
self.actor.cleanup()
self.actor = Actor('models/ralph',
{'walk' : 'models/ralph-walk',
'run' : 'models/ralph-run'})
self.actor.reparentTo(self)
self.actor.setScale(.2)
# Setup a really simple nametag so we can know it's name.
self.nameText = TextNode('%d-nameText' % self.doId)
self.nameText.setText(self.name)
self.nameText.setAlign(self.nameText.A_center)
self.nameNP = self.attachNewNode(self.nameText)
self.nameNP.setScale(.25)
self.nameNP.setPos(0, 0, 1.2)
self.nameNP.setBillboardPointEye()
self.chatText = TextNode('%d-chatText' % self.doId)
self.chatText.setText(self.chat)
self.chatText.setAlign(self.chatText.A_center)
self.chatText.setTextColor(0.5, 0.5, 1, 1)
self.chatNP = self.attachNewNode(self.chatText)
self.chatNP.setScale(.35)
self.chatNP.setPos(0, 0, 1.6)
self.chatNP.setBillboardPointEye()
示例2: FastTextNode
class FastTextNode(DebugObject):
""" Interface for the Panda3D TextNode. """
def __init__(self, font="Data/Font/Roboto-Bold.ttf", pixel_size=16, align="left",
pos=Vec2(0), color=Vec3(1), parent=None):
self._node = TextNode('FTN')
self._node.set_text("Text")
self._node.set_align(getattr(TextNode, "A_" + align))
self._node.set_text_color(color.x, color.y, color.z, 1)
if parent is None:
parent = Globals.base.aspect2d
self._nodepath = parent.attach_new_node(self._node)
self._nodepath.set_scale(pixel_size * 2.0 / float(Globals.base.win.get_y_size()))
self._nodepath.set_pos(pos.x, 0, pos.y)
font = Globals.loader.loadFont(font)
font.set_outline(Vec4(0, 0, 0, 0.78), 1.6, 0.37)
font.set_scale_factor(1.0)
font.set_texture_margin(int(pixel_size / 4.0 * 2.0))
font.set_bg(Vec4(0, 0, 0, 0))
self._node.set_font(font)
def set_text(self, text):
self._node.set_text(text)
示例3: setupCoins2
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())
示例4: initFishStaminaBar
def initFishStaminaBar(self):
self.legendaryGui = loader.loadModel('models/minigames/pir_m_gam_fsh_legendaryGui')
self.iconBaseFrame = DirectFrame(relief = None, state = DGG.DISABLED, pos = (0, 0, 0), sortOrder = 30, image = self.legendaryGui.find('**/pir_t_gui_fsh_fishPortraitFrame'), image_scale = 0.17999999999999999, image_pos = (0, 0, 0))
self.iconBaseFrame.setTransparency(TransparencyAttrib.MAlpha)
self.fishUINodePath = NodePath(self.iconBaseFrame)
self.fishUINodePath.setPos(-0.29999999999999999, 0.0, 0.82999999999999996)
self.fishUINodePath.reparentTo(hidden)
self.iconCard = loader.loadModel('models/gui/treasure_gui')
self.iconBaseFrame.iconImage = OnscreenImage(parent = self.iconBaseFrame, image = self.iconCard.find('**/%s*' % CollectionMap.Assets[self.myData['id']]), scale = 0.34999999999999998, hpr = (0, 0, 0), pos = (0.0, 0, 0.0))
self.fishNameLabel = TextNode('fishNameLabel')
name = self.getName().split('_')
self.fishNameLabel.setText(name[0])
self.fishNameLabel.setTextColor(1.0, 1.0, 1.0, 1.0)
self.fishNameLabelNodePath = NodePath(self.fishNameLabel)
self.fishNameLabelNodePath.setPos(0.29999999999999999, 0, 0.040000000000000001)
self.fishNameLabelNodePath.setScale(0.044999999999999998)
self.fishNameLabelNodePath.reparentTo(self.iconBaseFrame)
self.fishStaminaBar = DirectWaitBar(parent = self.iconBaseFrame, relief = DGG.FLAT, state = DGG.DISABLED, range = 100, value = 0, sortOrder = 20, frameColor = (0, 0, 0, 1.0), pos = (0.070000000000000007, 0.0, -0.014999999999999999), hpr = (0, 0, 0), frameSize = (0, 0.71999999999999997, 0, 0.028000000000000001))
self.fishStaminaBar['value'] = self.staminaValue
self.fishStaminaBar['barColor'] = FishingGlobals.fishingStaminaBarColor[int((self.staminaValue / 100.0) * (len(FishingGlobals.fishingStaminaBarColor) - 1))]
self.fishStaminaValueLabel = TextNode('fishStaminaValueLabel')
self.fishStaminaValueLabel.setText(str(self.staminaValue) + '//' + str(self.staminaValue))
self.fishStaminaValueLabel.setTextColor(1.0, 1.0, 1.0, 1.0)
self.fishStaminaValueLabelNodePath = NodePath(self.fishStaminaValueLabel)
self.fishStaminaValueLabelNodePath.setPos(0.66000000000000003, 0, -0.059999999999999998)
self.fishStaminaValueLabelNodePath.setScale(0.044999999999999998)
self.fishStaminaValueLabelNodePath.reparentTo(self.iconBaseFrame)
self.fishStaminaBarFrame = DirectLabel(parent = self.iconBaseFrame, relief = None, state = DGG.DISABLED, frameColor = (1, 1, 1, 0.10000000000000001), pos = (0.44, 0.0, 0.0), hpr = (0, 0, 0), sortOrder = 25, image = self.legendaryGui.find('**/pir_t_gui_fsh_staminaBarForeground'), image_scale = (1.0, 0.0, 0.050000000000000003), image_pos = (0.0, 0.0, 0.0), image_hpr = (0.0, 0.0, 0.0))
self.fishStaminaBarFrame.setTransparency(TransparencyAttrib.MAlpha)
self.fishStaminaBarFrame.setDepthTest(True)
self.fishStaminaBarFrame.setDepthWrite(True)
示例5: Game_Point
def Game_Point(self):
self.ignore("arrow_down")
self.ignore("arrow_up")
self.ignore("arrow_down-repeat")
self.ignore("arrow_up-repeat")
#self.text1 = addInstructions(0.5,"Is this Recyclable")
self.text1 = TextNode('t1')
self.text1.setText("is This Recyclable")
self.text1.setTextColor(0,0,0,1)
self.textNodePath1 = aspect2d.attachNewNode(self.text1)
self.textNodePath1.setScale(0.07)
self.textNodePath1.setPos(-0.1,-0.1,0.1)
#text1.setTextColor(1,1,1)
self.text1.setFrameColor(1, 0, 0, 1)
self.text1.setFrameAsMargin(0.2, 0.2, 0.1, 0.1)
self.text2 = TextNode('t2')
self.text2.setText("Y/N")
self.text2.setTextColor(0,0,0,1)
self.textNodePath2 = aspect2d.attachNewNode(self.text2)
self.textNodePath2.setScale(0.07)
self.textNodePath2.setPos(0,0,0)
#textNodePath2.setTextColor(1,1,1)
self.text2.setFrameColor(1, 0, 0, 1)
self.text2.setFrameAsMargin(0.2, 0.2, 0.1, 0.1)
self.accept('y',self.answer,[0])
self.accept('n',self.answer,[1])
示例6: renderClickableModel
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 )
示例7: __init__
def __init__(self, w, h, locationId = LocationIds.PORT_ROYAL_ISLAND):
GuiPanel.GuiPanel.__init__(self, '', w, h, True)
self.card = loader.loadModel('models/gui/pir_m_gui_fsh_legendaryScreen')
self.storyImageCard = loader.loadModel('models/minigames/pir_m_gam_fsh_legendaryGui')
self.UICompoments = { }
self.setPos(-1.1499999999999999, 0.0, -0.59999999999999998)
self['geom'] = self.card.find('**/background')
self['geom_pos'] = (0.57999999999999996, 0.0, 0.63)
self['geom_scale'] = (0.94999999999999996, 0.0, 0.84999999999999998)
self.coinImage = OnscreenImage(parent = self, image = self.card.find('**/coin'), scale = 0.90000000000000002, hpr = (0, 0, 0), pos = (0.84999999999999998, 0, 0.84999999999999998))
self.titleTextNode = TextNode('legendPanelTitle')
self.titleTextNode.setText(PLocalizer.LegendSelectionGui['panelTitle'])
self.titleTextNode.setFont(PiratesGlobals.getPirateFont())
self.titleTextNode.setTextColor(0.87, 0.81999999999999995, 0.54000000000000004, 0.90000000000000002)
self.titleTextNodePath = NodePath(self.titleTextNode)
self.titleTextNodePath.setPos(0.65000000000000002, 0.0, 1.2)
self.titleTextNodePath.setScale(0.070000000000000007)
self.titleTextNodePath.reparentTo(self)
self.introTextNode = TextNode('legendaryIntroTextNode')
self.introTextNode.setText(PLocalizer.LegendSelectionGui['legendIntro'])
self.introTextNode.setWordwrap(14.0)
self.introTextNode.setTextColor(0.90000000000000002, 0.80000000000000004, 0.46999999999999997, 0.90000000000000002)
self.introTextNodePath = NodePath(self.introTextNode)
self.introTextNodePath.setPos(0.59999999999999998, 0.0, 0.5)
self.introTextNodePath.setScale(0.042000000000000003)
self.introTextNodePath.reparentTo(self)
self.buttonRootNode = NodePath('button_RootNode')
self.buttonRootNode.reparentTo(self)
self.buttonRootNode.setPos(-0.080000000000000002, 0.0, 1.1499999999999999)
self.iconCard = loader.loadModel('models/gui/treasure_gui')
self.legendSelectionButtons = { }
btnGeom = (self.card.find('**/fishButton/idle'), self.card.find('**/fishButton/idle'), self.card.find('**/fishButton/over'))
for i in range(len(FishingGlobals.legendaryFishData)):
fishName = FishingGlobals.legendaryFishData[i]['name']
fishId = FishingGlobals.legendaryFishData[i]['id']
assetsKey = CollectionMap.Assets[fishId]
pos_x = 0.29999999999999999
pos_z = 0.0 - i * 0.25
button = GuiButton(parent = self.buttonRootNode, text = (fishName, fishName, fishName, fishName), text0_fg = (0.42999999999999999, 0.28999999999999998, 0.19, 1.0), text1_fg = (0.42999999999999999, 0.28999999999999998, 0.19, 1.0), text2_fg = (0.42999999999999999, 0.28999999999999998, 0.19, 1.0), text3_fg = (0.42999999999999999, 0.28999999999999998, 0.19, 1.0), text_scale = 0.035000000000000003, text_pos = (0.037999999999999999, -0.0050000000000000001), pos = (pos_x, 0, pos_z), hpr = (0, 0, 0), scale = 1.5, image = btnGeom, image_pos = (0, 0, 0), image_scale = 0.69999999999999996, sortOrder = 2, command = self.buttonClickHandle, extraArgs = [
fishId,
assetsKey,
locationId])
button.icon = OnscreenImage(parent = button, image = self.iconCard.find('**/%s*' % assetsKey), scale = 0.34999999999999998, hpr = (0, 0, 0), pos = (-0.123, 0, 0.0050000000000000001))
self.legendPanel = GuiPanel.GuiPanel('', 2.6000000000000001, 1.8999999999999999, True)
self.legendPanel.setPos(-1.3, 0.0, -0.94999999999999996)
self.legendPanel.background = OnscreenImage(parent = self.legendPanel, scale = (2.3999999999999999, 0, 1.8), image = self.storyImageCard.find('**/pir_t_gui_fsh_posterBackground'), hpr = (0, 0, 0), pos = (1.3, 0, 0.94999999999999996))
self.legendPanel.storyImage = OnscreenImage(parent = self.legendPanel, scale = 1, image = self.card.find('**/coin'), hpr = (0, 0, 0), pos = (1.8, 0, 1))
self.storyTextNode = TextNode('storyTextNode')
self.storyTextNode.setText('')
self.storyTextNode.setWordwrap(19.0)
self.storyTextNode.setTextColor(0.23000000000000001, 0.089999999999999997, 0.029999999999999999, 1.0)
self.storyTextNodePath = NodePath(self.storyTextNode)
self.storyTextNodePath.setPos(0.33000000000000002, 0.0, 1.6699999999999999)
self.storyTextNodePath.setScale(0.050000000000000003)
self.storyTextNodePath.reparentTo(self.legendPanel)
self.callBack = None
self.legendPanel.hide()
示例8: fontHasCharacters
def fontHasCharacters(name, font = font):
if font:
tn = TextNode('NameCheck')
tn.setFont(font)
for c in name:
# Define c as unicode
if not tn.hasCharacter(unichr(ord(c))):
notify.info('name contains bad char: %s' % TextEncoder().encodeWtext(c))
return OTPLocalizer.NCBadCharacter % TextEncoder().encodeWtext(c)
示例9: _show
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
示例10: draw
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)
示例11: drawBuilding
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()
示例12: draw_mstr
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)
示例13: start
def start(self):
self._credits_node = aspect2d.attachNewNode("credits-node")
text = TextNode('node name')
text.setText(" A solar storm hits a moon base.\n Some vital systems are breaking.\n Get close to repair them before failure\nof four simultaneously, because this\ndestroy the base.")
textNodePath = self._credits_node.attachNewNode(text)
textNodePath.setScale(0.07)
textNodePath.setPos((0.0, 0.0, 0.0))
DirectButton(text = ("Back", "Back", "Back", "Back"),
pos=(0, 0, -0.8), scale=.15, command=self._butBack, parent=self._credits_node)
示例14: generate
def generate(self):
DistributedObject.announceGenerate(self)
self.trolleyStation = self.cr.playGame.hood.loader.geom.find('**/prop_trolley_station_DNARoot')
self.trolleyCar = self.trolleyStation.find('**/trolley_car')
self.trolleyKey = self.trolleyStation.find('**/key')
tn = TextNode('trolleycountdowntext')
tn.setFont(CIGlobals.getMickeyFont())
tn.setTextColor(1, 0, 0, 1)
self.countdownText = self.trolleyStation.attachNewNode(tn)
self.countdownText.setScale(3.0)
self.countdownText.setPos(14.58, 10.77, 11.17)
self.acceptOnce('entertrolley_sphere', self.__handleTrolleyTrigger)
示例15: createActor
def createActor(self, render, username, x, y, z, h):
actor = PlayerObject(render, username, x, y, z, h)
# Displays username above Ralph character
nameplate = TextNode('textNode username_' + str(username))
nameplate.setText(username)
npNodePath = actor.actor.attachNewNode(nameplate)
npNodePath.setScale(1.0)
npNodePath.setBillboardPointEye()
npNodePath.setZ(8.0)
return actor