To stop the infinite animation loop you can invoke the command stop()
. As soon as the command is executed the infinite animation loop will stop and the animation will freeze in the moment.
In the example below, we have the text "Hello" that is moving constantly to the right. We have added an onkey interaction that says, as soon as the key "s" is pressed stop the loop. When you run the code below and press key "s" the loop will stop and the animation/game will freeze.
shape greeting(text):
.text = "Hello"
.color = RED
.position = (100, 100)
endshape
onkey s
stop()
endonkey
loop
greeting.move(RIGHT)
endloop
Notice any errors or typos? Please let us know or feel free to edit stop.md and issue a pull request.
Follow us on twitter @RevineLang
Built by Arpit Bhayani