Particle Effect - Causing Flashes

A

Andy Chu

Guest
Greetings Game Makers!

I have created a particle effect but it seems that it is causing brief flashes on my objects.
What can I do to fix it up?

Code:
Sname=part_system_create();

particle1 = part_type_create();
part_type_shape(particle1,pt_shape_line);
part_type_size(particle1,0.10,0.10,0,0);
part_type_colour1(particle1,236);
part_type_speed(particle1,1,1,0,0);
part_type_direction(particle1,90,90,0,0);
part_type_orientation(particle1,0,0,0,0,1);
part_type_blend(particle1,1);
part_type_life(particle1,0,20);

emitter1 = part_emitter_create(Sname);
part_emitter_region(Sname,emitter1,x+16,x-16,y+16,y-16,ps_shape_ellipse,ps_distr_linear);
part_emitter_stream(Sname,emitter1,particle1,1);


Please and thank you!
 

BLang

Member
Oh, yeah, I guess that's a bit of a weird question on it's own. Let me explain...

I had a similar problem with one of my games - whenever I created particles, my whole screen would flash black for seemingly no reason. I thought it might have been too many particles causing my graphics card to act up or something like that. And I spent ages trying to figure it out.

Then, after nearly ripping out all of my hair trying to solve this problem, I went into the room editor and noticed that I have a 5x5 pixel view just a bit off screen, and it was being drawn over everything else. So what was actually happening was that the particles would fall down and pass over the 5x5 view off screen, causing the weird flashing.

This probably isn't the same problem as what you're having, but food for thought! Maybe there's something similar going on with surfaces or sprites grabbed from the screen or something.
 

RangerX

Member
Might be alpha related. Like the particles and that object are drawn according the "main alpha" of the engine and not your own variable.
 
A

Andy Chu

Guest
Oh, yeah, I guess that's a bit of a weird question on it's own. Let me explain...

I had a similar problem with one of my games - whenever I created particles, my whole screen would flash black for seemingly no reason. I thought it might have been too many particles causing my graphics card to act up or something like that. And I spent ages trying to figure it out.

Then, after nearly ripping out all of my hair trying to solve this problem, I went into the room editor and noticed that I have a 5x5 pixel view just a bit off screen, and it was being drawn over everything else. So what was actually happening was that the particles would fall down and pass over the 5x5 view off screen, causing the weird flashing.

This probably isn't the same problem as what you're having, but food for thought! Maybe there's something similar going on with surfaces or sprites grabbed from the screen or something.
Yeah I don't think its similar but indeed a food for thought.

Might be alpha related. Like the particles and that object are drawn according the "main alpha" of the engine and not your own variable.
Unsure..

But I did a bit of digging around the blog mentioned that every time a new texture is drawn it will cause the flashing. - http://www.yoyogames.com/blog/23
I'm not sure if this is correct either...
This function clears all data from the texture memory. Note that this may cause a brief flash or flicker as the new textures are loaded for the first time when the draw event is run, and so, to avoid this, you should also "initialize" the textures in the same event, by simply calling a draw function (one for each of the needed pages). This will not be seen since it is in the Create Event, but will prevent any glitches or flickers when the game graphics are actually drawn. Your final Create Event would look something like this:
 

RangerX

Member
Are you using "draw_texture_flush()" ?
I think you found the problem. Can you try the solution in the blog?

An alternative could be to actually have your particles your own sprites and create them with an object. Basically making your own particle system.
A great advantage of that (while less flexible visually maybe) is that you will save alot of texture pages since your sprite used for particle will simply end up on the same texture pages than the rest of your graphics.
Less page swaps = game runs better.
 
A

Andy Chu

Guest
Are you using "draw_texture_flush()" ?
I think you found the problem. Can you try the solution in the blog?

An alternative could be to actually have your particles your own sprites and create them with an object. Basically making your own particle system.
A great advantage of that (while less flexible visually maybe) is that you will save alot of texture pages since your sprite used for particle will simply end up on the same texture pages than the rest of your graphics.
Less page swaps = game runs better.
I'm not quite sure how or where to implement that function since I am a month old with Game Maker Studio.
Having my own particle sprites.. I really need an artist for that as I am not confident artistically.
 
A

Argonaut14

Guest
Some thoughts from me, it's 5am so be nice :p

You aren't setting the alpha within the particle system, so the particle system alpha shouldn't affect the blue box object - although changing the alpha elsewhere might cause problems.

Have you tried putting the Particle effect into a blank room with background and ensuring the particle system works alone? And I assume the blue box has no problems when on it's own.

Are you spawning the particle system over and over again having the creation of the PS inside the STEP event?

Do any other objects flash or is it just this one?
 
A

Andy Chu

Guest
Some thoughts from me, it's 5am so be nice :p

You aren't setting the alpha within the particle system, so the particle system alpha shouldn't affect the blue box object - although changing the alpha elsewhere might cause problems.

Have you tried putting the Particle effect into a blank room with background and ensuring the particle system works alone? And I assume the blue box has no problems when on it's own.

Are you spawning the particle system over and over again having the creation of the PS inside the STEP event?

Do any other objects flash or is it just this one?
Hmm I have already tried it in a blank room and the Particles work vice versa.
My code is in my first comment under the tag spoilers is a create event and I don't have a step event for this.
Apparently all objects with light color flashes and darker ones do not.

Here is another video:
 
C

CoderJoe

Guest
just a random idea, try changing the depth of the object creating the particles. (I believe negative numbers for depth will make it draw over everything else)
 
A

Argonaut14

Guest
The effect is only one one object or only dark coloured ones? We're definitely narrowing down the problem.
 
A

Andy Chu

Guest
The effect is only one one object or only dark coloured ones? We're definitely narrowing down the problem.
Effect is the red particles that is being emitted.
just a random idea, try changing the depth of the object creating the particles. (I believe negative numbers for depth will make it draw over everything else)
I might've tried it and showed no result but I'll try it agains just to see.
 

andulvar

Member
the problem is with:
  • part_type_blend(particle1,1);

When you stream a particle with additive blending it can cause problems. You could just remove it, but if you want to preserve the additive effect, the best way around it is to change it from a stream to a burst. I used 10 burst particles in the example but using 2 would match your particle code above better.

Create Event:
  • part_emitter_burst(Sname,emitter1,particle1,10);
  • alarm[0]=2
Alarm[0]
  • part_emitter_burst(Sname,emitter1,particle1,10);
  • alarm[0]=2
 
A

Andy Chu

Guest
the problem is with:
  • part_type_blend(particle1,1);

When you stream a particle with additive blending it can cause problems. You could just remove it, but if you want to preserve the additive effect, the best way around it is to change it from a stream to a burst. I used 10 burst particles in the example but using 2 would match your particle code above better.

Create Event:
  • part_emitter_burst(Sname,emitter1,particle1,10);
  • alarm[0]=2
Alarm[0]
  • part_emitter_burst(Sname,emitter1,particle1,10);
  • alarm[0]=2
You're a genius ahah.
 
Top