30/09/2018, 22:40
Thread trong Java
public void run() {
while (true) {
try {
Thread.sleep(27);
Iterator<Enemy_plane> enemy_planeIterator = enemy_planeVector.iterator();
while (enemy_planeIterator.hasNext()) {
Enemy_plane enemy_plane = enemy_planeIterator.next();
enemy_plane.y += 10;
if (enemy_plane.y >= 600) enemy_planeIterator.remove();
}
Iterator<Bullet> bulletIterator = bulletVector.iterator();
while (bulletIterator.hasNext()) {
Bullet bullet = bulletIterator.next();
bullet.y -= 10;
if (bullet.y <= 110) bulletIterator.remove();
}
repaint();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
Các bác cho em hỏi có cách nào để trễ đoạn
Iterator<Enemy_plane> enemy_planeIterator = enemy_planeVector.iterator();
while (enemy_planeIterator.hasNext()) {
Enemy_plane enemy_plane = enemy_planeIterator.next();
enemy_plane.y += 10;
if (enemy_plane.y >= 600) enemy_planeIterator.remove();
}
thêm 1s không ạ?
Bài liên quan
Bỏ vào block code đi bạn, để vầy khó đọc quá
This post was flagged by the community and is temporarily hidden.