issue#661 update state before values are cleared

this prevent loosing state values related to physics bodys
and inputs before `state.update` is called.
Merge pull request #662 from ralphsmith80/master

issue#661 update state before values are cleared