-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPipe.js
33 lines (30 loc) · 1.19 KB
/
Pipe.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
import React, { Component } from "react";
import { View, Image } from "react-native";
import Images from './assets/Images';
export default class Pipe 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 pipeRatio = 160 / width;
const pipeHeight = 33 * pipeRatio;
const pipeIterations = Math.ceil(height / pipeHeight)
return (
<View
style={{
position: "absolute",
left: x,
top: y,
width: width,
height: height,
overflow: 'hidden',
flexDirection: 'column'
}}>
{Array.apply(null, Array(pipeIterations)).map(( el, idx) => {
return <Image style={{ width: width, height: pipeHeight }} key={idx} resizeMode="stretch" source={Images.pipeCore} />
})}
</View>
);
}
}