(later) Schoolboy error. I was using insertElementAt() instead of setElementAt().
Thus - the Vector of Sprites appears in slist:
// This is a sinking sort. On first pass, the highest
// priority sprite arrives at the bottom. On second,
// the next highest arrives at second bottom, etc.
// Sprites of the same priority remain in their
// original sequence with respect to each other.
for (ii = 0; ii< slist.size()-1; ii++)
{
for (jj = 0; jj < (slist.size()-ii-1); jj++)
{
spare1 = (Sprite)slist.elementAt(jj);
spare2 = (Sprite)slist.elementAt(jj+1);
if (spare1.getPriority() > spare2.getPriority())
{
slist.setElementAt(spare1, jj+1);
slist.setElementAt(spare2, jj);
}
}
}
No comments:
Post a Comment