Game Development Community

Set size and collision for a particle effect...

by Isaac Barbosa · in Torque Game Builder · 12/29/2006 (5:07 pm) · 6 replies

I'm using this code to attach a particle effect in the stage and it works, except for the size... is there a way to set the size of a particle just like with an static particle? I read the docs but can't find an answer.

function Bomb::bombexplode(%this)
{
   %bombexplosion = new t2dParticleEffect()
   {
      scenegraph = %this.scenegraph;
   };

   %bombexplosion.loadEffect("~/data/particles/firexplosion.eff");
   %bombexplosion.setEffectLifeMode("KILL", 1);
   //%bombexplosion.setEffectSize(%this, "1 1");
   %bombexplosion.setEffectCollisionStatus(true);
   %bombexplosion.setPosition(%this.getPosition());
   %bombexplosion.setEmitterType(%this, "Area");
   %bombexplosion.setSize(2, 2);
   %bombexplosion.playEffect();
}

And, how can I make my effect to check for collisions?
I have this from the docs... but is not clear for me.

function Bomb::onParticleCollision( %this )
{

}

Thanks in advance

#1
12/30/2006 (8:17 am)
I'd recommend playing around with the size of the particle using the particle editor graphs, since size in TGB is all relative, you should first scale the actual size of the particle to dimensions relative to the rest of the artwork in your game before trying to size the particle in the game itself.
#2
12/30/2006 (8:22 am)
@Drew:

Thanks Drew. I believe I did not explain well my self. I know how to change the size using the particle editor. I want to change the area/size of the whole effect in the game but setSize or size doesn't seems to work.
#3
12/30/2006 (5:49 pm)
How can I set an staticSprite to detect collision against an AnimatedSprite??? Can't find a solution and I have read the whole docs :(

Thanks for the help...
#4
12/31/2006 (9:05 am)
Still can't do it :(

Since the onParticleCollision(%this) method has no the %srcObj and the %dstObj methods... how can I be able to make a contact between a playing effect (maybe fire) and my character to make it get burn?
#5
12/31/2006 (9:30 am)
Still can't do it :(

Since the onParticleCollision(%this) method has no the %srcObj and the %dstObj methods... how can I be able to make a contact between a playing effect (maybe fire) and my character to make it get burn?
#6
12/31/2006 (12:51 pm)
Quote:
How can I set an staticSprite to detect collision against an AnimatedSprite??? Can't find a solution and I have read the whole docs :(
They are both t2dSceneObjects - in terms of collisions you don't need to consider them to be different types of objects, since they both share the same properties when it comes to collisions. Just look up the collision routines in the t2dSceneObject reference or use the collisions feature tutorial.
Quote:
Since the onParticleCollision(%this) method has no the %srcObj and the %dstObj methods... how can I be able to make a contact between a playing effect (maybe fire) and my character to make it get burn?
I have to admit, looking at the onParticleCollision callback, it's not very useful to anything but the particle effect. So in your case if you had a particle effect and you wanted to know if your player hit it, then you should create a bounding box around the particle effect that is the same size as the extent of the effect, probably a bit smaller so that when the player comes within range of the effect, a normal onCollision callback is thrown.