代码演示
package com.arvin;
import java.awt.image.BufferedImage;
public class Obstacle implements Runnable{
private int x; private int y;
private int type;
private BufferedImage show = null;
private BackGround BackGround = null;
private Thread thread = new Thread(this);
public Obstacle (int x, int y, int type, BackGround BackGround) { this.x = x; this.y = y; this.type = type; this.BackGround = BackGround; show = StaticValue.Obstacle.get(type);
if (type == 4){ thread.start(); } }
public int getX() { return x; }
public int getY() { return y; }
public int getType() { return type; }
public BufferedImage getShow() { return show; }
@Override public void run() { while(true){
if (this.BackGround.isReach()) { if (this.y < 374) { this.y += 5; }else { this.BackGround.setBase(true); } }
try { Thread.sleep(50); } catch (InterruptedException exception) { exception.printStackTrace(); }
} } }
|
版權聲明: 此文章版權歸Arvin所有,如有轉載,請註明來自原作者