This site requires JavaScript, please enable it in your browser!
Greenfoot back
Herzensburger
Herzensburger wrote ...

2017/12/1

I keep getting this error "class, interface, or enum expected"

Herzensburger Herzensburger

2017/12/1

#
Here is the code that i am working with. The error appears on at every "int".
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
import java.util.*;
 
 
public class Explosion extends Actor
{
    /**
     * Act - do whatever the Explosion wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act()
    {
        // Add your action code here.
    }   
}
 
/**
 * An explosion. It starts by expanding and then collapsing.
 * The explosion will explode other obejcts that the explosion intersects.
 */
public class Explosion extends Actor{;
    /** How many images should be used in the animation of the explostion */
    private final static int IMAGE_COUNT= 1;
}
    /**
     * The images in the explosion. This is static so the images are not
     * recreated for every object (improves performance significantly).
     */
    private static GreenfootImage[] images;
     
    /** Current size of the explosion */
    private int imageNo = 0;
     
    /** How much do we increment the index in the explosion animation. */
    private int increment=1;   
     
    public Explosion() {
        initialiseImages();
        setImage(images[0]);       
        Greenfoot.playSound("Explosion.wav");
    }   
     
    /**
     * Create the images for explosion.
     */
    public synchronized static void initialiseImages() {
        if(images == null) {
            GreenfootImage baseImage = new GreenfootImage("explosion.png");
            int maxSize = baseImage.getWidth()/2;
            int delta = maxSize / (IMAGE_COUNT+1);
            int size = 0;
            images = new GreenfootImage[IMAGE_COUNT];
            for(int i=0; i < IMAGE_COUNT; i++) {
                size = size + delta;
                images[i] = new GreenfootImage(baseImage);
                images[i].scale(size, size);
            }
        }
    }
     
    /**
     * EXPLODE!
     */
    public void act()
    {
        if(imageNo > 0) {
            setImage(images[imageNo]);
        }
 
        imageNo += increment;
        if(imageNo >= IMAGE_COUNT) {
            increment = -increment;
            imageNo += increment;
        }
         
        if(imageNo <= 0) {
            setImage(new GreenfootImage(1,1));
        }
        if(imageNo <= -30) {
            ((Space) getWorld()).gameOver();
        }
    }
}
danpost danpost

2017/12/1

#
Remove all from lines 7 to line 24 except for line 23.
You need to login to post a reply.