jeudi 20 avril 2017

when all the lemon movie clips hit the target I want it to go to a well done screen however im unsure how to

Im using Actionscript 3 in Adobe Flash. Ive tried numerous if statements some have slightly worked however,the one at the moment only considers the fifth movieclip. It should be when all movieclips have hut the target the next scene should play. can you please help? Thanks.

import flash.events.TouchEvent;
import flash.ui.Multitouch;
import flash.ui.MultitouchInputMode;
import flash.display.MovieClip;

 /* Touch and Drag Event
 Allows the object to be moved by holding and dragging the object.
 */
var objectoriginalX:Number;
var objectoriginalY:Number;
Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;

var lemons:Array = [lemon1_mc, lemon2_mc, lemon3_mc, lemon4_mc, lemon5_mc];

for each(var lemonMC:MovieClip in lemons)
{
lemonMC.buttonMode = true;
lemonMC.addEventListener(TouchEvent.TOUCH_BEGIN, pickobject);
lemonMC.addEventListener(TouchEvent.TOUCH_END, dropobject);

lemonMC.startX = lemonMC.x;
lemonMC.startY = lemonMC.y;

 }
 var fl_DragBounds:Rectangle = new Rectangle(0, 0, stage.stageWidth, 
 stage.stageHeight);


 function pickobject(event:TouchEvent):void
 {
event.target.startTouchDrag(event.touchPointID, false, fl_DragBounds);
event.target.parent.addChild(event.target);
objectoriginalX = event.target.x; 
objectoriginalY = event.target.y;


}

function dropobject(event:TouchEvent):void
{
if(event.target.hitTestObject(target_mc)){
    event.target.buttonMode = false;
    event.target.x = target_mc.x;
    event.target.y = target_mc.y;
    event.target.visible = false;


  }

 if (lemonMC.hitTestObject(target_mc))
{
    gotoAndPlay(0,"Scene 2");
}

else{
event.target.x = event.target.startX;
event.target.y = event.target.startY;
event.target.buttonMode = true;
}
}

Aucun commentaire:

Enregistrer un commentaire