mercredi 15 mars 2017

Hit test object action script

I am trying to make a gear fall off a line using the hit test object. I have a background layer, a layer for the gear and one for the line. The gear rotates on the line and it also moves until to the point where it's going to fall. The code that I have right now is only added in the actual ball instance. The error that I have is access to undefined property Mc_gear_small as well as Mc_rack. What am I doing wrong?

stop();

this.addEventListener(Event.ENTER_FRAME,RotateTiny);

function RotateTiny(e:Event):void {
    this.rotation=this.rotation+7;
}

this.addEventListener(Event.ENTER_FRAME,MoveTiny);

function MoveTiny(e:Event):void {
    this.x=this.x+7;    
}


function fallTiny(e:Event):void {
    this.y=this.y-7;    
}

this.addEventListener(Event.ENTER_FRAME, Fall);

function Fall  ( e:Event ):void
{

if (mc_gear_small.hitTestObject(mc_rack))
{
    mc_gear_small.y=mc_rack.y-15;
}

}

Aucun commentaire:

Enregistrer un commentaire