Enigma (Or Programmer Ignorance)

L

Luc The Perverse

I have a class - it starts like this (the rest of the class is irrelevant)

class MazeWalker extends AdvanceSprite{
public static final int STILL = 0, MOVING = 1, WALKING=0, RUNNING=2;
public static final int LEFT = 1, RIGHT = 2, UP = 3, DOWN = 4;
. . .


I have an instantiation of the class called Heina

In another function in another class I am trying to implement this.

boolean okToFire = (timer==null) || timer.action(elapsedTime);
if (okToFire)
if(keyDown(KeyEvent.VK_SPACE)) {
switch(Heina.getDirection()){
case Heina.UP:
GOODBULLETS.add(new GoodBullet(getImages("Projectile.png",
2,1),Heina.getX()+Heina.getWidth()/2, +Heina.getY(),
Heina.getHorizontalSpeed(), -0.8+Heina.getVerticalSpeed()));
break;
case Heina.DOWN:
GOODBULLETS.add(new GoodBullet(getImages("Projectile.png",
2,1),Heina.getX()+Heina.getWidth()/2, +Heina.getY()+Heina.getHeight()/2,
Heina.getHorizontalSpeed(), 0.8+Heina.getVerticalSpeed()));
break;
case Heina.LEFT:
GOODBULLETS.add(new GoodBullet(getImages("Projectile.png",
2,1),Heina.getX(), +Heina.getY()+Heina.getHeight()/2,
Heina.getHorizontalSpeed()-0.8, Heina.getVerticalSpeed()));
break;
case Heina.RIGHT:
GOODBULLETS.add(new GoodBullet(getImages("Projectile.png",
2,1),Heina.getX()+Heina.getWidth(), +Heina.getY()+Heina.getHeight()/2,
Heina.getHorizontalSpeed()+0.8, Heina.getVerticalSpeed()));
break;


}
timer = new Timer(800);
}
else
timer=null;

But I get the error message
"Constant expression required" for each of my case statements. Doesn't my
declaration make those values constant?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top