Table of Contents
This plugin causes particles to spawn as part of a card's removal animation. If the animation is set to Burn, particles will be spawned randomly at the part of the card that is being burned. If set to Fade, particles will be spawned randomly anywhere inside the bounds of the card.
Parameters
The parameter Particles is a list of particles you can define, including their behaviors.
ParticleFX uses formulas to determine values that affect a particle's behavior. They can be as simple as pure numbers or as complex as you want them to be. These formulas can have multiple lines to them, but the final line must be an expression that contains a value.(Note for programmers: Please do not use the 'return' keyword here)
Here's an example of a formula that could be used for the Vertical Speed Formula:
var diceSize = 6; var diceAmount = 3; var total = 0; for (var i = 0; i < diceAmount; i++) { total += (Math.floor(Math.random() * diceSize) + 1); } total
Notice a few things in this example:
1) All lines have semi-colons at the end of them, except for the last line which doesn't need one. The for loop and brackets also do not have semi-colons as in programming they are not supposed to.
2) The final line contained only the value we wanted to set the Vertical Speed of the particle to.
This formula would roll 3 dice, add up their values, and set the particle's vertical speed to that.
Here's another example of a formula that could work:
4
This would set the vertical speed to 4. And that's all it needs to do!
Note that numbers, variables, and mathematical operations can all be used in the final line (ex, “6 + 4” is acceptable, but “total = 6 + 4” is NOT)
There are two categories of formulas particles use:
1) One-time evaluation - these are evaluated right when the particle is spawned
2) Continuous evaluation - these are evaluated every frame.
All formulas are One-time evaluated except for:
Fade Start Condition Scale Over Time Formula
The Fade Start Condition evaluates until it evaluates to true.
The Scale Over Time Formula sets the particle's scale every frame, so that you can change it over time in either direction (ie, grow and shrink) rather than only have it go in one direction like the rest of the formulas.
To give an example of what I mean, the Horizontal Speed Formula is evaluated one time, when the particle spawns. Once that is done, its horizontal speed cannot be changed.
Notetags
Notetag Syntax | Plugin Required | Database Usage | Description |
---|---|---|---|
<Card Particle: X> | Card Particle FX | Skills | Spawns Particles of X ID when the Card is removed. |
Formulas
A few variables have been defined to help you:
time | This number increments every frame the particle has existed. |
gravity | This is the value of gravity that has been given to the particle. |
vertSpeed horzSpeed | These are the values of the particle's verticle and horizontal speed, respectively |
x y | These are the particle's coordinates on the screen. |
rotation | The particle's current rotation in degrees. |
scale | The particle's scale *before* evaluating its new scale through the Scale Over Time Formula. |
isFading | A boolean that represents whether the Fade Start Condition has triggered |
particlesSpawned | The number of particles that this card has spawned up until now. Most of these variables will mostly only be useful for the continuous formulas, but particlesSpawned may be useful for the one-time evaluated formulas. |
Some helpful tools:
Math.random() - returns a random number between 0.000... and 0.9999... Math.random() * x - returns a random number between 0.000... and (x-1).9999... Math.floor(Math.random() * x) - returns a random whole number between 0 and x-1.
So if you want to simulate rolling 2 dice:
(Math.floor(Math.random() * 6) + 1) + (Math.floor(Math.random() * 6) + 1)
Template
For Horizontal Speed Formula:
Math.sin(particlesSpawned / 15) * 6
This will set the particle's horizontal speed somewhere between -6 and 6, and every time another particle is spawned in the removal animation, the speed will shift left or right. 15 is the frequency (the larger the number, the longer it takes to go from -6 to 6) and 6 is the amplitude (at 10, for example, it would be between -10 and 10).
For Vertical Speed Formula:
Math.random() * 6 + Math.random() * 6 - 15
This will set the particle's vertical speed somewhere betwwen -3 and -15, but since 2 randoms are called the number will be more likely to be in between the two edge cases. A negative number is important if we want the particle to go up, as lower numbers are higher up in screen coordinates.
For Fade Start Condition:
(vertSpeed >= 0)
vertSpeed represents the particle's vertical speed. This value changes, unlike horzSpeed, because of gravity. If gravity is set to a value of greater than 0, vertSpeed will slowly rise from a negative number to a positive number. Here, the Fade Start Condition will return true once the particle reaches the peak of its arc and begins to fall down.
For Scale Over Time Formula:
var scale = 1; if (time < 30) scale = (time / 30) + 0.5; else scale = ((30 - time) / 30) + 1.5; if (scale < 0) scale = 0; scale
This one is a bit more complicated. It uses the time variable which goes up every frame, and you can see here if the particle has been alive for less than 30 frames, it grows in size starting from a scale of 0.5 to a scale of 1.5 over the course of 30 frames. Once it has been alive for 30 frames, it begins to shrink, going from 1.5 to 0.5 in 30 frames. If the particle is still alive after 60 total frames, time will continue to increase, and after 75 total frames the scale will be 0.
For Rotation Speed Formula:
var direction = Math.random() >= 0.5 ? 1 : -1; direction * 5
this one can also be written as:
var direction = 5; if (Math.random() < 0.5) direction = -5; direction
This flips a coin, and sets the speed of the particle's rotation either to 5 degrees per frame, or -5 degrees per frame.