Skip to content

Instantly share code, notes, and snippets.

@pavelvlasov
Created July 24, 2018 02:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pavelvlasov/85555cadaa7c7df7f7622fef56d005df to your computer and use it in GitHub Desktop.
Save pavelvlasov/85555cadaa7c7df7f7622fef56d005df to your computer and use it in GitHub Desktop.
Sprite animate function
const { state } = this.state;
const { framesPerStep, states } = this.props;
if (this.tick === framesPerStep) {
this.tick = 0;
this.setState({
state: (state + 1) % states
});
}
this.tick += 1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment