问题
A few fish come to the screen and stop after a while the other fishes come in.Then a while the stage is stopped and the player is trying to guess the first fishes.How can I create code to say that the chosen fish is wrong or true.For example:The first come 3 fishes it's correct and after then came fishes wrong.Player guess right all the fishes and earn coins or display win text bla bla..
I selected to sequence of the fish at timeline.So yes I animated.I was using as3 random function for the display on the screen.
This is a memory game.Fishes (it's buttons ) display on the screen and stop then other fishes ( a wrong fishes ) display.After a while stops all the scene and player choose ( click ) right fishes.So all I need: if clicked button 1 + button2 = true then go to bla bla. if wrong goto bla bla. All in the one order...I don't put code for display to fish,just I put here a button code .
fish1.addEventListener(MouseEvent.CLICK, click1);
fish2.addEventListener(MouseEvent.CLICK, click2);
fish3.addEventListener(MouseEvent.CLICK, click3);
fish4.addEventListener(MouseEvent.CLICK, click4);
fish5.addEventListener(MouseEvent.CLICK, click5);
var PC:Boolean = false;
function click1 ( m:MouseEvent ){
PC = true;
}
function click2 ( m:MouseEvent ){
PC = true;
}
function click3 ( m:MouseEvent ){
PC = true;
}
function click4 ( m:MouseEvent ){
PC = true;
}
function click5 ( m:MouseEvent ){
if ( PC )
{
PC = false;
gotoAndPlay (1);
}
}
回答1:
It's easy. So you know how many fishes are CORRECT right , so use
//number of correct fishes
var correctFishesCount:int = 3;
//add a number to this temporary count to check whether user predicted all fishes
var userCount:int = 0;
fish1.addEventListener(MouseEvent.CLICK, click1);
fish2.addEventListener(MouseEvent.CLICK, click2);
fish3.addEventListener(MouseEvent.CLICK, click3);
fish4.addEventListener(MouseEvent.CLICK, click4);
fish5.addEventListener(MouseEvent.CLICK, click5);
var PC:Boolean = false;
function addUserCount(){
userCount++;
if(userCount == correctFishesCount)
We Have a winner
}
function click1 ( m:MouseEvent ){
PC = true;
addUserCount()
}
function click2 ( m:MouseEvent ){
PC = true;
addUserCount()
}
function click3 ( m:MouseEvent ){
PC = true;
addUserCount()
}
function click4 ( m:MouseEvent ){
PC = true;
addUserCount()
}
function click5 ( m:MouseEvent ){
if ( PC )
{
PC = false;
gotoAndPlay (1);
}
来源:https://stackoverflow.com/questions/41556178/if-clicked-12-button-true-or-wrong-how-i-do-that