mercredi 12 avril 2017

Example of game colors in as3

How can you put names

Make sure if you put names on the text dynamic and the rest of the colors

This is a game about colors where the name of the color will appear on top and you have to try to guess which color you will have 3 lives

  stop();

 //var and text information
  texto.text = "Vermelho";
  var vidas  = 3;
  vida.text = "Vidas: " + vidas;

  //buttons function to be pressed
  vermelho.addEventListener(MouseEvent.CLICK, clicked);
  Azul.addEventListener(MouseEvent.CLICK, clicked1);
  Verde.addEventListener(MouseEvent.CLICK, clicked2);
  Amarelo.addEventListener(MouseEvent.CLICK, clicked3);
  Rosa.addEventListener(MouseEvent.CLICK, clicked4);
  Laranja.addEventListener(MouseEvent.CLICK, clicked5);

 //function to validate if the text is equal to the button
function clicked(clickInfo){

//If click on red go to blue
if(clickInfo.target == vermelho){
    trace("Correto");
    texto.text = "Azul";
    vermelho.visible = false;
}else{
    vidaa();
    vida.text = "Vidas: " + vidas;
    trace("Incorecto");
}
}
function clicked1(clickInfo){
//If click on blue go to green
if(clickInfo.target == Azul && texto.text == "Azul"){
    trace("Correto");
    texto.text = "Verde";
    Azul.visible = false;
}else{
    vidaa();
    vida.text = "Vidas: " + vidas;
    trace("Incorecto");
}
}
function clicked2(clickInfo){
//If click on green go to yellow
if(clickInfo.target == Verde && texto.text == "Verde"){
    trace("Correto");
    texto.text = "Amarelo";
    Verde.visible = false;
}else{
    vidaa();
    vida.text = "Vidas: " + vidas;
    trace("Incorecto");
}
}
function clicked3(clickInfo){
//If click on yellow go to pink
if(clickInfo.target == Amarelo && texto.text == "Amarelo"){
    trace("Correto");
    texto.text = "Rosa";
    Amarelo.visible = false;
}else{
    vidaa();
    vida.text = "Vidas: " + vidas;
    trace("Incorecto");
}
}
function clicked4(clickInfo){
//If click on pink go to orange
if(clickInfo.target == Rosa && texto.text == "Rosa"){
    trace("Correto");
    texto.text = "Laranja";
    Rosa.visible = false;
}else{
    vidaa();
    vida.text = "Vidas: " + vidas;
    trace("Incorecto");
}
}
function clicked5(clickInfo){
//If click on orange go to win the game
if(clickInfo.target == Laranja && texto.text == "Laranja"){
    trace("Correto");
    texto.text = "Parabéns";
    Laranja.visible = false;
}else{
    vidaa();
    vida.text = "Vidas: " + vidas;
    trace("Incorecto");
}

}


function vidaa(){
vidas -=1;
if (vidas == 0){
    gotoAndStop(2);
}
}

Aucun commentaire:

Enregistrer un commentaire