*   >> Lectura Educación Artículos >> science >> programación

Hacer un juego en 3D con Ogre - Agregar Effects

s de ser retirado del nivel. La propiedad duración del emisor define cuánto tiempo un sistema de partículas debería emitir partículas de. Al agregar este valor al de la vida útil de las partículas individuales se puede calcular cuánto tiempo el efecto durará. Almacenamos este valor en la variable timeToLive

 timeToLive = particleSystem-> getEmitter 

(0) -> getDuration () + particleSystem-> getEmitter

(0) -> getTimeToLive ();.} Void ParticleSystemEffect :: apagado ( ) {sceneNode-> detachObject (particleSystem); GAMELEVEL.

GetSceneManager () -> destroyParticleSystem (particleSystem); GAMELEVEL.GetPlayerSceneNode () -> removeAndDestroyChild (sceneNode-> getName ()); InitialiseVariables (); PersistentFrameListener :: apagado ();} void ParticleSystemEffect :: InitialiseVariables () {timeToLive = 0; SceneNode = NULL; particleSystem = NULL;.}

La función frameStarted contará hacia atrás la variable timeToLive, y cuando llega a cero la función de apagado está llamada, eliminando el sistema de partículas desde el nivel

 bool ParticleSystemEffect :: frameStarted (const FrameEvent y evt) {timeToLive - = evt.

timeSinceLastFrame; si (timeToLive

Al igual que los enemigos, armas y otros objetos que responden a Ogre eventos marco, existen objetos ParticleSystemEffect en una piscina, con los que han terminado de estar en un estado de suspensión hasta que se vuelven a utilizar. La clase ParticleSystemEffectManager mantiene esta piscina de objetos ParticleSystemEffect. El código para crear objetos ParticleSystemEffect, almacenarlos en una piscina y volver objetos no utilizados es el mismo que el código correspondiente en las clases WeaponDatabase y EnemyDatabase.

De hecho la clase ParticleSystemEffectManager no hace más que mantener este grupo de objetos ParticleSystemEffect.

ParticleSystemEffectManager.h

 /* * ParticleSystemEffectManager.h * * Autor: Matthew Casperson * Email: [email protected] * Sitio web: https://www.brighthub.com/hubfolio/matthew -casperson.aspx * /# ifndef PARTICLESYSTEMEFFECTMANAGER_H_ # definir PARTICLESYSTEMEFFECTMANAGER_H_ # incluyen "ParticleSystemEffect.

h" #include "lista" typedef std :: Lista ParticleSystemEffectList; #define ParticleSystemEffectManager :: Instancia () Clase PARTICLESYSTEMEFFECTMANAGER ParticleSystemEffectManager {public: ~ ParticleSystemEffectManager (); estática y ParticleSystemEffectManager Instancia () {instancia ParticleSystemEffectManager estática; volver instancia; } Void

Page   <<  [1] [2] [3] >>
Copyright © 2008 - 2016 Lectura Educación Artículos,https://lectura.nmjjxx.com All rights reserved.