Ok, so I have a stageMovement Array that grabs hold of everything except the UI in my game, so I can use a for statement as a virtual camera. Anyways: everything works just fine until I spam spells.
The spells are contained in another array than the hero, but for some reason when I splice out like 15 spells at the same time, I invariably splice the hero out.
I realize that my code is probably an abomination, but that's how you get better right?
This is my vcam forloop
function dostagemovement()
{
if (Hero[0].x > 700)
{
for (i=stageMove.length-1; i>=0; i--)
{
//make a ref to current object
ob = stageMove[i];
st = new stageMovement(ob,.5,-(Hero[0].x/125),0);
}
}
if (Hero[0].x < 200)
{
for (i=stageMove.length-1; i>=0; i--)
{
//make a ref to current object
ob = stageMove[i];
st = new stageMovement(ob,.5,((900-Hero[0].x)/125),0);
}
}
}
This is (I suspect) the offending for loop
for (i=Magic.length-1; i>=0; i--)
{
if (Magic[i].HP < 0)
{
Magic.splice(i,01);
stageMove.splice(Magic[i],1);
}
}