I’ve created a brand new “Mobile template” project and trying to rotate my sprite on touch event. For some reasons it rotates only first time I touch the screen. All next touches are registered (I see “Touch” in the console) but the sprite does not rotate anymore…
function on_input(self, action_id, action)
if action_id == hash("touch") and action.pressed then
go.animate("switch", "euler.z", go.PLAYBACK_ONCE_FORWARD, -90, go.EASING_LINEAR, 0.5)
print("Touch!")
end
end
Rotation is to absolute values. Your code rotates to Z angle -90 and not current rotation minus 90. Subsequent rotations will start at -90 and go to -90 - i.e. no rotation.
I believe it’s because the code doesn’t rotate the sprite by -90 degrees but to -90 degrees. Subsequent calls “rotate” it again, but the rotation is the same as the way the sprite already is rotated, so you can’t see anything.
You should probably change the -90 to a relative rotation based on the sprite’s current rotation.