mirror of
https://github.com/Noratrieb/Java2DGame.git
synced 2026-01-14 14:05:01 +01:00
debug lifetime
This commit is contained in:
parent
81855c6a6d
commit
c919d1490b
2 changed files with 14 additions and 0 deletions
|
|
@ -9,10 +9,19 @@ import java.awt.*;
|
|||
* A GameObject used for debugging
|
||||
*/
|
||||
public class DebugPos extends GameObject {
|
||||
|
||||
private final long lifeTime;
|
||||
private long spawnTime;
|
||||
|
||||
public DebugPos(Vector2D position, Vector2D size) {
|
||||
this(position, size, Long.MAX_VALUE);
|
||||
}
|
||||
|
||||
public DebugPos(Vector2D position, Vector2D size, long lifeTime) {
|
||||
super(position.copy(), size);
|
||||
this.velocity = new Vector2D();
|
||||
this.mainColor = Color.GREEN;
|
||||
this.lifeTime = lifeTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -22,5 +31,10 @@ public class DebugPos extends GameObject {
|
|||
|
||||
@Override
|
||||
public void update() {
|
||||
long current = System.currentTimeMillis();
|
||||
if (current - spawnTime > lifeTime) {
|
||||
destroy();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue