@@ -7,14 +7,15 @@ export default class Controls extends PureComponent {
77 constructor ( props ) {
88 super ( props )
99 this . scrollView = React . createRef ( )
10- this . cannonXPosition = 0
10+ this . cannonXPosition = this . props . width / 2
1111 this . translateY = new Animated . Value ( 0 )
1212 }
1313
1414 componentDidMount ( ) {
15+ const { width } = this . props
1516 // Centra il cannone
1617 // Senza timeout non chiama scrollTo.. perché?
17- setTimeout ( ( ) => this . scrollView . current . scrollTo ( { x : this . props . width / 2 - 25 , y : 0 , animated : false } ) , 200 )
18+ setTimeout ( ( ) => this . scrollView . current . scrollTo ( { x : width / 2 - 25 , y : 0 , animated : false } ) , 200 )
1819 Animated . timing (
1920 this . translateY ,
2021 {
@@ -27,7 +28,7 @@ export default class Controls extends PureComponent {
2728 ) . start ( )
2829 }
2930
30- afire = ( ) => {
31+ fire = ( ) => {
3132 const { fire } = this . props
3233
3334 // Passa a fire() la posizione del cannone, per sincronizzare il proiettile
@@ -47,7 +48,7 @@ export default class Controls extends PureComponent {
4748 }
4849
4950 render ( ) {
50- const { width, height, winner } = this . props
51+ const { width, height } = this . props
5152
5253 console . log ( 'Controls rendered' )
5354
@@ -63,33 +64,33 @@ export default class Controls extends PureComponent {
6364 showsHorizontalScrollIndicator = { false }
6465 overScrollMode = 'never'
6566 decelerationRate = { 0.01 }
66- contentContainerStyle = { styles . scrollViewContainer }
6767 scrollEventThrottle = { 50 }
6868 onScroll = { ( { nativeEvent } ) => this . calculateCannonPosition ( nativeEvent . contentOffset . x ) }
6969
7070 >
71- < View style = { sidePaddingStyle } />
72-
73- { winner !== 2 && < Sprite image = 'cannon' /> }
74-
75- < View style = { sidePaddingStyle } />
76-
71+ < TouchableWithoutFeedback onPress = { this . fire } >
72+ < View style = { styles . touchableArea } >
73+ < View style = { sidePaddingStyle } />
74+ < Sprite image = 'cannon' />
75+ < View style = { sidePaddingStyle } />
76+ </ View >
77+ </ TouchableWithoutFeedback >
7778 </ ScrollView >
78- </ Animated . View >
79+ </ Animated . View >
7980 )
8081 }
8182}
8283
8384const styles = StyleSheet . create ( {
84- scrollViewContainer : {
85+ touchableArea : {
86+ flexDirection : 'row' ,
8587 alignItems : 'flex-end'
8688 } ,
8789 sidePaddingBase : {
8890 height : 50 ,
8991 //backgroundColor: 'orangered'
9092 } ,
9193 base : {
92- //backgroundColor: 'green',
9394 position : 'absolute' ,
9495 bottom : - 50 ,
9596 left : 0 ,
0 commit comments