samedi 25 juin 2016

As3 hitTestObject not working

My hittestobject isn't working and I don't know why. Could anyone please help me? I'm trying this all day already.

Why doesnt it work?

`

for(var id=0; id<5; id++) {

        var frizercek:obstacle = new obstacle();

        //setting the brick's coordinates via the i variable and brickRow
        frizercek.x = frizercek.x + id* 110;
            frizercek.gotoAndStop(3)
            frizercek.width = 92.9
            frizercek.height = 26.1

            line4.addChild(frizercek);

            trace("lol" + id)
            frizercek.addEventListener(Event.ENTER_FRAME, didithit ); 

        function didithit(e:Event){
            if(mcball.hitTestObject(frizercek)){
                    ballYSpeed  *=-1;
    line4.removeChild(frizercek)


            }
            if(mcball.hitTestObject(frizercek.sidewall)){
                    ballXSpeed *=-1;
    line4.removeChild(frizercek)


            }

        //finally, add the brick to stage

    }


    } `

Aucun commentaire:

Enregistrer un commentaire