Created
February 3, 2017 19:25
-
-
Save markbiek/4c203d9e8956f05e536a226b2671eccb to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import React, { Component } from 'react'; | |
import { | |
AppRegistry, | |
StyleSheet, | |
Text, | |
Button, | |
Navigator, | |
View, | |
TouchableHighlight | |
} from 'react-native'; | |
import { | |
Loop, | |
Stage, | |
Sprite | |
} from 'react-game-kit/native'; | |
export default class App extends Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
steps: [0] | |
}; | |
this.stepRocket = this.stepRocket.bind(this); | |
} | |
stepRocket() { | |
let { steps } = this.state; | |
this.setState({ | |
steps: [steps[0] == 0 ? 20 : 0] | |
}); | |
} | |
render() { | |
const { steps } = this.state; | |
if (!steps) { | |
console.log('Not ready yet'); | |
return null; | |
} | |
console.log(steps); | |
return ( | |
<Loop> | |
<Stage> | |
<TouchableHighlight onPress={this.stepRocket}> | |
<View style={styles.container}> | |
<Sprite | |
repeat={false} | |
src={require('../../img/sprite-rocket.png')} | |
tileWidth={128} | |
tileHeight={128} | |
ticksPerFrame={1} | |
scale={2} | |
state={0} | |
steps={steps} | |
/> | |
</View> | |
</TouchableHighlight> | |
</Stage> | |
</Loop> | |
); | |
} | |
} | |
const styles = StyleSheet.create({ | |
container: { | |
width: 1000, | |
height: 2000, | |
borderColor: 'red', | |
borderWidth: 1 | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment