嗨,我正在通过adobe flash和acs3制作一个小游戏应用程序。我想启动应用程序然后出现一个影片剪辑,然后我在舞台上有一系列按钮,用户必须从中选择一个按钮以匹配屏幕上的对象。每次用户点击一个按钮点击放置在舞台上的按钮时,对象应该根据用户的正确(添加10分)或错误(不计数)按钮点击进行更改。所以基本上,我认为将屏幕上产生的对象与屏幕上的按钮相匹配的方法是采用他们的x和y,如果他们匹配则添加得分并继续前进。 ,关于如何使对象出现在舞台上特定的x,y然后等待用户点击并基于他们的x和y匹配或错误的任何想法?如果有人有疑问,我可以提供更多信息。
var score=1;
var gameTime:Number =20;
//stop();
var myTimer:Timer = new Timer(1000);
myTimer.addEventListener(TimerEvent.TIMER, createNote);
myTimer.start();
function createNote(evt:TimerEvent):void{
var aNote:NoteF = new NoteF();
aNote.y = 400;
//aNote.y = (Math.floor(Math.random() *100) + 400 );
aNote.x = ( Math.floor(Math.random() *150) + 100 );
aNote.addEventListener(MouseEvent.MOUSE_DOWN,hitme);
gameTime--;
addChildAt(aNote, 0);
txtTime.text = gameTime.toString();
if (gameTime <= 0){
gotoAndStop(6);
myTimer.stop();
aNote.stop();
}
}
function hitme(event:MouseEvent){
var ms:NoteF = new NoteF();
ms.x = event.stageX;
ms.y = event.stageY;
//addChildAt(ms, 0);
txtScore.text = Score++;
event.target.parent.removeChild(event.target);
}
//set the array and fill in the notes for treble
var TrebleArray:Array=["C1","D1","E1","F1","G1","A","B","C","D","E","F","G","A1","B1"];
//then set up the listener for the button
PiannoKeys.addEventListener(MouseEvent.CLICK ,piannokeys);
function piannokeys(myEvent:MouseEvent){
btnC.visible=false;
btnD.visible=false;
btnE.visible=false;
btnF.visible=false;
btnG.visible=false;
btnA.visible=false;
btnB.visible=false;
}
btnC.addEventListener(MouseEvent.CLICK,btnc);
stop();
//now the function called by the function listener
function btnc(myEvent:MouseEvent){
var currentNote:Number=Math.round(Math.random()*(TrebleArray.length-1));
//currentNote++;
txtFeedback.text=TrebleArray[currentNote];
}