T2008
Member
I added a particle system to create rain in one room. I"m trying to get it to stop in the next room, but the rain keeps coming even though I destroy it in the room end event. My game is large and I intend to use the rain in many rooms, so I need to be able to turn on and off the rain based on room the player is in. In the Room End Event, I clear the particles; which only deletes them momentarily in the next room and then it resumes. When I tried destroying the particles, the particles stopped but would not start again when I returned the the room that is supposed to have rain. Any ideas on this would be greatly appreciated!!!!
Object Rain Create Event:
Room End Event:
Edit: So I changed the Room End Event to include the below code instead; and then had the player object create the rain object in the correct rooms if it didn't alreayd exists. This seems to work. Anyone see any issues with memory leaks, etc with this?
Object Rain Create Event:
Code:
//Rain System
partRain_sys = part_system_create();
//Rain Particle
partRain = part_type_create();
part_type_shape(partRain,pt_shape_line);
part_type_size(partRain,0.2,0.3,0,0);
//part_type_size(partRain,0.1,0.2,0,0); //my adjustment
part_type_color2(partRain,c_teal, c_white);
part_type_alpha2(partRain,.5,.1);
part_type_gravity(partRain,0.1,290);
part_type_speed(partRain,0.5,0.5,0,0);
part_type_direction(partRain,250,330,0,1); //adds wiggle
part_type_orientation(partRain,290,290,0,0,0); //no wiggle
part_type_life(partRain,20,180); //how long it lasts; 140,180 for platformer
//Puddle Particle
partPuddle = part_type_create();
part_type_shape(partPuddle,pt_shape_circle);
part_type_size(partPuddle,0.5,0.8,.01,0);
part_type_scale(partPuddle,.5,.1); //creates oval that gets bigger and squishes out
part_type_color1(partPuddle,c_silver);
part_type_alpha2(partPuddle,.4,0);
part_type_speed(partPuddle,0,0,0,0);
part_type_direction(partPuddle,9,0,0,1);
part_type_gravity(partPuddle,0,270);
part_type_life(partPuddle,50,60); //how long it lasts
//Set Sequence
part_type_death(partRain,1,partPuddle); //can create more puddles by increasing number; or -5 means one in five chance of creating puddle
//Create Emitter
partRain_emit = part_emitter_create(partRain_sys);
part_emitter_region(partRain_sys,partRain_emit,0,1920,0,0,ps_shape_line,ps_distr_linear);
part_emitter_stream(partRain_sys,partRain_emit,partRain,5);
//Advance System - makes rain start in middle and not at top
repeat(room_speed* 3) { //3 seconds into system
part_system_update(partRain_sys);
}
Code:
part_particles_clear(partRain);
part_particles_clear(partPuddle);
Edit: So I changed the Room End Event to include the below code instead; and then had the player object create the rain object in the correct rooms if it didn't alreayd exists. This seems to work. Anyone see any issues with memory leaks, etc with this?
Code:
part_type_destroy(partRain);
part_type_destroy(partPuddle);
part_emitter_destroy(partRain_sys,partRain_emit);
part_system_destroy(partRain_sys);
instance_destroy();
Last edited: