本文整理汇总了Python中panda3d.core.TextNode.setCardDecal方法的典型用法代码示例。如果您正苦于以下问题:Python TextNode.setCardDecal方法的具体用法?Python TextNode.setCardDecal怎么用?Python TextNode.setCardDecal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类panda3d.core.TextNode
的用法示例。
在下文中一共展示了TextNode.setCardDecal方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: draw_mstr
# 需要导入模块: from panda3d.core import TextNode [as 别名]
# 或者: from panda3d.core.TextNode import setCardDecal [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)
示例2: drawBuilding
# 需要导入模块: from panda3d.core import TextNode [as 别名]
# 或者: from panda3d.core.TextNode import setCardDecal [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()
示例3: attachHostNameToSign
# 需要导入模块: from panda3d.core import TextNode [as 别名]
# 或者: from panda3d.core.TextNode import setCardDecal [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)
示例4: drawFigures
# 需要导入模块: from panda3d.core import TextNode [as 别名]
# 或者: from panda3d.core.TextNode import setCardDecal [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()
示例5: _show
# 需要导入模块: from panda3d.core import TextNode [as 别名]
# 或者: from panda3d.core.TextNode import setCardDecal [as 别名]
def _show(self, ctb, identifier):
if self.node is not None: self.node.removeNode()
tnode = TextNode(identifier)
tnode.setText(ctb.text)
r, g, b, a = ctb.textcolor
tnode.setTextColor(r, g, b, a)
r, g, b, a = ctb.boxcolor
tnode.setCardColor(r, g, b, a)
tnode.setCardAsMargin(0, 0, 0, 0)
tnode.setCardDecal(True)
node = NodePath(tnode)
self._scale(tnode, node)
node.reparentTo(self.pnode)
self.node = node
示例6: load
# 需要导入模块: from panda3d.core import TextNode [as 别名]
# 或者: from panda3d.core.TextNode import setCardDecal [as 别名]
def load(self):
from toontown.toonbase import ToontownGlobals
from panda3d.core import TextNode
textNode = TextNode('moviedialogue')
textNode.setTextColor(0, 0, 0, 1)
textNode.setCardColor(1, 1, 1, 1)
textNode.setCardAsMargin(0, 0, 0, 0)
textNode.setCardDecal(True)
textNode.setWordwrap(27.0)
textNode.setAlign(TextNode.ACenter)
textNode.setFont(ToontownGlobals.getToonFont())
self._dialogueLabel = aspect2d.attachNewNode(textNode)
self._dialogueLabel.setScale(0.06, 0.06, 0.06)
self._dialogueLabel.setPos(0.32, 0, -0.75)
self._dialogueLabel.reparentTo(hidden)
示例7: cityLabels
# 需要导入模块: from panda3d.core import TextNode [as 别名]
# 或者: from panda3d.core.TextNode import setCardDecal [as 别名]
def cityLabels(self, citylabels, terrain):
children = self.cityLabels.getChildren()
for child in children:
child.removeNode()
for ident, city in citylabels.items():
text = city['name'] + "\n" + city["mayor"] + "\n" + "Population: " + str(city['population'])
label = TextNode(str(ident) + " label")
label.setText(text)
label.setTextColor(1, 1, 1, 1)
label.setShadowColor(0, 0, 0, 1)
label.setCardDecal(True)
textNodePath = self.cityLabels.attachNewNode(label)
textNodePath.setPos(city['position'][0], city["position"][1], city['position'][2])
textNodePath.setLightOff()
textNodePath.setBillboardPointEye()
示例8: _draw
# 需要导入模块: from panda3d.core import TextNode [as 别名]
# 或者: from panda3d.core.TextNode import setCardDecal [as 别名]
def _draw(self, string, identifier, parentnode, parameters):
if self.node is not None: self.node.removeNode()
tnode = TextNode(identifier)
tnode.setText(string)
# TODO: use more parameters
if hasattr(parameters, "cardcolor"):
tnode.setCardColor(*parameters.cardcolor)
tnode.setCardAsMargin(0, 0, 0, 0)
tnode.setCardDecal(True)
aspect = True
if hasattr(parameters, "aspect"):
aspect = parameters.aspect
node = NodePath(tnode)
self._scale(tnode, node, aspect)
node.reparentTo(parentnode)
self.node = node
示例9: Fighter
# 需要导入模块: from panda3d.core import TextNode [as 别名]
# 或者: from panda3d.core.TextNode import setCardDecal [as 别名]
class Fighter(DirectObject):
def __init__(self):
base.disableMouse()
# Carga el fondo del juego
self.bg = loader.loadModel("models/plane")
self.bg.reparentTo(camera)
self.bg.setPos(0, 200, 0)
self.bg.setScale(300, 0, 146)
self.bg.setTexture(loader.loadTexture("models/Backgrounds/farback.png"), 1)
# Inicializa el gestor de teclado y los objetos del juego
self.inputManager = InputManager()
# Inicializa el menu del juego
self.inicializarMenu()
self.marcador = None
self.barraEnergia = None
self.marcadorFinalNP = None
self.entrada = None
self.rankingNP = None
self.mostrarMenuJuego()
self.accept("m", self.cambiarMenuJuego)
self.accept("q", self.salir)
# Inicializa el menu
def inicializarMenu(self):
self.menuGraphics = loader.loadModel("models/MenuGraphics")
self.fonts = {"silver" : loader.loadFont("fonts/LuconSilver"),
"blue" : loader.loadFont("fonts/LuconBlue"),
"orange" : loader.loadFont("fonts/LuconOrange")}
self.menu = Menu(self.menuGraphics, self.fonts, self.inputManager)
self.menu.initMenu([0, None,
["Nueva Partida", "Salir"],
[[self.nuevaPartida], [self.salir]],
[[None], [None]]])
# Comienza una partida
def nuevaPartida(self):
if (not self.marcadorFinalNP is None):
self.marcadorFinalNP.detachNode()
self.marcadorFinalNP.remove()
if (not self.rankingNP is None):
self.rankingNP.detachNode()
self.rankingNP.remove()
self.ship = Ship(self.inputManager)
self.mostrarInfo()
taskMgr.add(self.actualizarInfo, "Actualizar Puntuacion")
# Inicializa y muestra el marcador del jugador
def mostrarInfo(self):
self.marcador = TextNode("Marcador")
self.marcador.setText("Puntos: " + str(self.ship.puntos))
self.marcador.setCardColor(0, 0, 0, 1)
self.marcador.setCardDecal(True)
self.marcador.setCardAsMargin(0.4, 0.4, 0.4, 0.4)
self.marcadorNP = aspect2d.attachNewNode(self.marcador)
self.marcadorNP.reparentTo(base.a2dTopLeft)
self.marcadorNP.setPos(0.02, 0, -0.05)
self.marcadorNP.setScale(0.07)
self.barraEnergia = DirectWaitBar(text = "Energia", value = 5,
range = 5, scale = 0.3, pos = (0, 0, 0.95))
# Actualiza la puntuacion del jugador en pantalla
def actualizarInfo(self, tarea):
self.marcador.setText("Puntos: " + str(self.ship.puntos))
self.barraEnergia["value"] = self.ship.vida
self.barraEnergia.setValue()
# Termina la partida
if (self.ship.terminarPartida):
self.terminarPartida()
return tarea.done
return tarea.cont
# Termina partida liberando recursos para poder empezar una nueva
# sin reiniciar el juego
def terminarPartida(self):
# Solicita al usuario un nombre para la tabla de puntuaciones
self.entrada = DirectEntry(width = 15, numLines = 1, scale = 0.07,
cursorKeys = 1, frameSize = (0, 15, 0, 1), command = self.almacenarPuntuacion,
pos = (-0.3, 0, 0.1), focus = True, text_pos = (0.2, 0.2))
self.puntos = self.ship.puntos
self.ship.ship.detachNode()
self.ship.ship.remove()
taskMgr.remove("Mover Nave")
taskMgr.remove("Generar Enemigos")
taskMgr.remove("Comprobar Impactos")
taskMgr.remove("Actualizar Puntuacion")
#.........这里部分代码省略.........
示例10: Cog
# 需要导入模块: from panda3d.core import TextNode [as 别名]
# 或者: from panda3d.core.TextNode import setCardDecal [as 别名]
class Cog(DirectObject):
def __init__(self, name, dept, suit, head, handColor, height, minLevel, maxLevel):
self.name = name
self.dept = dept
self.head = head
self.headObj = None
self.headAccessory = head.getAccessory()
self.suit = suit
self.handColor = handColor
self.height = height
self.level = random.randint(minLevel, maxLevel)
self.minLevel = minLevel
self.maxLevel = maxLevel
self.version = 1
self.hit = False
self.isDefeated = False
self.healthBar = None
self.healthCondition = 0
def generate(self, isSkeleton = False, isWaiter = False):
self.isSkeleton = isSkeleton
self.isWaiter = isWaiter
self.suit.setupSuit(self.dept.getDept(), self.handColor, isSkeleton, isWaiter)
self.suit.generate()
self.cog = self.suit.getActor()
self.cog.setPythonTag('Cog', self)
self.cog.setName(self.name)
self.cog.flattenStrong()
if(self.level % 12 != 0):
self.hp = (self.level + 1) * (self.level + 2)
else:
self.hp = (self.level / 12) * 200
self.maxHp = self.hp
if not isSkeleton:
self.headObj = self.head.generate(self.headAccessory)
self.head.getHead().reparentTo(self.cog.find('**/joint_head'))
self.corpMedallion = self.cog.find('**/Medallion')
self.generateHealthBar()
self.createNameTag()
if not self.isSkeleton:
if(self.headObj.getChildren().size() == 0 and self.head.hasAccessory()):
self.head.attemptAccessoryFix()
def createNameTag(self):
try:
if(self.nameTag):
self.nameTagPath.removeNode()
except: pass
self.nameTag = TextNode("NameTag")
dept = self.dept.getGameDept()
name = self.name
if self.isSkeleton:
name = "Skelecog"
if(self.version == 1):
self.nameTag.setText('%s\n%s\nLevel %s' % (name, dept, self.level))
else:
self.nameTag.setText('%s\n%s\nLevel %s v%s.0' % (name, dept, self.level, self.version))
cogFont = Globals.getFont('vtRemingtonPortable.ttf')
self.nameTag.setFont(cogFont)
self.nameTagPath = render.attachNewNode(self.nameTag)
self.nameTagPath.reparentTo(self.cog.find('**/joint_nameTag'))
self.nameTagPath.setBillboardPointEye(0)
head = self.head.getHead()
jointPos = self.cog.find('**/joint_head').getPos(render)
if(head != None):
min, max = head.getTightBounds()
size = max - min
zPos = head.getPos(render).getZ() - size.getZ()
pos = head.getPos(render).getZ() + size.getZ() + 2.4
else:
pos = jointPos.getZ() + 2.4
self.nameTagPath.setZ(pos)
self.nameTag.setAlign(TextNode.ACenter)
self.nameTag.setCardColor(0.8, 0.8, 0.8, 0.5)
self.nameTag.setCardAsMargin(0,0,0,-0.2)
self.nameTag.setCardDecal(True)
self.nameTag.setTextColor(0.2,0.2,0.2,1.0)
self.nameTagPath.setScale(0.35)
def playAnim(self, anim, playRate, loop):
if(loop):
ActorInterval(self.cog, anim, playRate = playRate).loop()
else:
ActorInterval(self.cog, anim, playRate = playRate)
def updateHealthBar(self):
health = float(float(self.hp) / float(self.maxHp))
if health < 1:
self.corpMedallion.hide()
self.healthBar.show()
if health > 0.95:
condition = 0
elif health > 0.7:
condition = 1
elif health > 0.3:
condition = 2
elif health > 0.05:
condition = 3
elif health > 0:
#.........这里部分代码省略.........