Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

icons facing in wrong direction

 
Marc Beck
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic