2013-04-10 49 views
0

我正在製作一款互動遊戲 - 目前爲止我已經有了這段代碼。 drop1是硬幣,用戶將其放入target1(盒子)中,一旦完成,他們就可以在下一個場景中觀看視頻播放。當drop1(硬幣)滴到框中可以看到硬幣然後消失AS3 - 使用If語句拖動到下一個場景。

//Array to hold the target instances, the drop instances, 
    //and the start positions of the drop instances. 
    var hitArray:Array = new Array(hitTarget1); 
    var dropArray:Array = new Array(drop1); 
    var positionsArray:Array = new Array(); 


    //This adds the mouse down and up listener to the drop instances 
    //and add the starting x and y positions of the drop instances 
    //into the array. 
    for (var i:int = 0; i < dropArray.length; i++) { 
    dropArray[i].buttonMode = true; 
    dropArray[i].addEventListener(MouseEvent.MOUSE_DOWN, mdown); 
    dropArray[i].addEventListener(MouseEvent.MOUSE_UP, mUp); 

    positionsArray.push({xPos:dropArray[i].x, yPos:dropArray[i].y}); 
    } 

    //This drags the object that has been selected and moves it 
    //to the top of the display list. This means you can't drag 
    //this object underneath anything. 
    function mdown(e:MouseEvent):void { 
    e.currentTarget.startDrag(); 
    setChildIndex(MovieClip(e.currentTarget), numChildren - 1); 
    } 

    //This stops the dragging of the selected object when the mouse is 
    //released. If the object is dropped on the corresponding target 
    //then it get set to the x and y position of the target. Otherwise 
    //it returns to the original position. 
    function mUp(e:MouseEvent):void { 
    var dropIndex:int = dropArray.indexOf(e.currentTarget); 
    var target:MovieClip = e.currentTarget as MovieClip; 

    target.stopDrag(); 

    if (target.hitTestObject(hitArray[dropIndex])) { 
    target.x = hitArray[dropIndex].x; 
    target.y = hitArray[dropIndex].y; 
    drop1.visible = false; 
    }else{ 
    target.x = positionsArray[dropIndex].xPos; 
    target.y = positionsArray[dropIndex].yPos; 

    } 
    } 

現在...我想要的代碼知道當用戶在框中已經下降了硬幣如果用戶已他們可以觀看視頻,但如果他們將硬幣放入盒中,則只能觀看視頻。我如何編碼?

請大家幫忙。

謝謝

回答

0

如果你還在苦苦掙扎,你隨時可以嘗試閱讀說明書..?我懷疑這就是爲什麼你迄今還沒有答案。在幀/場景之間旅行需要gotoAndPlay或gotoAndStop。檢查:http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/MovieClip.html#gotoAndPlay()

看場景跳轉代碼的例子二。它說:「介紹」(幀標籤)也沒關係,只需使用一個號碼,但場景的名稱必須..如:

mc1.gotoAndPlay("intro", "Scene 12"); 

或在您的情況類似下面(假設你已經將其命名爲scene_video)

if (target.hitTestObject(hitArray[dropIndex])) { 
target.x = hitArray[dropIndex].x; 
target.y = hitArray[dropIndex].y; 
drop1.visible = false; 
gotoAndStop(1, "scene_video");  } 

我再次假設您的視頻播放器在該場景的第1幀,因此在那裏停止允許用戶有機會觀看視頻播放器。

+0

謝謝你的幫助 – sjb 2013-06-18 10:11:44