You don't need a separate variable at all. You already have two values that hold the state: the frame numbers themselves. Also, you method is inefficient as the frames are set every tick. This method only changes the frame 'on touched'. (Doesn't make much difference yet, but as things get bigger, it's better practice to reduce overhead).