How to set the blend color of a particle?
by Gellyware · in Torque Game Builder · 03/23/2008 (3:35 pm) · 6 replies
How do you set the blend color of a particle? setblendcolor doesn't seem to do anything.
%particle = new t2dParticleEffect()
{
scenegraph = sceneWindow2D.getSceneGraph();
effectFile = "~/data/particles/sparkleExplosion.eff";
useEffectCollisions = "0";
effectMode = "KILL";
effectTime = "0.5";
Position = %this.getPosition();
size = "128.000 128.000";
Layer = "8";
CollisionPhysicsSend = "0";
CollisionPhysicsReceive = "0";
};
%blendColor = %this.sprite.getBlendColor();
%particle.setBlendColor( %blendColor );
%particle.playEffect();About the author
#2
03/23/2008 (3:52 pm)
Will do, thanks Kevin.
#3
09/07/2009 (2:05 pm)
There is nothing worse than reading a forum post which tells you to read somethnig else without providing any code for future referance. I am posting an example as to help others and myself in the future have someplace to get an example%color = %obj.getBlendColor();
if (isObject(squareSelectGood))
{
%explosion = squareSelectGood.clone();
%emitter = %explosion.findEmitterObject( "NewEmitterName" );
%emitter.selectGraph( "red_life" );
%emitter.clearDataKeys();
// Add our keys.
%emitter.addDataKey( 1.0, getWord(%color, 0) );
%emitter.selectGraph( "green_life" );
%emitter.clearDataKeys();
// Add our keys.
%emitter.addDataKey( 1.0, getWord(%color, 1) );
%emitter.selectGraph( "blue_life" );
%emitter.clearDataKeys();
// Add our keys.
%emitter.addDataKey( 1.0, getWord(%color, 2) );
%explosion.position = %position;
%explosion.setEffectLifeMode("Kill", 1.0);
%explosion.playEffect();
%explosion.schedule(1100, safedelete);
}
#4
09/07/2009 (4:04 pm)
No need to schedule a safe delete, KILL will delete the effect when finished. Another way to delete an object after a specified time is using setLifetime rather than scheduling a safeDelete.
#5
06/19/2010 (12:38 pm)
@Anthony - Thanks. This post saved me a lot of time.
#6
03/23/2012 (9:11 am)
Great post!
Torque Owner Kevin James