reset method
void
reset()
当雪花移出屏幕时,需要重置参数
Implementation
void reset() {
double ratio = 1.0;
if (weatherType == WeatherType.lightRainy) {
ratio = 0.5;
} else if (weatherType == WeatherType.middleRainy) {
ratio = 0.75;
} else if (weatherType == WeatherType.heavyRainy ||
weatherType == WeatherType.thunder) {
ratio = 1;
} else if (weatherType == WeatherType.lightSnow) {
ratio = 0.5;
} else if (weatherType == WeatherType.middleSnow) {
ratio = 0.75;
} else if (weatherType == WeatherType.heavySnow) {
ratio = 1;
}
if (WeatherUtil.isRainy(weatherType)) {
double random = 0.4 + 0.12 * Random().nextDouble() * 5;
this.scale = random * 1.2;
this.speed = 30 * random * ratio * heightRatio;
this.alpha = random * 0.6;
x = Random().nextInt(width * 1.2 ~/ scale).toDouble() -
width * 0.1 ~/ scale;
} else {
double random = 0.4 + 0.12 * Random().nextDouble() * 5;
this.scale = random * 0.8 * heightRatio;
this.speed = 8 * random * ratio * heightRatio;
this.alpha = random;
x = Random().nextInt(width * 1.2 ~/ scale).toDouble() -
width * 0.1 ~/ scale;
}
}