Is there a proper way to reset/restart a game?

Hi everyone,

I know this is a very broad general question, bu I have run into an issue with the little game I am working on. I am not really sure how to properly restart or reset my game. I sort of achieve it by resetting the project properties to default settings and going back to a previous frame by clicking a button, then I also tried checking if the avatar health reached 0 then reset the project properties to default settings.

However, even though this seems to work, it also seems like the project frame rate, or perhaps one of my other values increase because every time you click the button to replay and go back to the previous frame, it seems like it’s going faster. You can die a couple more times and hit replay and it’s super fast right off the bat.

So I think I am doing something wrong, I just don’t know what.

Here is the game in question:
ifi-holidays202012-7-2020_12-13-56PM.html (2.2 MB)
ifi-holidays202012-7-2020_12-13-48PM.wick (115.0 KB)

So if you have any references or suggestions I can check, it would be much appreciated. Thank you.


P.s. I have done some simple games before but I didn’t have a reset button. The way I did it would just to completely refresh the web page which I could totally do for this.

You can see some examples here:
Reading cassette
Christmas2019

1 Like

I might’ve found the problem: in the default script, you have an update function.

Let’s say you have an update function in the default frame that says, “obj.x+=10,” the object will go right by 10. Then you come back to the frame after leaving it, it reloads the update script and makes the object go right by 10. Then it would be really going right by 20. Let me know if this sounds confusing.

Solution:
Add an update script, and write everything in there
ifi-holidays202012-7-2020_1-53-04PM.wick (114.9 KB)

Let me know if this helps

1 Like

thank you for your help. Let you know how it goes.

That fixed it. I think I understand what your saying although now I am wondering why, is it because now it’s firing two update events instead one? Now looking at the reference, the example listed does say it’s used in the load script, but if i put the update event in there I think it has the same unexpected behavior. Just curious that’s all, but anyway thanks for the help.