Skip to main content
deborahb44958436
Inspiring
May 6, 2015
Answered

Another counter problem AS3

  • May 6, 2015
  • 1 reply
  • 370 views

I set this game level so the player can replay the level but there is a penalty of -30 points  each time the player replay the level. Also I set the replay to forget the accumulated points of that level. Somehow the two statements conflict with one another and each time the player replay the level the negative points multiple. for example on the first replay it would penalize the player with -30 points as it should  but on the second try it would penalize  the player with -60 points and on the third -90 points. each formula works great on it's own but not when I put them together. I tried everything and can't figure it out . please help

Here is the script:

playLevelAgain.addEventListener(MouseEvent.CLICK, doLevelAgain5);

function doLevelAgain5(event: MouseEvent): void {

// -30 points penalty for replaying the level

score -= 30;

// resting the points to the original point level.

score -= ScoreScene6;

gotoAndPlay(1);

This topic has been closed for replies.
Correct answer Ned Murphy

The two lines where you adjust the score do not make sense when you place them together, especially if the second is supposed to be resetting (not "resting" I would guess).  What is the value of ScoreScene6?  Try using the trace function to see what the value of the score is through that processing...

trace("1: ", score);

// -30 points penalty for replaying the level

score -= 30;

trace("2: ", score);

// resting the points to the original point level.

score -= ScoreScene6;

trace("3: ", score);

1 reply

Ned Murphy
Ned MurphyCorrect answer
Legend
May 6, 2015

The two lines where you adjust the score do not make sense when you place them together, especially if the second is supposed to be resetting (not "resting" I would guess).  What is the value of ScoreScene6?  Try using the trace function to see what the value of the score is through that processing...

trace("1: ", score);

// -30 points penalty for replaying the level

score -= 30;

trace("2: ", score);

// resting the points to the original point level.

score -= ScoreScene6;

trace("3: ", score);

deborahb44958436
Inspiring
May 6, 2015

I got it. thanks for the help and I like trace trick

Ned Murphy
Legend
May 6, 2015

You're welcome.  Try to remember the trace function and use it freely... it's purpose in life is to help solve designs