java-mejsr179

Nokia N97 realted to orientation


Myself shweta dodiya.I am facing problem with nokia N97 related to change orientation for my game application. I am using J2me technology.I want to pause my application when i open my slider.

Thanks in advance


Solution

  • I don't know what code are you using, or are you using Canvas to draw the game on screen, or some other API that does that for you...

    If you have something like this GameScreen extends Canvas and you use GameScreen object to draw and display the game, you need to add an override to sizeChanged method to it and check the new width (w) and the new height (h) of the GameScreen, and do the things you want in regards to that:

    public void sizeChanged(int w, int h)
    {
        if(h > w)  //NORMAL
        {
            drawGame();
            if(paused) resumeGame();            
        }
        else  //LANDSCAPE
        {
            pauseGame();
            drawPauseScreen();
        }
    }
    

    This is a simple pseudo code, I hope you are getting the point. If statement is checking the relation between new width and the new height. If the phone is in landscape mode, H is less then W...