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


Python DirectWaitBar.setBillboardPointEye方法代码示例

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


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

示例1: __init__

# 需要导入模块: from direct.gui.DirectGui import DirectWaitBar [as 别名]
# 或者: from direct.gui.DirectGui.DirectWaitBar import setBillboardPointEye [as 别名]
    def __init__(self):
        #create Queue to hold the incoming chat
        #request the heartbeat so that the caht interface is being refreshed in order to get the message from other player
        
        self.keyMap = {"left":0, "right":0, "forward":0, "cam-left":0, "cam-right":0, "charge":0}
        base.win.setClearColor(Vec4(0,0,0,1))

        self.cManager = ConnectionManager()
        self.cManager.startConnection()
        #------------------------------
        #Chat
        Chat(self.cManager)
        
        
        #send dummy login info of the particular client
        #send first chat info 
        #---------------------------------------
        self.userName = username
        dummy_login ={'user_id' : self.userName, 'factionId': faction, 'password': '1234'}
        self.cManager.sendRequest(Constants.RAND_STRING, dummy_login)
        
        
        chat = { 'userName' : self.userName,     #username
                 'message'    : '-------Login------' }
        self.cManager.sendRequest(Constants.CMSG_CHAT, chat)

        #--------------------------------------
        #self.minimap = OnscreenImage(image="images/minimap.png", scale=(0.2,1,0.2), pos=(-1.1,0,0.8))

        #frame = DirectFrame(text="Resource Bar", scale=0.001)

        resource_bar = DirectWaitBar(text="",
            value=35, range=100, pos=(0,0,0.9), barColor=(255,255,0,1),
            frameSize=(-0.3,0.3,0,0.03))
        cp_bar = DirectWaitBar(text="",
            value=70, range=100, pos=(1.0,0,0.9), barColor=(0,0,255,1),
            frameSize=(-0.3,0.3,0,0.03), frameColor=(255,0,0,1))

        # Set up the environment
        #
        # This environment model contains collision meshes.  If you look
        # in the egg file, you will see the following:
        #
        #    <Collide> { Polyset keep descend }
        #
        # This tag causes the following mesh to be converted to a collision
        # mesh -- a mesh which is optimized for collision, not rendering.
        # It also keeps the original mesh, so there are now two copies ---
        # one optimized for rendering, one for collisions.  

        

        self.environ = loader.loadModel("models/world")      
        self.environ.reparentTo(render)
        self.environ.setPos(0,0,0)
        
        # Create the main character, Ralph

        ralphStartPos = self.environ.find("**/start_point").getPos()
        self.ralph = Actor("models/ralph",
                                 {"run":"models/ralph-run",
                                  "walk":"models/ralph-walk"})
        self.ralph.reparentTo(render)
        self.ralph.setScale(.2)
        self.ralph.setPos(ralphStartPos)

        nameplate = TextNode('textNode username_' + str(self.userName))
        nameplate.setText(self.userName)
        npNodePath = self.ralph.attachNewNode(nameplate)
        npNodePath.setScale(0.8)
        npNodePath.setBillboardPointEye()
        #npNodePath.setPos(1.0,0,6.0)
        npNodePath.setZ(6.5)

        bar = DirectWaitBar(value=100, scale=1.0)
        bar.setColor(255,0,0)
        #bar.setBarRelief()
        bar.setZ(6.0)
        bar.setBillboardPointEye()
        bar.reparentTo(self.ralph)

        # Create a floater object.  We use the "floater" as a temporary
        # variable in a variety of calculations.
        
        self.floater = NodePath(PandaNode("floater"))
        self.floater.reparentTo(render)

        # Accept the control keys for movement and rotation

        self.accept("escape", sys.exit)
        self.accept("arrow_left", self.setKey, ["left",1])
        self.accept("arrow_right", self.setKey, ["right",1])
        self.accept("arrow_up", self.setKey, ["forward",1])
        self.accept("a", self.setKey, ["cam-left",1])
        self.accept("s", self.setKey, ["cam-right",1])
        self.accept("arrow_left-up", self.setKey, ["left",0])
        self.accept("arrow_right-up", self.setKey, ["right",0])
        self.accept("arrow_up-up", self.setKey, ["forward",0])
        self.accept("a-up", self.setKey, ["cam-left",0])
        self.accept("s-up", self.setKey, ["cam-right",0])
