android - Java LibGDX Update and Draw Methods -
people write "draw(spritebatch batch)" , "update(float deltatime)" methods in player classes. why don't write "render(spritebatch batch, float deltatime)"? because of readability? mean, why make 2 methods? can in single method.
readability , ease of updating/changing 1 reason.
but there logistical reasons. want sure whole game state date before start drawing, whatever on screen up-to-date possible. if put updating , rendering 1 method each object, objects updated , drawn first might out of date compared objects updated later , affect state of earlier objects. if updating , drawing separated, can update entire game , draw entire game.
and if game uses physics, separation of updating , drawing allows update world @ fixed timestep (at different rate drawing) ensure game play not affected frame rate.
Comments
Post a Comment