private void resetSnow(Snow snow) { snow.y = 0; snow.x = r.nextInt(width); snow.speed = r.nextInt(maxSpeed) * 2; snow.radius = 2; snow.color = Color.WHITE; }
/** * 雪花下落 * * @param snow Snow */ private void SnowDown(Snow snow) { // 雪花的落出屏幕后又让它从顶上下落 if (snow.x > screenWidth || snow.y > screenHeight) { snow.y = 0; snow.x = random.nextFloat() * screenWidth; } snow.x += snow.offset; // 下落飘的偏移量 snow.y += snow.speed; // 下落的速度 }
private void moveSnow(Snow snow) { snow.y = snow.y + snow.speed * 2; if (snow.y > height) resetSnow(snow); }