-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCredits.java
More file actions
46 lines (42 loc) · 1.09 KB
/
Credits.java
File metadata and controls
46 lines (42 loc) · 1.09 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
import greenfoot.*;
import java.util.regex.*;
/**
* Dis be where da credits will be from.
* Gon' be fade-in-fade-out.
*
* @author James Thomas Gryder III
* @version 04/28/2015
*/
public class Credits extends World
{
// keep track of what the current image number is to change it
private int creditPage = -1;
/**
* Constructor for objects of class Credits
*/
public Credits(String path)
{
super(526, 590, 1);
// construct the initial image yo
Matcher matcher = Pattern.compile("\\d+").matcher(path);
matcher.find();
creditPage = Integer.valueOf(matcher.group());
setBackground(path);
}
/**
* Change the pictures yo
*/
public void act() {
String nextPage = "images/credits/credits" + (creditPage + 1) + ".png";
GreenfootImage bg;
if(creditPage++ < 1) {
Greenfoot.delay(200);
bg = new GreenfootImage(nextPage);
bg.scale(526,590);
setBackground(bg);
}
else {
Greenfoot.stop();
}
}
}