well, imo, you made it look a bit weird, but I think this is a better way to do code animation. code > frame imo
You could also make the x move instead of moving the sprite, but this is easier just a little bit, so that's why I did it like this. (I only changed the code side, not the frame side)