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

2020/10/12

Add obj

1
2
3
danpost danpost

2020/10/13

#
Roshan123 wrote...
Do i need to make another world
Only for Help option.
Roshan123 Roshan123

2020/10/13

#
But i want to decrease the lag Is their any other option
danpost danpost

2020/10/13

#
danpost wrote...
// line 18
    return;
Insert before that line:
timer = 0;
Roshan123 Roshan123

2020/10/13

#
Roshan123 wrote...
But i want to decrease the lag Is their any other option
I mean without making another world
Roshan123 Roshan123

2020/10/13

#
Oh sorry help is not a png Its a actor I apologise for this mistake
Roshan123 Roshan123

2020/10/13

#
If 2 is pressesd Then it will add help class
danpost danpost

2020/10/13

#
Roshan123 wrote...
But i want to decrease the lag Is their any other option
This should not effect any lag, in itself. Hardly any actions will be running during the time Help is up. Only waiting for key press or mouse click to return back to game world.
Roshan123 Roshan123

2020/10/13

#
danpost wrote...
Sounds like using getKey would be a better option -- and once a key is accepted, do not accept any more. Also, using separate worlds for each option would help. Passing "this" to Help world will allow a return to this world; and passing a boolean value to Game world will inform of using a Bot actor or a secondary Tank actor. Something like this:
// global
private String key;
private int timer;

// in act
if (key != null)
{
    if (++timer == 100)
    {
        switch ("1234".indexOf(key))
        {
            case 1:  Greenfoot.setWorld(new MyWorld()); break;
            case 2:  Greenfoot.setWorld(new Help(this)); break;
            case 3:  Greenfoot.setWorld(new Game(true)); break;
            case 4:  Greenfoot.setWorld(new Game(false)); break;
        }
    }
    return;
}
key = Greenfoot.getKey();
if (key != null && "1234".indexOf(key) < 0) key = null;
Will the given condition decrease the lag
danpost danpost

2020/10/13

#
Roshan123 wrote...
<< Quote Omitted >> Will the given condition decrease the lag
I do not currently know the source of your lagging. All I know is that the quoted code only does things when needed (not prematurely or repeatedly). Also, since there is a "delay" timer, any lag would be unnoticeable.
Roshan123 Roshan123

2020/10/13

#
Will it decrease by adding certain classes like what i m doing now I mean if 3 is pressed then it will add certain classes Note that i m not deleting any classes I m just adding certain classes by giving condition Before that it added all the classes Is it a waste of time or will it decrease by adding certain classes??? Note: My loops are not more then 3 loops If Else if Else I only used if
Roshan123 Roshan123

2020/10/13

#
danpost danpost

2020/10/13

#
It is not normally the adding or deleting of classes that cause lag. Usually is it either an over-abundance of actors, image manipulations or processes. As far as the mentioned looping, it may not be as readily apparent as "if / else if / else". It does not need to be "while", "for", or "do", either.
Roshan123 Roshan123

2020/10/13

#
Scenario 750 kb Images below 550 kb No sound
Roshan123 Roshan123

2020/10/13

#
No gif or animated images
danpost danpost

2020/10/13

#
Roshan123 wrote...
Scenario 750 kb Images below 550 kb No sound
Maximum number of actors in world at any one time?
There are more replies on the next page.
1
2
3