dimanche 31 mai 2015

how does the "for each in" loop work?

for some reason this code does not work as intended, ive cut out most of my program but, all i think i need to tell you is that i have a tree array. and im trying to make collisions with said trees so i thought that this would work

function collisions(loopEvent:Event):void{
    for each (var a:tree in TreeArray)
    {
        if (brettMc.right1.hitTestObject(a.stump))
    {
        rightcoll = false;
    }
    else
    {
        rightcoll = true;
    }
    if (brettMc.left1.hitTestObject(a.stump))
    {
        leftcoll = false;
    }
    else
    {
        leftcoll = true;
    }
    if (brettMc.up1.hitTestObject(a.stump))
    {
        upcoll = false;
    }
    else
    {
        upcoll = true;
    }
    if (brettMc.down1.hitTestObject(a.stump))
    {
        downcoll = false;
    }
    else
    {
        downcoll = true;
    }
}
}

im pretty sure that the problem is juat that the for each loop is messing up, but im dumb, so that could also be the problem.

Aucun commentaire:

Enregistrer un commentaire