Created
July 24, 2018 02:35
-
-
Save pavelvlasov/592a00692c39c66b7317e899de968177 to your computer and use it in GitHub Desktop.
Sprite component
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Sprite extends React.Component { | |
static defaultProps = { | |
src: PropTypes.string.isRequired, | |
tile: PropTypes.object.isRequired, | |
scale: PropTypes.number.isRequired | |
}; | |
tick = 0; | |
frame: number = 0; | |
state = { | |
state: 0 | |
}; | |
componentDidMount() { | |
this.animate(); | |
} | |
componentWillUnmount() { | |
cancelAnimationFrame(this.frame); | |
} | |
animate = () => { | |
// TODO: implement | |
} | |
render() { | |
const { src, tile, scale } = this.props; | |
const { state } = this.state; | |
return <Tile src={src} state={state} tile={tile} scale={scale} />; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment