jeudi 24 décembre 2015

how to make a score with function mousedown to movie clip actionscript 3

enter image description hereIn my game, I've three holes (MovieClip) and that every time (of 20 times) the rat (MovieClip) to be over one of those holes. i want to to make a score when rat(movie clip) click with function mousedown in actionscript 3. i already to try but error.

 hammerMC.addEventListener(MouseEvent.MOUSE_DOWN, turunpalu);
 function turunpalu (e:Event):void{
   hammerMC.visible = true;
   hammerMC.x = mouseX;
   hammerMC.y = mouseY; 

// the array has all the hole movieclips
var allHoles:Array = new Array(hole1_mc,hole2_mc, hole3_mc);
rat_mc.visible = false;

// show the rat 20 times
var myTimer:Timer = new Timer(1000,20); 
myTimer.addEventListener(TimerEvent.TIMER, showRat);

function showRat(e:Event):void{
// choose a random hole
var rand = Math.floor(Math.random()*3);
var randomHole = allHoles[rand];

rat_mc.visible = true;
rat_mc.x = randomHole.x;
rat_mc.y = randomHole.y;

Aucun commentaire:

Enregistrer un commentaire