Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow addTimer to take a key value for uniqueness #48

Closed
bitspittle opened this issue Sep 3, 2021 · 2 comments
Closed

Allow addTimer to take a key value for uniqueness #48

bitspittle opened this issue Sep 3, 2021 · 2 comments
Labels
enhancement New feature / functionality maybe Not sure if we're going to do this issue or not

Comments

@bitspittle
Copy link
Contributor

bitspittle commented Sep 3, 2021

Currently in Snake I'm doing something like:

var firstMove = true
level.snake.onMoved = {
   if (firstMove) {
      firstMove = false
      addTimer(KonsoleAnim.ONE_FRAME_60FPS, repeat = true) {
         ...
      }
   }
}

which could possibly be simplified to:

level.snake.onMoved = {
   addTimer(KonsoleAnim.ONE_FRAME_60FPS, repeat = true, key = level.snake) {
      ...
   }
}

In other words, if a timer with the particular key is already found, don't add it again.

@bitspittle bitspittle added enhancement New feature / functionality maybe Not sure if we're going to do this issue or not labels Sep 3, 2021
@bitspittle
Copy link
Contributor Author

It's way fewer lines, which is nice, so we should probably do it. But there's a workaround so it's not urgent.

@bitspittle
Copy link
Contributor Author

Done. KonsoleAnim also benefted from the feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature / functionality maybe Not sure if we're going to do this issue or not
Projects
None yet
Development

No branches or pull requests

1 participant