×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    May 2005
    Posts
    2

    How do i load up my sprites?

    I know this is a stupid question but, i can't seem to get the nokia toolkit to load up the sprites for my game.

    Image homeImage = Image.createImage("/home.png");
    homeSprite= new Sprite (homeImage);


    Image backgroundImage = Image.createImage("/bg.png");
    backgroundSprite = new Sprite (backgroundImage);

    layerManager = new LayerManager();
    layerManager.append(homeSprite);
    layerManager.append(backgroundSprite);

    and they are in the main directory. Am i doing something wrong?
    I tryed adding the files into resources tab of the aplication creator, but the files do not apear.

  2. #2
    Regular Contributor
    Join Date
    Mar 2005
    Posts
    249
    First off, not stupid question. I spent a while figuring where to load my images.

    What do you mean by main directory? When I upload images, I copy them into my source folder, and compiler finds them there.
    ie. "... /GameApp/src/spritefile.png"

    Then use
    Image homeImage = Image.createImage("/spritefile.png");


    If your image is located in a package (ie. .../GameApp/src/package/spritefile.png), You will need to specify the folder it's in.

    Image homeImage = Image.createImage("/package/spritefile.png");

    Don't know if it works any diff in the nokia toolkit, but I doubt it would.

    Hope this helps.

    Cheers.

  3. #3
    Registered User
    Join Date
    May 2005
    Posts
    2
    Still no luck, i have tried all kinds of locations, it just never seems to load it into the jar. I have even specfied the complete path from my harddrive. Any other ideas.

  4. #4
    Super Contributor
    Join Date
    Mar 2003
    Location
    Israel
    Posts
    2,280
    The location depends on your dev environment.

    But still, remember that you can open jars with any zip utility, and manually add the images. Just remember to change the jar size fields in the jad and the manifest (in META-INF inside the jar) accordingly.

    Also, filenames are case-sensitive so if the file is named image.PNG and you use createImage("/image.png") then it won't load.

    shmoove

Posting Permissions

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