Home Help Search Login Register


J2meForums  |  General Category  |  Devices that support j2me technology (Moderator: mikkom)  |  Topic: No sprite support? « previous next »
Pages: [1] Print
Author

No sprite support?

 (Read 220 times)
unme
New user
*
Posts: 4



View Profile
No sprite support?
« on: July 05, 2010, 06:52:46 pm »

Hi!

I've programmed a little application for my cell phone that only draws an animated sprite on my screen. Here's an excerpt of the code: (I've cut out some unimportant things)

Code:
//Importing packages


class Level1 extends Canvas {
  Display display;
  Image offscreen;
  boolean firstrun = true;
  Player player;

  Level1 (Display display) {
    this.display = display;


    if (!isDoubleBuffered () && false)
      offscreen = Image.createImage (getWidth (), getHeight ());
    }

  public void paint (Graphics g) {

    Graphics g2 = offscreen == null
      ? g
      : offscreen.getGraphics ();

   
    if (firstrun) {
       try {Thread.sleep(1000);} catch (InterruptedException ex) {}
        try
        {
           player = new Player(Image.createImage("/Player/RunSprites.png"));
        }
        catch (Exception e)
        {
           System.out.println("Unable to read PNG image");
        }
       firstrun = false;
    }
    g.setColor (0, 200, 200);
    g.fillRect (0, 0, getWidth (), getHeight ());
    player.nextFrame();
    player.paint(g);   

    if (offscreen != null)
      g.drawImage (offscreen, 0, 0, Graphics.TOP | Graphics.RIGHT);

    try {Thread.sleep(100);} catch (InterruptedException ex) {}
    repaint();
  }
}

class Player extends Sprite {

  Sprite player;
  Image runsprites;

  public Player (Image image) {

    super(image,80,120);
    setPosition(50,50);
    setRefPixelPosition(40,120);
    setFrameSequence(new int[] {0,1,2,3,4,5,6,7,8,9});

  }
}


public class GH extends MIDlet {

Player player;

  public void startApp () {

    Display display = Display.getDisplay (this);


     Level1 logo = new Level1(display);
     display.setCurrent(logo);

  }

  public void pauseApp () {

  }

  public void destroyApp (boolean forced) {
  }

}

In the emulator of the WTK everything works well. But when I create a jar of the image and the code and put it on my mobile phone, a LG KC550, the right background color appears but there is no sprite.
Can it be that this phone does support MIDP 2.0 (MIDP configurations) but does not support sprites?
Or did I do something wrong?

Thanks for your help!  Smiley
Logged
Claymore
Global Moderator
J2me god
*****
Posts: 4978


Quantity != Quality


View Profile WWW
Re: No sprite support?
« Reply #1 on: July 05, 2010, 07:52:18 pm »

Check the filename of your png - most phones are case sensitive (.png is different to .PNG) whereas your PC won't be
Logged

unme
New user
*
Posts: 4



View Profile
Re: No sprite support?
« Reply #2 on: July 06, 2010, 05:25:46 pm »

Thanks for your answer!

I've checked the filename of my image and it's right. I've also tried to load an image not as a sprite but as a simple image and then draw it on the screen. That worked but there is still no sprite.
I've played some games on that phone and they worked although they contained a controllable player figure that really looked like a sprite...
Logged
unme
New user
*
Posts: 4



View Profile
Re: No sprite support?
« Reply #3 on: July 11, 2010, 11:32:50 am »

Well, I've found the problem.
I've saved the sprite image via Gimp in the interlaced mode. The computer supports it but not the phone.
After loading the image into Photofiltre and saving it without interlacing it worked.
Logged
Pages: [1] Print 
J2meForums  |  General Category  |  Devices that support j2me technology (Moderator: mikkom)  |  Topic: No sprite support? « previous next »
Jump to:  


Login with username, password and session length

Powered by MySQL Powered by PHP J2meForums | Powered by SMF 1.0.8.
© 2001-2005, Lewis Media. All Rights Reserved.
Valid XHTML 1.0! Valid CSS!