Author Topic: Particle Animation and Z-Order  (Read 2134 times)

YellowBirdAZ

  • Full Member
  • ***
  • Posts: 80
    • View Profile
Particle Animation and Z-Order
« on: January 27, 2018, 03:08:28 PM »
So I made a custom screensaver, it displays game snap-vids scrolling horizontally over a parallax scrolling starfield in the background.

The only problem is the stars aren't in the background, they appear over the top of the snap-vids.

Does anyone know how to force particles into a lower z-order, or some other way to force them to the background? I may be missing something obvious.

I think each new particle is a new addition to the draw list, therefore they are almost always on top of anything else on the screen (since stars are being drawn far more frequently than anything else on screen).

I did see a property for "particlesontop" but it is not implemented. I tried setting it to false, and it doesn't even look like the property is part of the particle object yet.

EDIT
I just thought of the hackiest thing ever, which would be to screencap the star field and make it into a loopable video to just play in the background. Still, I would rather use the animation, so I would prefer to figure out how to fix this.

« Last Edit: January 27, 2018, 03:10:57 PM by YellowBirdAZ »

YellowBirdAZ

  • Full Member
  • ***
  • Posts: 80
    • View Profile
Re: Particle Animation and Z-Order
« Reply #1 on: January 27, 2018, 09:12:53 PM »
OK, this is clunky but it works.

I added this loop to the screensaver.

Code: [Select]
foreach ( o in fe.obj )
{
if ( o.texture_width < 100 && o.zorder != 1 )
{
o.zorder = 1;
}
}

This goes through and scans everything in the front end's draw list. Since my star PNGs are the only things smaller than 100px across, I look for anything smaller than that size and set it to an arbitrarily small zorder value (1). All the big objects I put on the screen are assigned larger zorder values.

This makes the snap-vids appear opaque as they move across the screen. The stars scrolling behind them disappear as they pass behind the snap-vids.