-
Notifications
You must be signed in to change notification settings - Fork 0
/
ballPane.java
130 lines (130 loc) · 4.09 KB
/
ballPane.java
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
//package com.example.ballpane;
//
//import javafx.animation.Animation;
//import javafx.animation.KeyFrame;
//import javafx.animation.Timeline;
//import javafx.animation.TranslateTransition;
//import javafx.beans.property.DoubleProperty;
//import javafx.scene.layout.Pane;
//import javafx.scene.paint.Color;
//import javafx.scene.shape.Circle;
//import javafx.util.Duration;
//
//import java.util.ArrayList;
//
//public class ballPane extends Pane {
// public final int radius = 20;
// private double score ;
// private final int numberOfBalls = 5;
// private int count = 0;
//
// private int x = radius, y = radius;
// private int dx = 1, dy = 1;
//
// private Circle mycircle ;
//
// private Timeline animation;
// private boolean isSelect = false ;
// Timeline[] animations = new Timeline[numberOfBalls];
// myCircle[] Balls = new myCircle[numberOfBalls];
// public ballPane(){
// add();
//
//// for (Timeline animation : animations){
//// getChildren().add(Balls[count]);
//// animation = new Timeline( new KeyFrame(Duration.millis(100),e -> moveBallDownAndRemove(count)));
//// animation.setCycleCount(Timeline.INDEFINITE);
//// animation.play();
//// count++;
//// }
// animation = new Timeline(
// new KeyFrame(Duration.millis(50), e -> moveBallDownAndRemove()));
// animation.setCycleCount(Timeline.INDEFINITE);
// animation.play(); // Start animation
//
//// for (int i = 0; i < Balls.length; i++) {
//// getChildren().add(Balls[i]);
//// Timeline animation = new Timeline(
//// new KeyFrame(Duration.millis(100), e -> moveBallDownAndRemove(count))
//// );
//// animation.setCycleCount(Timeline.INDEFINITE);
//// animation.play();
//// count++;
//// }
//// count = 0;
//
// }
//// public void createBalls(){
//// for (int i = 0; i < numberOfBalls; i++){
//// Balls[i] = new myCircle((int)(radius+Math.random()*getWidth()),y,radius,(i+1)*5);
//// }
//// }
// public void add() {
// Color color = new Color(Math.random(),
// Math.random(), Math.random(), 0.5);
//
// mycircle = new myCircle(x+ (int)(Math.random()*20), y,radius, color,(int)(Math.random()*5));
// getChildren().add(mycircle);
// }
//
//
//
// public void play(){
// animation.play();
// }
// public void pause(){
// animation.pause();
// }
// public void selector(double x,double y){ if(mycircle.contains(x,y)){
//// isSelect = true;
// getChildren().remove(getChildren().size() - 1);
// add();
// }}
//
// public void increaseSpeed(){
// animation.setRate(animation.getRate() + 50.1);
// }
// public void decreaseSpeed(){
// animation.setRate(animation.getRate() > 0 ? animation.getRate()-50.1 : 0);
// }
//
// public DoubleProperty rateProperty(){
// return animation.rateProperty();
// }
// public void displayBalls(int c){
//
//
// }
//
//// protected void moveBall(){
//// if (y < radius || y > getHeight() - radius){
//// dy*=-1;
//// }
//// y+=dy;
//// circle.setCenterX(x);circle.setCenterY(y);
//// }
//
//// protected void moveBallDownAndRemove(int count){
////
//// if (y > getHeight() - radius) {getChildren().remove(Balls[count]); }
//// // remove the circle from the pane after the transition is finished
//// else {
////
//// Balls[count].setCenterY(Balls[count].getCenterY()+dy);
//// }
////
//// }
// protected void moveBallDownAndRemove(){
//
// if (y > getHeight() - radius) {
// getChildren().remove(mycircle);
// add();
// }
// // remove the circle from the pane after the transition is finished
// else {
// mycircle.setCenterY(mycircle.getCenterY()+dy);
// }
//
// }
//
//}