Skip to main content
BluTurquoise
Participating Frequently
October 8, 2015
Question

score disappears in game

  • October 8, 2015
  • 2 replies
  • 677 views

to anyone whom can help:

this is a lesson I'm doing for a class except the tutorial doesn't cover the response to this scenario.  My score disappears once the game is in execution mode.  I've seen forms suggesting the placement of a .embed code (not specific where) I've also seen a suggestion to change font which i've done and nothing has happened.  I don't want to disrupt the code from the lesson to much so any suggestions to what I may be missing I appreciate.

thank you.

//Setting up the game variables

userChoice = "none";

userComp = "none";

//Setting up score variables

Wins = 0;

Losses = 0;

Draws = 0;

Tries = 0;

//control variable

control = true;

//Initial hideLogos call

hideLogos();

function hideLogos()

{

  //Hiding our logos

  this.StatWin._visible = false;

  this.statLose._visible = false;

  this.statDraw._visible = false;

}

//Choose functions

function choose(newChoice)

{

  //If we have control, run the game

  if (control)

  {

  hideLogos();

  userChoice = newChoice;

  trace("You've have selected " + userChoice);

  rndChoice = Math.ceil(Math.random() * 3);

  //trace ("Random number : " + rndChoice) ;

  switch (rndChoice)

  {

  case 1 :

  compChoice = "Rock";

  break;

  case 2 :

  compChoice = "Zors";

  break;

  case 3 :

  compChoice = "Paper";

  break;

  }

  trace("Computer selected" + compChoice);

  Object(this).scarecrowUser.gotoAndPlay(userChoice);

  Object(this).scarecrowComp.gotoAndPlay(compChoice);

  control = false;

  }

}

function gameLogic()

{

  if (!control)

  {

  if ((userChoice == "Rock" && compChoice == "Zors") || (userChoice == "Zors" && compChoice == "Paper") || (userChoice == "Paper" && compChoice == "Rock"))

  {

  //Result is victory

  trace("You've won!");

  this.StatWin._visible = true;

  wins++;

  }

  else if (userChoice == compChoice)

  {

  //Result is draw

  trace("it's a draw");

  Object(this).statDraw._visible = true;

  draws++;

  }

  else

  {

  //Result is loss

  trace("you've lost :(");

  Object(this).statLose._visible = true;

  losses++;

  }

  tries++;

  control = true;

}

}

//Functions for the buttons

Object(this).btnRock.onPress = function()

{

  choose("Rock");

};

Object(this).btnPaper.onPress = function()

{

  choose("Paper");

};

Object(this).btnZors.onPress = function()

{

  choose("Zors");

};

This topic has been closed for replies.

2 replies

Inspiring
October 10, 2015

As I see in the screenshot, the score text field has no instance name and in your code you're using trace only   trace("You've won!");.. that will not do anything to the score text field it'll only show you the result in the Flash output window! if I am not wrong you have to give an instance name for each text field you want to show your messages through it.. after that use the text fields names in the code to fill the text ( text_instance.text = "You've won!"; ) instead of trace("You've won!");.. plus the previews steps for the font.

Inspiring
October 8, 2015

Object(this).statLose._visible = true;

correct the "visible" code: statLose.visible = true; without underscore.

BluTurquoise
Participating Frequently
October 10, 2015

I tried pulling the underscore but unfortunately it still did not work.  There was another similar complaint where they changed the font and they were good.  I suspect it has something to do with Flash and the imbed radio button.

Inspiring
October 10, 2015

One more thing, it's better to add an "as linkage" for the font you've embedded. (from the library select the font and double click on the "Linkage" area then type the font name as a linkage).