I am spinning my wheels on this.
I have a grid of cells to load each displaying a seperate sprite on a sheet.
However, I want to load them in gradually. My cells are loaded as individual objects in a LIST.
So on the first update the first cell will start at 20% opacity.
On the second update the first cell will be at 40% and the second cell will be at 20%.
On the third update the first cell be at 60%, second cell at 40% and third cell at 20%.
This pattern would continue until every cell is at 100%
I have figured out the sprite sheet part, the opacity, drawing the texture, etc, etc. Its just the loop I can’t figure out.
Either I end up with everything loading at once. Only one cell loading. A mixture of cells. A mixture of opacity values across the cells. I even got them all phasing in correctly as one big group but I haven’t been able to figure out how to get them to gradually load in.
Below is the code I wrote that doesn’t really do work. The idea would be to go through the list and keep a “buffer” value of the previous cell. Then based on that value determine the value of the current cell. One problem I already see is that I am going to have issues with setting the first or last cell properly because the buffer will either not be present or the last cell will never reach the appropriate value.
Blockquote
int jpsMenuObjectPhaseBuffer = 0;
if (timeSinceLastMenuLoad > .075f)
{
foreach (JPSMenuGraphic x in demo.jpsMenuObjects)
{
if (jpsMenuObjectPhaseBuffer == 1)
{
x.phase = 1;
x.opacity = .20f;
}
else if (jpsMenuObjectPhaseBuffer == 2)
{
x.phase = 2;
x.opacity = .40f;
}
else if (jpsMenuObjectPhaseBuffer == 3)
{
x.phase = 2;
x.opacity = .80f;
}
else if (jpsMenuObjectPhaseBuffer == 3)
{
x.phase = 3;
x.opacity = 1.0f;
}
else
{
x.phase = 1;
x.opacity = .20f;
}
jpsMenuObjectPhaseBuffer = x.phase;
}
timeSinceLastMenuLoad = 0f;
}