Discussion Board

Results 1 to 2 of 2
  1. #1
    Regular Contributor
    Join Date
    Mar 2003

    URGENT - Graphic Not Printing (sometimes)


    I am having this problem with series60, 3660 in particular, phone. I have a routine that paints numbers, score, to the screen. Sometimes the score is printed, sometimes only a few didigts are painted and other times nothing is printed. Strange thing is, the other graphics on the screen paint with no problem.

    In the contructor i do:
    for (int i=0; i < 10; i++)
    numberImgs[i] = Image.createImage("/num"+i+".png");

    this stores all of the digit images.

    protected void paint(Graphics g)
    mmenuG.setColor(102, 51, 0);
    mmenuG.fillRect(0, 0, 176,208);
    if (menuitem == MAIN_MENU)
    else if (menuitem == INSTR_MENU)
    else if (menuitem == SOUND_MENU)
    else if (menuitem == GAME_OVER_MENU)
    g.drawImage(mmenu, 0, 0, Graphics.TOP|Graphics.LEFT);
    The above is the main paint() loop. I added the repaint() to try to fix the problem.

    private void gameovermenu()
    mmenuG.setColor(102, 51, 0);
    mmenuG.fillRect(0, 0, 176, 208);
    mmenuG.drawImage(mlabel, 176/2 - mlabel.getWidth()/2, 5, Graphics.TOP|Graphics.LEFT);
    mmenuG.drawImage(gameovr1, 176/2 - gameovr1.getWidth()/2, mlabel.getHeight() + 6, Graphics.TOP|Graphics.LEFT);
    mmenuG.drawImage(gameovr2, 176/2 - gameovr2.getWidth()/2, mlabel.getHeight()+6+gameovr1.getHeight()+5, Graphics.TOP|Graphics.LEFT);
    int x = 176/2 - gameovr2.getWidth()/2 + 84 + 10;
    int y = mlabel.getHeight()+6+gameovr1.getHeight()+5 + gameovr2.getHeight()/2 - numberImgs[0].getHeight()/2;
    int n = score;
    int d1 = n / 10000;
    n -= d1 * 10000;
    int d2 = n / 1000;
    n -= d2 * 1000;
    int d3 = n / 100;
    n -= d3 * 100;
    int d4 = n / 10;
    n -= d4 * 10;
    int d5 = n;
    mmenuG.drawImage(numberImgs[d1], x, y, Graphics.TOP|Graphics.LEFT);
    x += numberImgs[d1].getWidth();
    mmenuG.drawImage(numberImgs[d2], x, y, Graphics.TOP|Graphics.LEFT);
    x += numberImgs[d2].getWidth();
    mmenuG.drawImage(numberImgs[d3], x, y, Graphics.TOP|Graphics.LEFT);
    x += numberImgs[d3].getWidth();
    mmenuG.drawImage(numberImgs[d4], x, y, Graphics.TOP|Graphics.LEFT);
    x += numberImgs[d4].getWidth();
    mmenuG.drawImage(numberImgs[d5], x, y, Graphics.TOP|Graphics.LEFT);
    mmenuG.drawImage(ok, 176 - ok.getWidth(), 208-ok.getHeight() -1, Graphics.TOP|Graphics.LEFT);
    The above prints the score. sometimes all or none of the digits get printed.

    The game is threaded. The GameManager class manages the menu and start and stop of game threads. When a game over screen is need the game thread calls the gameManager function, via interface, to perform game over logic. The game over logic first sets a boolean variable in the game thread to force it to terminate. The the thead is set to null, and the game object is set to null. then I display the game over menu by setting the appropiate flag and calling, repaint(), serviceRepaints();

    the above gameovermenu() function is only called once, should I force it to be called twice? I tried that by adding 'repaint()' in paint().

    The error is occuring both on the phone and the emulator.

    I really need this problem solved because I am releasing this software this week.

    Thank you,

  2. #2
    Super Contributor
    Join Date
    Mar 2003
    I see you're drawing to an offscreen graphics context. Series 60 devices have a known issue: drawString only draws black strings on offscreen devices.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts