I have a student that wants to provide the option of two different type of games in the Clicker App - if the user clicks catButton, then the game behaves one way, and if dogButton, another way. She attempted this with two different functions: a catFunction in the catButton event handler, and a dogFunction in the dogButton event handler. Each function contains a series of onEvents.
The problem is that even though it appears that her code assigns the variables for lives and score back to the game’s defaults after a lost game, if you play the game again, the numbers go up and down by two points (instead of one). It’s as if the user is trapped in a double function.
We understand that she could probably fix this problem by creating two screens with a separate series of onEvents, but she wanted to try to handle it with functions on one screen. And now we’re really curious as to why the logic behaves this way. Is this problem due to having onEvents embedded within an onEvent? (I also realize there might be something entirely different amiss in the logic; I’m new at this myself.)