-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFloor.js
31 lines (28 loc) · 1.1 KB
/
Floor.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
import React, { Component } from 'react';
import { View, Image } from 'react-native';
import Images from './assets/Images';
export default class Floor extends Component {
render () {
const width = this.props.body.bounds.max.x - this.props.body.bounds.min.x;
const height = this.props.body.bounds.max.y - this.props.body.bounds.min.y;
const x = this.props.body.position.x - width / 2;
const y = this.props.body.position.y - height / 2;
const imageIterations = Math.ceil(width / height);
return (
<View
style={{
position: 'absolute',
top: y,
left: x,
width: width,
height: height,
overflow: 'hidden',
flexDirection: 'row'
}}>
{Array.apply(null, Array(imageIterations)).map(( el, idx) => {
return <Image style={{ width: height, height: height}} key={idx} resizeMode="stretch" source={Images.floor} />
})}
</View>
)
}
}