Generified handling of sprites and the global state.