Game Development Community

SetSize()

by Kevin James · in Torque Game Builder · 04/07/2005 (5:23 pm) · 13 replies

I tried this on my particle affect and it doesn't change the visible size. I saw in the other thread something about "emission area" so does that mean setSize() changes something invisible? I'm asking because my game has players along a isometric ranged field. An explosion that happens down field should be smaller than an explosion up field (closer to the screen).

Thanks

About the author

Computer security, digital forensics, and platform jumper enthusiast. shells.myw3b.net/~syreal/


#1
04/09/2005 (12:23 pm)
I've just started on the particle effects, but setSize() apparently only applies to area particle emitters (vs Point, which is the type I've done, linex or liney). I haven't been able to find anything yet on how the area particle emitters differ (I can guess, but the parameters all look the same...)
#2
04/09/2005 (2:45 pm)
So, if your project is an isometric game and you have activity along the full depth range, all of the particle effects will be the same size, or you have to create different size effects to have the illusion work.
#3
04/13/2005 (12:54 pm)
Well... instead of waiting for the answer, I'll just use an animated sprite to show this explosion "in scale".
#4
04/13/2005 (4:42 pm)
This thread might help. There are others on the same subject kicking around here and there, but I'm pretty sure this one goes most in-depth.

I'd suggest scaling the effect up and down in the particle editor, figuring out which attributes need to be edited each time to get a decent looking change in the overall effect's scale, and then using the graph editing functions in fxParticleEffect2D and fxParticleEmitter2D to change the overall scale programatically.
#5
04/15/2005 (12:11 am)
I use the following code to set the size of my explosions:

I set my sprite up as follows:
function createLargeMeteor()
{
	%largemeteor = new fxStaticSprite2D() { scenegraph = t2dSceneGraph; };
	%largemeteor.setImageMap( meteorsImageMap );

//	blah blah rest of stuff

	%largemeteor.explosionSize = 2;
}

And then when I detect collisions and want to blow stuff up, I call the following code. Note it takes the %dstObj from the collision call.

function explodeTarget(%dstObj)
{
	%explosion = new fxParticleEffect2D() { scenegraph = t2dSceneGraph; };
	%explosion.loadEffect("~/client/effects/big_explosion.eff");

	%explosion.selectGraph("sizex_scale");
	%explosion.setDataKeyValue(0, (%dstObj.explosionSize*0.2));

	%explosion.selectGraph("sizey_scale");
	%explosion.setDataKeyValue(0, (%dstObj.explosionSize*0.2));

	%explosion.setPosition(%dstObj.getPosition());
	%explosion.setEffectLifeMode(kill, 1);

	%explosion.playEffect();

	%dstObj.schedule (250, safeDelete);
}

With a bit of tweaking of the numbers involved I don't see why you couldn't do something similar.
#6
04/15/2005 (4:40 am)
Thanks Philip! I'll give this a try.

My animated explosion looks pathetic next to what T2D is really capable of.
#7
04/15/2005 (5:03 am)
As a sidenote, I also do this...

In the sprite setup:
%largemeteor.explosionColourRed = 0.784;
%largemeteor.explosionColourGreen = 0.482;
%largemeteor.explosionColourBlue = 0.235;

And in the explosion function I use:
%emitter = %explosion.findEmitterObject("INTENSE_CENTER");
%emitter.selectGraph("red_life");
%emitter.setDataKeyValue(0, %dstObj.explosionColourRed);

%emitter.selectGraph("green_life");
%emitter.setDataKeyValue(0, %dstObj.explosionColourGreen);

%emitter.selectGraph("blue_life");
%emitter.setDataKeyValue(0, %dstObj.explosionColourBlue);

This allows me to tint explosions based on what it is I'm blowing up. A rock might be a more browny shade, an iceberg can be a bluey-white and a gas tank a yellowy-red.
#8
04/15/2005 (5:14 am)
Awesome!
#9
04/15/2005 (8:17 am)
Philip, your code works like a charm in my project.

Thanks again!
#10
04/15/2005 (8:55 am)
Great stuff, glad you found it useful.

I'll just sit back and wait for the royalty cheques to start coming in... ;)
#11
04/15/2005 (9:07 am)
I remember seeing Melv talk about this in another thread, but it really didn't make sense until I saw your working example.
#12
04/15/2005 (9:18 am)
Ofcourse, and that's what set me on the track to using it.

Seeing an actual working example of code is often worth its weight in gold (particularly when you're a novice programmer like me!).
#13
04/16/2005 (6:48 am)
@Philip: Cool. You're the first person to really understand how simple it is to dynamically change all the properties of effects/emitters. Other particle systems force you to define the effect as it would appear in the game. T2D allows you to change ALL the properties in realtime. This is so extremely funky, even to me!

- Melv.