#.........这里部分代码省略.........
开发者ID:jaimodha,项目名称:MMOG,代码行数:103,代码来源:Ralph.py

示例2: Enemy

# 需要导入模块: from direct.gui.DirectGui import DirectWaitBar [as 别名]
# 或者: from direct.gui.DirectGui.DirectWaitBar import setBillboardPointEye [as 别名]

#.........这里部分代码省略.........
            
            for i in range(4):
                if( dir == 0 ):
                    nextBlock = self.map[row][col + 1]
                elif( dir == 1 ):
                    nextBlock = self.map[row - 1][col]
                elif( dir == 2 ):
                    nextBlock = self.map[row][col - 1]
                else:
                    nextBlock = self.map[row + 1][col]
                
                if( nextBlock.isType(PathBlock) or nextBlock.isType(EndBlock) ):
                    self.direction = dir
                    break
                
                dir = (dir + 1) % 4
                nextBlock = 0
                
        return nextBlock
        
    # Finds the first path block after the start block
    def findFirstPathBlock(self, currentBlock):
        (row, ignore, col) = currentBlock.index.partition(' ')
        row = int(row)
        col = int(col)
        dir = 0
        
        for dir in range(4):
                if( dir == 0 ):
                    nextBlock = self.map[row][col + 1]
                elif( dir == 1 ):
                    nextBlock = self.map[row - 1][col]
                elif( dir == 2 ):
                    nextBlock = self.map[row][col - 1]
                else:
                    nextBlock = self.map[row + 1][col]
                
                if( nextBlock.isType(PathBlock) ):
                    self.direction = dir
                    break
                
                nextBlock = 0
        
        return nextBlock
    
    # Removes the enemy once it has died or reached the end block
    def remove(self, task = None):
        #self.moveLerp.finish()
        self.isActive = 0
        self.eNode.removeNode()
        self.sphere.removeNode()
        taskMgr.remove('move' + str(self.index))
        messenger.send('enemy_removed', [self])
        
    # Sets up collision geometry so towers can find the enemy
    def setupCollision(self):
        self.sphere = self.eNode.attachNewNode( CollisionNode('object') )
        self.sphere.node().addSolid( CollisionSphere(0, 0, 0, 0.1) )
        self.sphere.node().setFromCollideMask( BitMask32.allOff() )
        self.sphere.node().setIntoCollideMask( BitMask32(2) )
        
    def setIndex(self, index):
        self.sphere.setTag('index', str(index) )
        self.index = index
        
    # Creates the health bar above the enemy
    def setupHealthBar(self):
        self.hpBar = DirectWaitBar( text = "", value = 100.0, pos = (0, 0, 1.5), scale = 0.3, barColor = Vec4(1, 0, 0, 1) )
        self.hpBar.setBillboardPointEye() 
        self.hpBar.reparentTo(self.eNode)
        #self.hpBar.clearColor()
        
    # Decreases the health of the enemy by the damage it takes
    def takeDamage(self, damage):
        self.health -= damage
        self.hpBar['value'] = (1.0 * self.health) / self.maxHealth * 100
        if( self.health <= 0 ):
            self.remove()
            
    def slow(self, fraction, duration):
        self.moveSpeed = self.maxMoveSpeed * fraction
        self.model.setColor( SLOW_COLOR )
        
        taskMgr.remove( 'removeSlow' + str(self.index) )
        taskMgr.doMethodLater( duration, self.removeSlow, 'removeSlow' + str(self.index) )
        
    def removeSlow(self, task = None):
        self.moveSpeed = self.maxMoveSpeed
        self.model.clearColor()
        
    def stun(self, duration):
        self.moveSpeed = 0
        self.model.setColor( STUN_COLOR )
        
        taskMgr.remove( 'removeStun' + str(self.index) )
        taskMgr.doMethodLater( duration, self.removeStun, 'removeStun' + str(self.index) )
        
    def removeStun(self, task = None):
        self.moveSpeed = self.maxMoveSpeed
        self.model.clearColor()
开发者ID:genusgant,项目名称:Panda3d-TowerDefense_Game,代码行数:104,代码来源:gameAssets.py


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