-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBall.js
More file actions
33 lines (31 loc) · 829 Bytes
/
Ball.js
File metadata and controls
33 lines (31 loc) · 829 Bytes
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 } from "react-native";
import { array, object, string } from 'prop-types';
export default class Ball extends Component {
render() {
const width = this.props.size[0];
const height = this.props.size[1];
const x = this.props.body.position.x - width / 2;
const y = this.props.body.position.y - height / 2;
const minSize = Math.min(width, height);
return (
<View
style={{
position: "absolute",
left: x,
top: y,
width: width,
height: height,
backgroundColor: this.props.color || "orange",
borderWidth: 2,
borderRadius: minSize / 2,
borderColor: 'black'
}} />
);
}
}
Ball.propTypes = {
size: array,
body: object,
color: string
}