Menu Sliding Variables

So, in my game, I like to put all kinds of little sliders and faders to make the UI sexy as possible. One problem I’ve come to though is the massive amount of variables at the top of classes used to control these. I mean, look at this:

	int currentMode = 0;
	boolean battleStart = true;
	
	int select = -1;
	boolean subMenuOn = false;
	
	int textScroller = 0;
	int textScroller2 = 0;
	int textCapicitor = 0;
	
	int battleBoxScroller = 0;
	int commandScroller = -500;
	
	int mugshotScroller = 100;
	int mugshotScroller2 = 140;
	

It’s not really massive, but generally it get’s a LOT longer.

Is there some way to make temporary variables in looped methods without them being reinitialized at the next step? Just curious. I’d like to know for future reference.

Not sure what you ask but… The variable list must be somewhere in the end, be it part of the object or locally created within a method or a set of { }. But you won’t get rid of the “long list”. Think about their use and the desired disponibility within the project.

To try to answer your question [quote]Is there some way to make temporary variables in looped methods without them being reinitialized at the next step?
[/quote]
I would have to say that initialize them outside the loop, like this:


boolean loop=true;
int x=0;
int j=100;
int n=0;
while(loop){
   x=j+n;
   j-=1;
   n++;
   if (n>j){
      loop=false;
   }
}

Maybe what you need is initialize all the object variables in its constructor?

public class myclass{
   private int x;
   public int n;
   
   public myclass(int number){
   this.x = number;
   this.n = number - 10;
   }
}

I think others may give you a better answer, I hope you get your doubts cleared soon! :smiley: