-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEffect.java
More file actions
37 lines (34 loc) · 1.25 KB
/
Copy pathEffect.java
File metadata and controls
37 lines (34 loc) · 1.25 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
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
/**
* This is the effect class. This class will form some effects and disappear as time goes.
* Those effects will affect the ships.
*
* @author George Lu
* @version final 2023/4/1
*/
public abstract class Effect extends Actor
{
protected GreenfootImage image;
protected double transparency;
/**This method will control the transparency of the effect and the remain time. When remain time is zero, it will remove the effect.
*
* @param duration This is the total time it should show up the world
* @param remainTime This is the current remaining time of the object
* @param count This is the variable determines when should the object fade
*/
public void controlEffect(int duration, int remainTime, int count)
{
if(duration <= 0)
{
getWorld().removeObject(this);
}
else if(duration <= count)
{
transparency = ((double)(duration)/(remainTime));
int newTransparency = (int)(transparency * 255);
image.setTransparency(newTransparency);
}
}
//This make sures a stopPlay method for all effect class
public abstract void stopPlay();
}