Okay. About time I shared my newfound and dearly loved knowledge on emitters. (This is an extremely long post, but read it if you want to learn Particle Emitters through and through, and yes I will start from the beginning).
First off, new function, we will need this for the Emitters:
This function can be used for the following script:
PHP Code:
//#CLIENTSIDE
function onCreated() {
showimg(1,"block.png",player.x,player.y);
findimg(1).x = player.x - 5;
with (findimg(1)) {
mode = 1;
red = 1;
blue = 0;
green = .5;
}
}
In short, findimg(index) works exactly like findplayer(index), and can be used in much the same way, but relative to images, and not a player.
Important notes before we start:- Indefined images have an image of "" (A blank string)
- Undefined images have an x and y equal to the player's x and y
Now, onto Particle Emitters!!
A particle emitter is an object. Just like 'player.' or 'this.', it is an object. It's parent is the TShowImg, which is the showimg object. First off, you do not need to define an image to cast an emitter on it. in fact, I did not and I made some pretty nice and simple emitters. (Attached is a preview of what I have made, and that's on Babylon). Now, the 'emitter.' object is how we access and create an emitter. First off, the basics:
PHP Code:
//#CLIENTSIDE
function onCreated() {
with (findimg(1)) {
layer = 2; // This will make the emitter draw under the player
x = player.x;
y = player.y; // These will show the emitter at the player's coords.
Follow along with what I'm doing? Now, here are the variables we will need to define, after setting the layer, x, and y, still inside the findimg() bracket:
PHP Code:
emitter.delaymin = float; // This is the minimum delay between emissions
emitter.delaymax = float; // This is the maximum delay between emissions, both of these are in seconds
emitter.emissionoffset = string; // In format of "{float, float, float}", it's the offset from the x, y, and z that an emission will show. It's the delta variables for the location, basically.
emitter.nrofparticles = integer; // The number of particles to be released at the same exact time when the emitter emits. For example, set this to two, and you'll have two particles released every time instead of the default 1
There. Define those as you wish. I have the mindelay as .01 and the max as .05. The offset I have as {.5,0,0}, which places the left edge of the emitters .5 tiles to the right. Now, time to teach how to change the particle attributes, and not just the base laws that govern them.
PHP Code:
emitter.particle.lifetime = float; // How long, in seconds, the emitter lasts.
emitter.particle.image = string; // The imagename of the emitter
emitter.particle.mode = integer; // Either 0, 1, or 2, the same as changeimgmode
emitter.particle.alpha = float; // Between 0 and 1, the alpha colour for transparancy
emitter.particle.zoom = float; // The zoom effect of the particle
emitter.particle.red = float;
emitter.particle.green = float;
emitter.particle.blue = float; // These three are between 0 and 1, and they're the colours of the individual particles
emitter.particle.zangle = float; // Between 0 and pi*2, it's the upward angle of the particles. Remember zangle from the shoot() function? Same basic idea.
emitter.particle.angle = float; // Again, between 0 and pi*2, it's the angle that the particle should flow.
emitter.particle.speed = float; // I'm not sure if this is measured in Tiles per second or what, but it's the speed. Higher = faster, obviously
emitter.particle.stretchy = float; // Remember elipses from your Advanced Algebra class? The eccentricity? Remember that? This is it! Yay. Values less than 1 stretch it horizontally, while values more than 1 stretch the image vertically. Fun, fun.
Now time to close the code!
There.
Well, I hope that taught you a thing or two about emitters! <3, and attached is the picture of what I've done with my emitter images. Note: You'll have to change the image's x and y to the player's x and y inside a timeout loop if you want the emitter to follow the player, as I have it.
Have fun!
EDIT: I left out the things I, myself, don't fully understand. Sorry. z-z