← View other scripts
script
Very Simple Particle Effects
Create a very simple particle effect that you can call from just one script!
Particle Systems can be complicated, but if you want a nice, simple effect that you can call and customise from just one script, here's the solution
1
Import the Sprite
2
Create the Object
CREATE
/// @description Set-Up
image_speed = 0
image_index = irandom(image_number)
direction = random(360)
alarm[0] = 30+random(20)
friction = 0.1
image_alpha = 0.8+random(0.2)
fade = false
STEP
/// @description Fade
if fade = true then image_alpha -= 0.05
if image_alpha < 0 then instance_destroy()
ALARM 0
/// @description Time-Out
fade = true
3
Create the Script
/// @function particles(x,y,amount,speed,colour,scatter)
/// @param {real} x
/// @param {real} y
/// @param {real} amount
/// @param {real} speed
/// @param {real} colour
/// @param {real} scatter
function particles(_xx,_yy,_amount,_speed,_colour,_scatter){
repeat(_amount) {
with(instance_create_depth(_xx-(_scatter/2)+random(_scatter*2),_yy-(_scatter/2)+random(_scatter*2),depth-1,oParticles)) {
image_blend = _colour
speed = _speed-0.5+random(1)
}}}
4
Using the Script
And that's it! Now, whenever you want a nice, simple particle effect, just call:
particles(<X>,<Y>,<AMOUNT>,<SPEED>,<COLOUR>,<SCATTER_AMOUNT>)
and it'll look like this:
Easy! Enjoy!