end callback before "nextstate" check to avoid callback not being called
added safety checks and sanitized values
added ability to draw a sprite with a scale
added facility function GetFrameDimension