File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Game Development and the fly likes icons facing in wrong direction Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Game Development
Bookmark "icons facing in wrong direction" Watch "icons facing in wrong direction" New topic
Author

icons facing in wrong direction

Marc Beck
Ranch Hand

Joined: Sep 09, 2006
Posts: 36
I have the problem that my icon faces left when moving up or down. It faces however in the correct direction when moving left and right.

Bill Cruise
Ranch Hand

Joined: Jun 01, 2007
Posts: 148
It looks like you're just loading different images for the four directions. Did you check the files to make sure the image you expect is there? It may just be that the North and South images are the same as the West, and only the East image was changed.

Why don't you just load one image and rotate it?
Marc Beck
Ranch Hand

Joined: Sep 09, 2006
Posts: 36
I checked all the images and they are the correct ones. Rotating sounds like a good idea, I just don't know the code for it.
Bill Cruise
Ranch Hand

Joined: Jun 01, 2007
Posts: 148
I was thinking in Python when I suggested it. I wrote a blog post about it if you care to learn.

Rotate an Image in Java
Marc Beck
Ranch Hand

Joined: Sep 09, 2006
Posts: 36
I copied the applet and ran it from a html file, but nothing happened. It only says 'applet RotateImage started', but nothing appears on screen. I tried it with a jpg first and then with a png.I am sure that I spelled the names of the pictures right.
Bill Cruise
Ranch Hand

Joined: Jun 01, 2007
Posts: 148
Thanks. I checked it out and found a bug in the code that loads the image. The init method body should be
Marc Beck
Ranch Hand

Joined: Sep 09, 2006
Posts: 36
Now I am getting a picture. I will play around with it over the weekend and see what I can do with it. Thanks for your help.
Marc Beck
Ranch Hand

Joined: Sep 09, 2006
Posts: 36
I am still having problems. For some reason it worked when I tried it a week ago and I got a picture, but now when I run the applet it is blank. When I click refresh, the area where the picture is supposed to be flickers.
Bill Cruise
Ranch Hand

Joined: Jun 01, 2007
Posts: 148
You need to translate the image either right before or right after you rotate it. In the code that I started with, call:

trans.translate(x, y);

Where x and y are the amount you want to move the image. I'd start with the width and height of your image and play around from there to see how it works.
Marc Beck
Ranch Hand

Joined: Sep 09, 2006
Posts: 36
I tried it and it did not help. Must be something really simple, but I just don't get to it.
That is what the code looks like:

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: icons facing in wrong direction