当前位置: 首页>>代码示例>>Python>>正文


Python TextNode.setCardColor方法代码示例

本文整理汇总了Python中panda3d.core.TextNode.setCardColor方法的典型用法代码示例。如果您正苦于以下问题:Python TextNode.setCardColor方法的具体用法?Python TextNode.setCardColor怎么用?Python TextNode.setCardColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在panda3d.core.TextNode的用法示例。


在下文中一共展示了TextNode.setCardColor方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: draw_mstr

# 需要导入模块: from panda3d.core import TextNode [as 别名]
# 或者: from panda3d.core.TextNode import setCardColor [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)
开发者ID:agoose77,项目名称:hivesystem,代码行数:28,代码来源:pandacanvas_mstr.py

示例2: drawBuilding

# 需要导入模块: from panda3d.core import TextNode [as 别名]
# 或者: from panda3d.core.TextNode import setCardColor [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()
开发者ID:mzdravkov,项目名称:comori,代码行数:27,代码来源:game_app.py

示例3: attachHostNameToSign

# 需要导入模块: from panda3d.core import TextNode [as 别名]
# 或者: from panda3d.core.TextNode import setCardColor [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)
开发者ID:nate97,项目名称:src,代码行数:33,代码来源:DistributedParty.py

示例4: drawFigures

# 需要导入模块: from panda3d.core import TextNode [as 别名]
# 或者: from panda3d.core.TextNode import setCardColor [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()
开发者ID:mzdravkov,项目名称:comori,代码行数:59,代码来源:game_app.py

示例5: _show

# 需要导入模块: from panda3d.core import TextNode [as 别名]
# 或者: from panda3d.core.TextNode import setCardColor [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
开发者ID:agoose77,项目名称:hivesystem,代码行数:16,代码来源:coloredtextbox_panda.py

示例6: load

# 需要导入模块: from panda3d.core import TextNode [as 别名]
# 或者: from panda3d.core.TextNode import setCardColor [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)
开发者ID:nate97,项目名称:src,代码行数:17,代码来源:CogdoUtil.py

示例7: _draw

# 需要导入模块: from panda3d.core import TextNode [as 别名]
# 或者: from panda3d.core.TextNode import setCardColor [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
开发者ID:agoose77,项目名称:hivesystem,代码行数:18,代码来源:panda_str.py

示例8: __init__

# 需要导入模块: from panda3d.core import TextNode [as 别名]
# 或者: from panda3d.core.TextNode import setCardColor [as 别名]
    def __init__(self,
                 horzmargin=0.5,        # horizontal margin in characters
                 vertmargin=1,          # vertical margin in charaters
                 width=30,              # width of the text box in characters
                 height=5,              # height of the text box in lines
                 scale=0.05,            # scaling of the text box
                 pos=(-3.1,-0.6),         # position of the upper-left corner inside the aspect2d viewport
                 font='arial.ttf',      # font to use for the text
                 align='left',          # alignment of the text (can be 'left', 'center', or 'right')
                 textcolor=(1,1,1,1),   # (r,g,b,a) text color
                 framecolor=(0,0,0,1),  # (r,g,b,a) frame color
                 *args,**kwargs
                 ): 
        
        """Construct a new TextPresenter."""
        MessagePresenter.__init__(self,*args,**kwargs)

        if align == 'left':
            align = TextNode.ALeft
        elif align == 'right':
            align = TextNode.ARight
        else:
            align = TextNode.ACenter

        text = TextNode('TextPresenter')
        text.setText('\n')
        font = loader.loadFont(font)
        text.setFont(font)
        text.setAlign(align)
        text.setWordwrap(width)
        text.setTextColor(textcolor[0],textcolor[1],textcolor[2],textcolor[3])
        if framecolor[3] > 0:
            text.setCardColor(framecolor[0],framecolor[1],framecolor[2],framecolor[3])
            text.setCardActual(-horzmargin,width+horzmargin,-(height+vertmargin),vertmargin)
        self.text = text
        self.text_nodepath = aspect2d.attachNewNode(text)
        self.text_nodepath.setScale(scale)        
        self.pos = pos        
        self.textcolor = textcolor
        pos = self.pos
        self.text_nodepath.setPos(pos[0],0,pos[1])
