This fix will work, but you can achieve what want differently.
For example you could add a frame to your blue block, a red frame at position 1, set the animation speed of the object to 0, then when the player touch a blue square :
On collision with blue block -> set frame to 1.