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


Python ParticleEffect.reparentTo方法代码示例

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


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

示例1: smoke_emitter

# 需要导入模块: from direct.particles.ParticleEffect import ParticleEffect [as 别名]
# 或者: from direct.particles.ParticleEffect.ParticleEffect import reparentTo [as 别名]
class smoke_emitter():
    def __init__(self, parent, _x, _y, _z):
        self.x = _x
        self.y = _y
        self.z = _z
        self.parent = parent
        self.p = ParticleEffect()
        self.load_config('steam.ptf')
        self.p.setScale(200)

    def load_config(self, file_name):
        self.p.cleanup()
        self.p = ParticleEffect()
        self.p.loadConfig(file_name)
        self.p.start(render)
        self.p.setPos(self.x, self.y, self.z)
        self.p.reparentTo(self.parent)
开发者ID:daFthawk,项目名称:group-3,代码行数:19,代码来源:smoke_emitter.py

示例2: mouBala

# 需要导入模块: from direct.particles.ParticleEffect import ParticleEffect [as 别名]
# 或者: from direct.particles.ParticleEffect.ParticleEffect import reparentTo [as 别名]
 def mouBala(bala, balaImage, vel, queue, task):
     if task.time > 3:
         balaImage.detachNode()
         expbala = ParticleEffect()
         expbala.reparentTo(self.particlesDummy)
         expbala.loadConfig("explosio.ptf")
         expbala.start(bala)
         taskMgr.doMethodLater(0.25, suprimir, "suprimir", extraArgs=[bala, expbala])
         return task.done
     if queue.getNumEntries() != 0:
         balaImage.detachNode()
         entry = queue.getEntry(0)
         bala.setPos(entry.getSurfacePoint(self.particlesDummy))
         expbala = ParticleEffect()
         expbala.reparentTo(self.particlesDummy)
         expbala.loadConfig("explosio.ptf")
         expbala.start(bala)
         taskMgr.doMethodLater(0.25, suprimir, "suprimir", extraArgs=[bala, expbala])
         return task.done
     bala.setFluidPos(bala, 0, vel * globalClock.getDt(), 0)
     balaImage.setR(balaImage, 1000 * globalClock.getDt())
     return task.cont
开发者ID:rhaps0dy,项目名称:FlyingGame,代码行数:24,代码来源:main.py

示例3: Dorf

# 需要导入模块: from direct.particles.ParticleEffect import ParticleEffect [as 别名]
# 或者: from direct.particles.ParticleEffect.ParticleEffect import reparentTo [as 别名]
class Dorf(DirectObject):
    idgen = count()

    def __init__(self, pos, world):
        self.id = next(Dorf.idgen)
        self.world = world
        self.node = loader.loadModel('media/models/dorfPH.egg')
        self.text = core.TextNode('dorf')
        self.text.setText('Dorf {}'.format(self.id))
        self.text.setAlign(core.TextNode.ACenter)
        self.text.setTextColor(1, 1, 0.5, 1)
        self.text.setShadow(0.1, 0.1)
        self.text.setShadowColor(0, 0, 0, 0.8)
        self.textnode = self.node.attachNewNode(self.text)
        self.textnode.setBillboardPointEye()
        self.textnode.setPos(0, 0, 1.1)
        self.textnode.setScale(0.4)
        self.textnode.setDepthWrite(False)
        self.textnode.setDepthTest(False)
        self.textnode.setShaderOff()
        self.x = int(pos.x)
        self.y = int(pos.y)
        self.z = 0
        self.next = None
        self.dir = (1, 0)

        taskMgr.doMethodLater(0.5, self.move, 'Move dorf')

        self.set_z(int(pos.z))
        self.node.setPos(pos.x, pos.y, 0)

        self.particles = ParticleEffect()
        self.particles.loadConfig('media/sparks.ptf')
        self.particles.reparentTo(self.node)

    def set_z(self, z):
        self.z = z
        messenger.send('entity-z-change', [self])

    def move(self, task):
        if self.next:
            self.x, self.y, z = self.next
            self.node.setPos(self.x, self.y, 0)
            if self.z != z:
                self.set_z(z)

        b = self.world.get_block(self.x, self.y, self.z)
        if b.is_ramp:
            self.node.setPos(self.x, self.y, 0.5)
        else:
            self.node.setPos(self.x, self.y, 0.0)

        if b.is_block:
            self.world.set_block(self.x, self.y, self.z, self.world.forms['Void'], 0, False)
            self.particles.setPos(0, 0, 0)
            self.particles.start()
            for p in self.particles.getParticlesList():
                p.induceLabor()
            #taskMgr.doMethodLater(1.0, self.particles.disable, 'stop particling', extraArgs=[])

        self.set_next()
        self.node.lookAt(self.next[0], self.next[1], 0)

        return task.again

    def set_next(self):
        x, y, z = self.x + self.dir[0], self.y + self.dir[1], self.z
        if (x, y, z) not in self.world or random.random() < 0.4:
            ds = [((dx, dy), (self.x + dx, self.y + dy, self.z))
                  for dx, dy in [(1, 0), (0, 1), (0, -1), (-1, 0)]]
            self.dir, np = random.choice([(d, n) for d, n in ds if n in self.world])
            x, y, z = np

        b = self.world.get_block(x, y, z)

        if b.is_void and not b.down.is_block:
            z -= 1

        self.next = (x, y, z)
开发者ID:anossov,项目名称:dorfdelf,代码行数:81,代码来源:dorf.py

示例4: Player

# 需要导入模块: from direct.particles.ParticleEffect import ParticleEffect [as 别名]
# 或者: from direct.particles.ParticleEffect.ParticleEffect import reparentTo [as 别名]
class Player(DirectObject):
    def __init__(self, dogSelection):
        self.playing_dead = False
        self._keymap = {
                'forward' : 0,
                'reverse' : 0,
                'right'   : 0,
                'left'    : 0,
                'jump'    : 0,
                'bark'    : 0,
        }
        self._dir = 0
        self.dogSelection = dogSelection
        if self.dogSelection == 2:
            self._coll_dist = 4
            self._coll_dist_h = 1.5
        else:
            self._coll_dist = 6
            self._coll_dist_h = 3
        self._scale = .5 * settings.GLOBAL_SCALE
        self._load_models()
        self._load_sounds()
        self._load_lights()
        self._setup_actions()
        self._setup_tasks()
        self._setup_collisions()
        self.bag = None
        self.gravity = 0
        self.jumping = 15
        self.falling = 0
        self.package = False
        self.jumpingCurrently = False
        self.chase = False
        self.chasetimer = settings.PLAYER_CHASE_LENGTH
        self.inst1 = addInstructions(0.95, str(self._model.getPos()))
        self.blocks = []
        self.currentRoom = 1
        self.lose = False
        
        self.win = False
    def _load_models(self):
        if self.dogSelection == 2:
            self._model = Actor("models/sdog.egg", {"walking":"models/sdoganim.egg"})
            #self._model2 = Actor("models/sdogb.egg", {"walking":"models/sdoganimb.egg"})
        else:
            self._model = Actor("models/bdog", {"walking":"models/bdoganim.egg"})
            #self._model2 = Actor("models/bdogb", {"walking":"models/bdoganimb.egg"})
        self.animControl =self._model.getAnimControl('walking')
        self.currentFrame = self.animControl.getFrame()
        self._model.reparentTo(render)
        self._model.setScale(.5 * settings.GLOBAL_SCALE)
        self._model.setPos(550, 0, 5)
        self._model.setH(-90)
        self.p = ParticleEffect()

    def _load_sounds(self):
        self.sound_bark = loader.loadSfx(os.path.join("sound files", "Dog Barking.mp3"))
        self.sound_dog_footsteps = loader.loadSfx(os.path.join("sound files", "Dog Footsteps.mp3"))

    def _load_lights(self):
        pass

    def _setup_actions(self):
        """
        self.accept("arrow_up", self._set_key, ["reverse", 1])
        self.accept("arrow_up-up", self._set_key, ["reverse", 0])
        self.accept("arrow_down", self._set_key, ["forward", 1])
        self.accept("arrow_down-up", self._set_key, ["forward", 0])
        self.accept("arrow_left", self._set_key, ["left", 1])
        self.accept("arrow_left-up", self._set_key, ["left", 0])
        self.accept("arrow_right", self._set_key, ["right", 1])
        self.accept("arrow_right-up", self._set_key, ["right", 0])
        """
        self.accept("w", self._set_key, ["reverse", 1])
        self.accept("w-up", self._set_key, ["reverse", 0])
        self.accept("s", self._set_key, ["forward", 1])
        self.accept("s-up", self._set_key, ["forward", 0])
        self.accept("a", self._set_key, ["left", 1])
        self.accept("a-up", self._set_key, ["left", 0])
        self.accept("d", self._set_key, ["right", 1])
        self.accept("d-up", self._set_key, ["right", 0])
        self.accept("e", self._set_key, ["bark", 1])
        self.accept('space',self._set_key, ["jump", 1])
        self.accept('space-up', self._set_key, ["jump", 0])
        self.accept('f', self.play_dead)

    def _setup_tasks(self):
        self._prev_move_time = 0
        taskMgr.add(self._task_move, "player-task-move")
        taskMgr.add(self._update_camera, "update-camera")

    def _setup_collisions(self):
        self._coll_trav = CollisionTraverser()
        # Front collision
        self._gnd_handler_front = CollisionHandlerQueue()
        self._gnd_ray_front = CollisionRay()
        self._gnd_ray_front.setOrigin(0, self._coll_dist, 1)
        self._gnd_ray_front.setDirection(0, 0, -1)
        self._gnd_coll_front = CollisionNode('collision-ground-front')
        self._gnd_coll_front.addSolid(self._gnd_ray_front)
#.........这里部分代码省略.........
开发者ID:MrSuborbian88,项目名称:perfumedprotector,代码行数:103,代码来源:player.py


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