开发者ID:sccn,项目名称:SNAP,代码行数:43,代码来源:TextPresenter.py

示例9: Fighter

# 需要导入模块: from panda3d.core import TextNode [as 别名]
# 或者: from panda3d.core.TextNode import setCardColor [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")
#.........这里部分代码省略.........
开发者ID:sfaci,项目名称:fighter2d,代码行数:103,代码来源:Fighter.py

示例10: MessageWriter

# 需要导入模块: from panda3d.core import TextNode [as 别名]
# 或者: from panda3d.core.TextNode import setCardColor [as 别名]
class MessageWriter(DirectObject):
    def __init__(self):
        # the tasktime the last sign in the textfield was written
        self.lastSign = 0.0
        # the sign that is actually written in the textfield
        self.currentSign = 0
        # the text to write in the textfield
        self.textfieldText = ""
        # stop will be used to check if the writing is finished or
        # somehow else stoped
        self.stop = False
        # the speed new letters are added to the text
        # the time, how long the text is shown after it is fully written
        self.showlength = 4

        # the textfield to put instructions hints and everything else, that
        # should be slowly written on screen and disappear after a short while
        self.textfield = TextNode('textfield')
        self.textfield.clearText()
        self.textfield.setShadow(0.005, 0.005)
        self.textfield.setShadowColor(0, 0, 0, 1)
        self.textfield.setWordwrap(base.a2dRight*2-0.4)
        self.textfield.setCardActual(
            -0.1, base.a2dRight*2-0.3,
            0.1, base.a2dBottom+0.5)
        self.textfield.setCardColor(0,0,0,0.45)
        self.textfield.setFlattenFlags(TextNode.FF_none)
        self.textfield.setTextScale(0.06)
        self.textfieldNodePath = aspect2d.attachNewNode(self.textfield)
        self.textfieldNodePath.setScale(1)
        self.textfieldNodePath.setPos(base.a2dLeft+0.2, 0, -0.4)

        self.hide()

    def show(self):
        self.textfieldNodePath.show()

    def hide(self):
        self.textfield.clearText()
        self.textfieldNodePath.hide()

    def clear(self):
        """Clear the textfield and stop the current written text"""
        self.hide()
        taskMgr.remove("writeText")
        self.stop = False
        self.writeDone = False
        self.currentSign = 0
        self.lastSign = 0.0
        self.textfield.clearText()

    def cleanup(self):
        """Function that should be called to remove and reset the
        message writer"""
        self.clear()
        self.ignore("showMessage")

    def run(self):
        """This function can be called to start the writer task."""
        self.textfield.setFlattenFlags(TextNode.FF_none)
        taskMgr.add(self.__writeText, "writeText", priority=30)

    def setMessageAndShow(self, message):
        """Function to simply add a new message and show it if no other
        message is currently shown"""
        self.clear()
        logging.debug("show message %s" % message)
        self.textfieldText = message
        self.show()
        # start the writer task
        self.run()

    def __writeText(self, task):
        elapsed = globalClock.getDt()
        if(self.stop):
            # text is finished and can be cleared now
            self.clear()
            return task.done

        if self.currentSign == len(self.textfieldText)-1:
            self.textfield.setFlattenFlags(TextNode.FF_dynamic_merge)

        if self.currentSign >= len(self.textfieldText):
            # check if the text is fully written
            if task.time - self.lastSign >= self.showlength:
                # now also check if the time the text should
                # be visible on screen has elapsed
                self.stop = True
                self.textfieldNodePath.flattenStrong()
        elif (task.time - self.lastSign > base.textWriteSpeed) and (not self.stop):
            # write the next letter of the text
            self.textfield.appendText(self.textfieldText[self.currentSign])
            self.currentSign += 1
            self.lastSign = task.time

        return task.cont
开发者ID:grimfang,项目名称:owp_ajaw,代码行数:98,代码来源:textfield.py

示例11: Cog

# 需要导入模块: from panda3d.core import TextNode [as 别名]
# 或者: from panda3d.core.TextNode import setCardColor [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:
#.........这里部分代码省略.........
开发者ID:Teku16,项目名称:Doomsday,代码行数:103,代码来源:Cog.py


注:本文中的panda3d.core.TextNode.setCardColor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。