Trying to Rotate and Flip Image

I am trying to make it so what when my image hits the side or when it hits the top of the screen the image is going to flip along its X or Y axis, I am not exactly sure how to make it happen, but was wondering if anyone could help me out, below is a link to my code.

You will probably need 4 different images to make this work.

Not an expert in App Lab, but did find this old posting. Would this work?