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


Python Character.getActor方法代码示例

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


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

示例1: World

# 需要导入模块: from Character import Character [as 别名]
# 或者: from Character.Character import getActor [as 别名]
class World(DirectObject):

    currentTime = 0
    idleTime = 0
    mySequence = None
    pandaPace = None
    jumpState = False
    isWalk = False
    previousPos = None #used to store the mainChar pos from one frame to another
    host = ""
    port = 0
    characters = []  #Stores the list of all the others players characters

    def __init__(self):
        # Network Setup
        print "Object Created"
        self.characters = []
    def setConnectionManager(self, connectionManager):
        self.cManager = connectionManager

    def initWorld(self, playerId, chosenCharId, x, y, h):

        self.keyMap = {"hello":0, "left":0, "right":0, "forward":0, "backward":0, "cam-left":0, "cam-right":0, "chat":0, "fast":0, "chat0": 0, "chat1": 0, "users": 0}
        base.win.setClearColor(Vec4(0,0,0,1))
		# chat box
        self.chatbox = Chat(self.cManager, self)
        self.activeUsers = Users(self.cManager, self)

        taskMgr.add(self.message, 'message')


        # Post the instructions

        self.title = addTitle("Panda3D Tutorial: Roaming Ralph (Walking on the Moon)")
        self.inst1 = addInstructions(0.95, "[ESC]: Quit")
        self.inst2 = addInstructions(0.90, "[A]: Rotate Ralph Left")
        self.inst3 = addInstructions(0.85, "[D]: Rotate Ralph Right")
        self.inst4 = addInstructions(0.80, "[W]: Run Ralph Forward")
        self.inst4 = addInstructions(0.75, "[S]: Run Ralph Backward")
        self.inst6 = addInstructions(0.70, "[Left Arrow]: Rotate Camera Left")
        self.inst7 = addInstructions(0.65, "[Right Arrow]: Rotate Camera Right")
        self.inst8 = addInstructions(0.60, "[0]: Toggle Chat Broadcast")
        self.inst9 = addInstructions(0.55, "[1]: Toggle Private Chat - username/")
        self.inst10 = addInstructions(0.50, "[L]: List Connected Users")


        # Set up the environment
        #
        self.environ = loader.loadModel("models/square")
        self.environ.reparentTo(render)
        self.environ.setPos(0,0,0)
        self.environ.setScale(100,100,1)
        self.moon_tex = loader.loadTexture("models/moon_1k_tex.jpg")
      	self.environ.setTexture(self.moon_tex, 1)

        #Collision Code
        # Initialize the collision traverser.
        base.cTrav = CollisionTraverser()
        # Initialize the Pusher collision handler.
        self.pusher = CollisionHandlerPusher()

        self.bTrav = base.cTrav
        # Create the main character, Ralph
        self.mainCharRef = Character(self, chosenCharId, True)
        self.mainCharRef.setPlayerId(playerId)
        self.characters.append(self.mainCharRef)
        self.mainChar = self.mainCharRef.getActor()


        #Create second bike
        self.mainCharRef2 = Character(self, 3, True)
        self.mainCharRef2.setPlayerId(2)
        self.characters.append(self.mainCharRef2)
        self.mainChar2 = self.mainCharRef2.getActor()

        resetPos = True
        if (x == 0 and y == 0):
            resetPos = False
        if resetPos:
            self.mainChar.setPos(x, y, 0)
        self.mainChar.setH(h)

        self.cManager.sendRequest(Constants.CMSG_CREATE_CHARACTER, [playerId,
                                                                    chosenCharId,
                                                                    self.mainChar.getX(),
                                                                    self.mainChar.getY(),
                                                                    self.mainChar.getZ()])


        self.previousPos = self.mainChar.getPos()
        taskMgr.doMethodLater(.1, self.updateMove, 'updateMove')

        # Creating Stationary spheres
        self.spheres = []
        self.sphereCount = 3
        for x in range(self.sphereCount):
            self.spheres.append(StationarySphere(self))
        for sphere in self.spheres:
            taskMgr.add(sphere.rotateForAll, "rotateSphere")

#.........这里部分代码省略.........
开发者ID:debasishgt,项目名称:dd-team,代码行数:103,代码来源:finalhw1.py


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