-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmain.js
48 lines (39 loc) · 1.02 KB
/
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
48
import Exponent from 'exponent';
import React from 'react';
import { Alert, PanResponder } from 'react-native';
import Game from './src/Game';
class App extends React.Component {
state = {
loaded: false,
}
componentWillMount() {
console.disableYellowBox = true;
this.loadAssetsAsync();
}
async loadAssetsAsync() {
try {
await Exponent.Font.loadAsync({
'SpaceMono': require('./assets/fonts/SpaceMono-Regular.ttf'),
});
let assets = [
require('./assets/sounds/countdownBlip.mp3'),
require('./assets/sounds/brickDeath.mp3'),
require('./assets/sounds/blip.wav'),
];
await Promise.all(
assets.map(asset => Exponent.Asset.fromModule(asset).downloadAsync())
);
this.setState({ loaded: true });
} catch (e) {
Alert.alert('Error when loading', e.message);
}
}
render() {
return this.state.loaded ? (
<Game />
) : (
<Exponent.Components.AppLoading />
);
}
}
Exponent.registerRootComponent(App);