That isn't a design solution - that is a solution using Gamemaker.
There is a built-in example that comes with C2.
Free your mind or you will always need a helping hand or just copy and paste...
It's always better to understand things and translate it to your needs.
but the c2 excample is a good approach.