-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
47 lines (37 loc) · 1008 Bytes
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import Expo from 'expo';
import React from 'react';
import { Alert, PanResponder } from 'react-native';
import Assets from './Assets';
import Game from './Game';
//// App
// This is the root component of the app. It does any loading required
// then renders `Game`.
class App extends React.Component {
state = {
loaded: false,
};
componentWillMount() {
// THREE warns about unavailable WebGL extensions.
console.disableYellowBox = true;
this.load();
}
// Do stuff that needs to be done before first render of scene.
async load() {
try {
// Load assets
await Promise.all(
Object.keys(Assets).map(name => Assets[name].downloadAsync())
);
// We're good to go!
this.setState({ loaded: true });
} catch (e) {
Alert.alert('Error when loading', e.message);
}
}
render() {
return this.state.loaded
? <Game style={{ flex: 1 }} />
: <Expo.Components.AppLoading />;
}
}
Expo.registerRootComponent(App);