Slick Forums

Discuss the Slick 2D Library
It is currently Fri May 24, 2013 1:57 am

All times are UTC




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: setIcon() problems
PostPosted: Wed May 18, 2011 8:07 pm 
Offline
User avatar

Joined: Sun May 15, 2011 6:28 pm
Posts: 20
Location: Virginia
Ok, I've been looking around for an answer to this but haven't found anything specific to the problem I'm having. The API says the setIcon method takes in a String reference to the image but is there a restriction on the image type? I ask because I can't seem to get any icon to be set. My main method creates a AppGameContainer which calls a class called Game that extends BasicGame. I want to set the icon in the AppGameContainer right? Not the GameContainer in the init() method in Game? If I set it in AppGameContainer the default windows icon appears (not the lwjgl one) but the icon I specified doesn't appear. I'm on windows and am creating a java application, no web start or anything.


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 19, 2011 8:00 am 
Offline
Game Developer
User avatar

Joined: Thu Mar 03, 2011 6:22 pm
Posts: 534
Maybe your icon has the ending *.ico?

You may only use: PNG, GIF, JPG and 'TGA' (with some restrictions)

_________________
Current Projects:
Image Mr. Hat I
Image Vegan Vs. Zombies
Projects:
RadicalFish Engine - Build on top of Slick2D, Ideas, Bugs? Open an Issue ticket!


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 19, 2011 3:08 pm 
Offline
User avatar

Joined: Sun May 15, 2011 6:28 pm
Posts: 20
Location: Virginia
I've been trying .PNG, .GIF, and .JPG with no success, they set the icon and the default lwjgl one doesn't appear, but the one I set it to doesn't appear either. It's just the default windows no icon program icon.


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 19, 2011 3:20 pm 
Offline
Game Developer
User avatar

Joined: Thu Mar 03, 2011 6:22 pm
Posts: 534
well the file SHOULD BE a png. not just have the ending ;) And also is the size of your icon correct?

_________________
Current Projects:
Image Mr. Hat I
Image Vegan Vs. Zombies
Projects:
RadicalFish Engine - Build on top of Slick2D, Ideas, Bugs? Open an Issue ticket!


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 19, 2011 3:29 pm 
Offline
User avatar

Joined: Sun May 15, 2011 6:28 pm
Posts: 20
Location: Virginia
Yes, I am saving it as a .PNG in photoshop, it definitely is a .PNG. I noticed in the lwjgl javadocs it says Windows programs should provide both a 32x32 and 16x16 size icon. By providing both, does that mean you have to use setIcons(String[] refs) instead of just setIcon(String ref)? I've tried all combinations, using setIcons() with both sizes, setIcon() with a 32x32 .PNG, setIcon() with a 16x16 .PNG, still no luck. Only thing I can think of is that the icon image isn't being found for some reason, but using the same string ref I can assign it to an image, render it on the screen, and it'll show up fine.


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 22, 2011 9:41 pm 
Offline

Joined: Wed Apr 27, 2011 3:21 am
Posts: 7
Maybe I can help, I had this problem for a while too. What you need to do is save the files as *.tga files. Make sure you create one of each: 32x32, 24x24, and 16x16. Then you just do
Code:
app = new AppGameContainer( new Game() );
if ( app instanceof AppGameContainer )
{
   app.setIcons( new String[] {"32x32.tga", "24x24.tga", "16x16.tga"} );
}

where "NxN.tga" is the filename of the image relative to the working directory


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 23, 2011 2:19 am 
Offline
User avatar

Joined: Sun May 15, 2011 6:28 pm
Posts: 20
Location: Virginia
Still nothing, mind sending me an example of a working icon you know works? Maybe it's just CS5 or something.

EDIT: Ah, nevermind they have to be 32 bit .tga, not 24 bit. Thanks so much, finally got it working.


Top
 Profile  
 
 Post subject: Re: setIcon() problems
PostPosted: Sat Feb 18, 2012 5:13 am 
Offline
User avatar

Joined: Mon Oct 03, 2011 3:08 am
Posts: 10
Location: Australia
I've gotten a problem like this.
Code:
a.setIcons(new String[] {(getImageDataPath() + "icons/16.tga"), (getImageDataPath() + "icons/24.tga"), (getImageDataPath() + "icons/32.tga")});


the error
Code:
java.lang.RuntimeException: Resource not found: /project/images/icons16.tga


Thanks

EDIT: moving a.start() to before the setIcons call removed the crash, but the icons aren't showing either :/


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC


Who is online

Users browsing this forum: Bing [Bot] and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group