Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / December 2005

Tip: Looking for answers? Try searching our database.

Enigma (Or Programmer Ignorance)

Thread view: 
Luc The Perverse - 27 Dec 2005 05:51 GMT
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?

Signature

LTP

:)
szewong@gmail.com - 27 Dec 2005 05:55 GMT
Do MazeWalker.UP etc and you should be fine.
Luc The Perverse - 27 Dec 2005 06:02 GMT
> Do MazeWalker.UP etc and you should be fine.

I am an idiot

Thank you

--
LTP

:)
szewong@gmail.com - 27 Dec 2005 06:06 GMT
Glad to help.

Sze
http://www.zerionconsulting.com


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.