new Thread() {
public void run() {
while (true) {
//星星旋转
angleRotateCelestial += 0.08f;//0.08f
if (angleRotateCelestial >= 360) {
angleRotateCelestial = 0;
}
//方块旋转
angleRotateCube += 2f;//2f
if (angleRotateCube >= 360) {
angleRotateCube = 0;
}
//六角方块旋转
angleRotateCenter +=0.2f;//0.2f
if (angleRotateCenter >= 360) {
angleRotateCenter = 0;
}
//36个六角方块中随机旋转
for (int i = 0; i < X; i++) {
angleRotateSelf[i] += new Random().nextFloat() * 6;//6
if (angleRotateSelf[i] >= 360) {
angleRotateSelf[i] = 0;
}
}
switch (directionZ) {
case 0:
//近处旋转
if (-1f < offsetZ && offsetZ < 0) {//0
offsetZ += 0.006f;//0.006f
} else {
offsetZ +=0.08f;//0.08f
}
if (offsetZ > 0) {
directionZ = 1;//1
}
if (-25f < offsetZ && offsetZ < -13f) {
angleRotateZ += angleZSpan;
} else if (-13f <= offsetZ && offsetZ < -1f) {
angleRotateZ -= angleZSpan;
} else {
angleRotateZ = 0;
}
break;
//远处旋转
case 1:
offsetZ -= 0.08f;
if (offsetZ <= -25f) {
directionZ = 0;
}
if (-1f < offsetZ && offsetZ < 0) {
angleRotateZ = 0;
} else if (-13f <= offsetZ && offsetZ <= -1f) {
angleRotateZ -= angleZSpan;
} else {
angleRotateZ += angleZSpan;
}
break;
}
try {
Thread.sleep(10);//30
} catch (Exception e) {
// TODO: handle exception
}
}
}
}.start();
屏保控制线程
最新推荐文章于 2022-10-20 17:27:00 发布