-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDisappearFX.java
More file actions
48 lines (39 loc) · 1.13 KB
/
Copy pathDisappearFX.java
File metadata and controls
48 lines (39 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
// Fade/disappear effect.
public class DisappearFX implements ImageFX {
private int x;
private int y;
private int width;
private int height;
private BufferedImage originalImage;
private BufferedImage currentImage;
private boolean active;
public DisappearFX(int xPos, int yPos, int w, int h, String imagePath) {
x = xPos;
y = yPos;
width = w;
height = h;
active = true;
originalImage = ImageManager.loadBufferedImage(imagePath);
if (originalImage != null) {
currentImage = ImageManager.copyImage(originalImage);
}
}
@Override
public void update() {
if (!active) return;
}
@Override
public void draw(Graphics2D g2) {
if (!active || currentImage == null) return;
g2.drawImage(currentImage, x, y, width, height, null);
}
public void setPosition(int xPos, int yPos) {
x = xPos;
y = yPos;
}
public BufferedImage getCurrentImage() {
return currentImage;
}
}