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


Python ParticleEffect.addForceGroup方法代码示例

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


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

示例1: Enemy

# 需要导入模块: from direct.particles.ParticleEffect import ParticleEffect [as 别名]
# 或者: from direct.particles.ParticleEffect.ParticleEffect import addForceGroup [as 别名]

#.........这里部分代码省略.........
        diff = angle - hpr.x 

        if diff > 180.0:
            diff = diff - 360

        if diff < -180.0:
            diff = diff + 360

        if diff > 5.0:
            diff = 5.0
        if diff < -5.0:
            diff = -5.0

        new = Vec3(diff, 0, 0) + hpr
        #self.np.setHpr(new)
        
        # move forward
        r = radians(new.x)
        curr = self.np.getPos()
        diff = Vec3(self.movespeed * cos(r), self.movespeed * sin(r), 0)
        self.np.setPos(curr + diff)"""

        if self.hp < 0.0 and self.dead == 0.0:
            self.dead = time 
            self.app.scene.remove(self)
            # Create particle effect before we go
            self.dnp.setPos(self.np.getPos())
            self.particles.start(parent = self.dnp, renderParent = self.app.render)
            self.np.detachNode()

            # Drop some loot
            self.app.item_manager.add_item(self.np.getPos(), "soul", self.level)
            # Give the player some points
            self.app.player.score = self.app.player.score + 100

    def apply_effect(self, target, timer):
        if self.last_activated - timer + self.activate_delay < 0.0:
            self.last_activated = timer
            target.hp = target.hp - self.damage
        if target.np.getName()[0] == 't':
            target.pursuers.append(self)
            #self.ai_b = self.ai_char.getAiBehaviors()
            #self.ai_b.pursue(self.np.getPos())
            self.ai_b.pauseAi("pursue")

    def load_particle_config(self):
        self.particles = ParticleEffect()
        self.particles.reset()
        self.particles.setPos(0.000, 0.000, 0.000)
        self.particles.setHpr(0.000, 0.000, 0.000)
        self.particles.setScale(1.000, 1.000, 1.000)
        p0 = Particles('particles-1')
        # Particles parameters
        p0.setFactory("PointParticleFactory")
        p0.setRenderer("SpriteParticleRenderer")
        p0.setEmitter("SphereVolumeEmitter")
        p0.setPoolSize(20)
        p0.setBirthRate(0.0100)
        p0.setLitterSize(20)
        p0.setLitterSpread(0)
        p0.setSystemLifespan(1.0100)
        p0.setLocalVelocityFlag(1)
        p0.setSystemGrowsOlderFlag(1)
        # Factory parameters
        p0.factory.setLifespanBase(1.0000)
        p0.factory.setLifespanSpread(0.0000)
        p0.factory.setMassBase(1.0000)
        p0.factory.setMassSpread(0.0100)
        p0.factory.setTerminalVelocityBase(1200.0000)
        p0.factory.setTerminalVelocitySpread(0.0000)
        # Point factory parameters
        # Renderer parameters
        p0.renderer.setAlphaMode(BaseParticleRenderer.PRALPHAOUT)
        p0.renderer.setUserAlpha(0.05)
        # Sprite parameters
        p0.renderer.setTexture(self.app.loader.loadTexture('effects/dust.png'))
        p0.renderer.setColor(Vec4(1.00, 0.10, 0.10, 0.50))
        p0.renderer.setXScaleFlag(2)
        p0.renderer.setYScaleFlag(2)
        p0.renderer.setAnimAngleFlag(0)
        p0.renderer.setInitialXScale(0.100 * self.level)
        p0.renderer.setFinalXScale(0.200 * self.level)
        p0.renderer.setInitialYScale(0.100 * self.level)
        p0.renderer.setFinalYScale(0.200 * self.level)
        p0.renderer.setNonanimatedTheta(0.0000)
        p0.renderer.setAlphaBlendMethod(BaseParticleRenderer.PPBLENDLINEAR)
        p0.renderer.setAlphaDisable(0)
        # Emitter parameters
        p0.emitter.setEmissionType(BaseParticleEmitter.ETRADIATE)
        p0.emitter.setAmplitude(1.0000)
        p0.emitter.setAmplitudeSpread(0.0000)
        p0.emitter.setOffsetForce(Vec3(0.0000, 0.0000, 0.0000))
        p0.emitter.setExplicitLaunchVector(Vec3(1.0000, 0.0000, 0.0000))
        p0.emitter.setRadiateOrigin(Point3(0.0000, 0.0000, 0.0000))
        # Sphere Volume parameters
        p0.emitter.setRadius(0.1000)
        self.particles.addParticles(p0)
        f0 = ForceGroup('gravity')
        # Force parameters
        self.particles.addForceGroup(f0)
开发者ID:michaeltchapman,项目名称:alem,代码行数:104,代码来源:enemy.py

示例2: _make_pfx

# 需要导入模块: from direct.particles.ParticleEffect import ParticleEffect [as 别名]
# 或者: from direct.particles.ParticleEffect.ParticleEffect import addForceGroup [as 别名]
    def _make_pfx (self, enode, rnode, pos, radius, scale1, scale2,
                   birthrate, lifespan, zspinini, zspinfin, zspinvel,
                   poolsize, littersize, amplitude, ampspread, risefact,
                   texpath, color, alphamode, softstop):

        pfx = ParticleEffect()
        pfx.setPos(pos)

        p0 = make_particles()
        p0.setPoolSize(poolsize)
        p0.setBirthRate(birthrate)
        p0.setLitterSize(littersize)
        p0.setLitterSpread(0)
        #p0.setSystemLifespan(1.0)
        #p0.setLocalVelocityFlag(1)
        #p0.setSystemGrowsOlderFlag(0)

        # p0.setFactory("PointParticleFactory")
        # p0.factory.setLifespanBase(lifespan)
        # p0.factory.setLifespanSpread(0.0)
        # #p0.factory.setMassBase(1.00)
        # #p0.factory.setMassSpread(0.00)
        # #p0.factory.setTerminalVelocityBase(400.0000)
        # #p0.factory.setTerminalVelocitySpread(0.0000)

        p0.setFactory("ZSpinParticleFactory")
        p0.factory.setLifespanBase(lifespan)
        p0.factory.setLifespanSpread(0.0)
        #p0.factory.setMassBase(1.00)
        #p0.factory.setMassSpread(0.00)
        #p0.factory.setTerminalVelocityBase(400.0000)
        #p0.factory.setTerminalVelocitySpread(0.0000)
        p0.factory.setAngularVelocity(zspinvel)
        p0.factory.setFinalAngle(zspinfin)
        p0.factory.setInitialAngle(zspinini)

        p0.setRenderer("SpriteParticleRenderer")
        p0.renderer.setAlphaMode(alphamode)
        texpaths = texpath
        if not isinstance(texpath, (tuple, list)):
            texpaths = [texpaths]
        for texpath in texpaths:
            texture = base.load_texture("data", texpath)
            p0.renderer.addTexture(texture)
        # p0.renderer.setUserAlpha(alpha)
        p0.renderer.setColor(color)
        p0.renderer.setXScaleFlag(1)
        p0.renderer.setYScaleFlag(1)
        p0.renderer.setAnimAngleFlag(1)
        p0.renderer.setInitialXScale(scale1)
        p0.renderer.setFinalXScale(scale2)
        p0.renderer.setInitialYScale(scale1)
        p0.renderer.setFinalYScale(scale2)

        p0.setEmitter("SphereVolumeEmitter")
        p0.emitter.setRadius(radius)
        p0.emitter.setEmissionType(BaseParticleEmitter.ETRADIATE)
        p0.emitter.setAmplitude(amplitude)
        p0.emitter.setAmplitudeSpread(ampspread)
        #p0.emitter.setOffsetForce(Vec3(0.0000, 0.0000, 0.0000))
        #p0.emitter.setExplicitLaunchVector(Vec3(1.0000, 0.0000, 0.0000))
        #p0.emitter.setRadiateOrigin(Point3(0.0000, 0.0000, 0.0000))

        f0 = ForceGroup("vertex")
        force0 = LinearVectorForce(risefact * amplitude)
        force0.setActive(1)
        f0.addForce(force0)

        p0.setRenderParent(rnode)

        pfx.addForceGroup(f0)
        pfx.addParticles(p0)

        pfx.start(enode)
        if softstop:
            pfx.softStop()

        return pfx
开发者ID:stelic,项目名称:limitload,代码行数:80,代码来源:debris.py

示例3: Lvl03

# 需要导入模块: from direct.particles.ParticleEffect import ParticleEffect [as 别名]
# 或者: from direct.particles.ParticleEffect.ParticleEffect import addForceGroup [as 别名]

#.........这里部分代码省略.........
        p0.setFactory("PointParticleFactory")
        p0.setRenderer("LineParticleRenderer")
        p0.setEmitter("SphereVolumeEmitter")
        p0.setPoolSize(10000)
        p0.setBirthRate(0.0500)
        p0.setLitterSize(10000)
        p0.setLitterSpread(0)
        p0.setSystemLifespan(2.0000)
        p0.setLocalVelocityFlag(1)
        p0.setSystemGrowsOlderFlag(1)
        # Factory parameters
        p0.factory.setLifespanBase(2.0000)
        p0.factory.setLifespanSpread(0.0000)
        p0.factory.setMassBase(.5000)
        p0.factory.setMassSpread(0.0500)
        p0.factory.setTerminalVelocityBase(400.0000)
        p0.factory.setTerminalVelocitySpread(0.0000)
        # Point factory parameters
        # Renderer parameters
        p0.renderer.setAlphaMode(BaseParticleRenderer.PRALPHAOUT)
        p0.renderer.setUserAlpha(1.00)
        # Line parameters
        p0.renderer.setHeadColor(Vec4(1.00, 0.00, 0.00, 1.00))
        p0.renderer.setTailColor(Vec4(1.00, 1.00, 0.00, 1.00))
        p0.renderer.setLineScaleFactor(3.00)
        # Emitter parameters
        p0.emitter.setEmissionType(BaseParticleEmitter.ETRADIATE)
        p0.emitter.setAmplitude(10.0000)
        p0.emitter.setAmplitudeSpread(0.0000)
        p0.emitter.setOffsetForce(Vec3(0.0000, 0.0000, -0.4930))
        p0.emitter.setExplicitLaunchVector(Vec3(1.0000, 0.0000, 0.0000))
        p0.emitter.setRadiateOrigin(Point3(0.0000, 0.0000, 0.0000))
        # Sphere Volume parameters
        p0.emitter.setRadius(0.5000)
        self.explosion.addParticles(p0)
        f0 = ForceGroup('gravity')
        # Force parameters
        self.explosion.addForceGroup(f0)
        
	cHandler = CollisionHandlerEvent()
	cHandler.addInPattern('%fn-into-%in')
	cSphereB = CollisionSphere(cEntry.getIntoNodePath().getParent().getPos(),1)
	cNodeB = CollisionNode("explosion")
	cNodeB.addSolid(cSphereB)
	cNodePathB = self.explosion.attachNewNode(cNodeB)
	self.cTrav.addCollider(cNodePathB,cHandler)
	cNodePathB.show()
        
	self.accept("player1-into-explosion",self.player2Wins)
	self.accept("player2-into-explosion",self.player1Wins)
        #f.reparentTo(self.playerModel)
        #self.explosion.setPos(self.playerModel.getPos())

        t = Sequence(Func(self.explosion.start, render, render),Wait(2),Func(self.cleanExplo))
        t.start()
	cEntry.getFromNodePath().getParent().removeNode()
        
    def cleanExplo(self):
        self.explosion.cleanup()

    def endGame(self,task):
        taskMgr.removeTasksMatching('returnSpeedsToNormal')
        taskMgr.removeTasksMatching('restoreCamera')
	taskMgr.removeTasksMatching('clockTask')
	taskMgr.removeTasksMatching('ballMoveTask')
	
	self.music.stop()

        self.music3  = loader.loadMusic("models/gamedev/CSTAR.mp3")
        self.music3.play()
        
        self.speed1 = 0
        self.speed2 = 0

    def getScores(self):
	return (self.player1Score, self.player2Score)
		
    def getGameLen(self):
	return self.gameLen
		
    def stopMusic(self):
	self.music3.stop()
	
    def destroy(self):
	self.playerModel.detachNode()
	self.playerModel2.detachNode()
	self.background.destroy()
	self.lava.detachNode()
	self.ladder.detachNode()
	self.ladder2.detachNode()
	
	for i in range(self.ballNum+1):
	    self.ball[i].detachNode()
	    
    def stopMusic(self):
        self.music3.stop()
        
#world = Lvl03()
#world.start()
#run()
开发者ID:CarlosPlusPlus,项目名称:rpi-undergrad,代码行数:104,代码来源:LVL03.py


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