Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Another counter problem AS3

Participant ,
May 06, 2015 May 06, 2015

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);

TOPICS
ActionScript
315
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , May 06, 2015 May 06, 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);

Translate
LEGEND ,
May 06, 2015 May 06, 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);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
May 06, 2015 May 06, 2015

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 06, 2015 May 06, 2015
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines