Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save anchetaWern/7411435de330c9dd7e98e05b5ab6fc77 to your computer and use it in GitHub Desktop.

Select an option

Save anchetaWern/7411435de330c9dd7e98e05b5ab6fc77 to your computer and use it in GitHub Desktop.
React Native Accelerometer Maze: Subscribe to accelerometer data
// App.js
accelerometer.subscribe(({ x, y }) => {
Matter.Body.setPosition(theBall, {
x: this.state.ballX + x,
y: this.state.ballY + y
});
this.setState({
ballX: x + this.state.ballX,
ballY: y + this.state.ballY,
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment