简体   繁体   中英

Adobe AIR 3.2 for Android AS3

I am creating a simple game for Android using flash and AS3. I have basic functionality, multi touch and touch and drag etc. I am trying to trigger an event when 3 objects are dragged to a certain point of the users screen, specifically, skip to a new frame. Shown below is the touch and drag event I am using to control the objects but I am kind of stumped on how I go about triggering the required event when all 3 are dragged to a certain position on screen. Any advice or direction would be greatly appreciated.

Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;

Gem1_MC.addEventListener(TouchEvent.TOUCH_BEGIN, fl_TouchBeginHandler);
Gem1_MC.addEventListener(TouchEvent.TOUCH_END, fl_TouchEndHandler);


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

    function fl_TouchBeginHandler(event:TouchEvent):void
    {
        event.target.startTouchDrag(event.touchPointID, false, fl_DragBounds);
    }

    function fl_TouchEndHandler(event:TouchEvent):void
    {
        event.target.stopTouchDrag(event.touchPointID);
    }

You need a loop in your game that fires on Event.ENTER_FRAME that tests each object's Rectangle against the "Victory" area(s) containsRect() method. http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/geom/Rectangle.html#containsRect()

You'll need a conditional to make sure that all 3 evaluate to true and then can trigger your victory condition.

You could fire this loop on the movement of the score objects as well, but then you're a bit limited if you wanted to do something like have a computer controlled opponent or do a simple demo within the game and reuse that logic.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM