Copy link to clipboard
Copied
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);
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);
Copy link to clipboard
Copied
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);
Copy link to clipboard
Copied
I got it. thanks for the help and I like trace trick
Copy link to clipboard
Copied
You're welcome. Try to remember the trace function and use it freely... it's purpose in life is to help solve designs
Find more inspiration, events, and resources on the new Adobe Community
Explore Now