Jump to content

onPaint() fps drop


Recommended Posts

Posted

Organise your code a little bit more.. seems like a mess there. That being said I don't think your onPaint() is causing that but might be due to your getState() in there(Just a guess).

 

The only time this occurred to me was when I tried to render multiple things whilst running but that's understandable.

Posted

For one why are you even call the getState() in paint?

 

Because if your doing that to get the status/state, that is a horrendous way of doing. Your onPaint is called every loop, so that means your calling your getState every second pretty much, for the how ever long you run your script, that will really start to add up.

 

At the top of your script you should declare a String like:

String status = "";

 

Then in you onLoop, inside of your switch statment, whatever state is called, add what status, so like:

switch(getState()){
     case ATTACK:

               status = "Attacking";

               break;

}

 

The finally in your onPaint, take out getState, and replace it with status.

 

See if that helps, and even if it doesn't, that still a much more efficient way of achieve the same goal.

(If it still lags, most likely there's some type of error in your getState like @Booch said)

  • Like 1
Posted

Should be getState().toString() buddy happy.png

You should not be so stupid, buddy.

For one why are you even call the getState() in paint?

 

Because if your doing that to get the status/state, that is a horrendous way of doing. Your onPaint is called every loop, so that means your calling your getState every second pretty much, for the how ever long you run your script, that will really start to add up.

 

At the top of your script you should declare a String like:

String status = "";

 

Then in you onLoop, inside of your switch statment, whatever state is called, add what status, so like:

switch(getState()){

     case ATTACK:

               status = "Attacking";

               break;

}

 

The finally in your onPaint, take out getState, and replace it with status.

 

See if that helps, and even if it doesn't, that still a much more efficient way of achieve the same goal.

(If it still lags, most likely there's some type of error in your getState like @Booch said)

 

 

Even better.

 

State state;

 

onLoop()

{

state = getState();

switch(state){

case StateY:

//some code

break;

}

 

}

 

then in onPaint just draw state instead of getState()

  • Like 1
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...