RezMike did a 2048 clone, and also created a tutorial explaining how to do it.

https://blog.korge.org/korge-tutorial-writing-2048-game-step-0/