Slick Forums

Discuss the Slick 2D Library
It is currently Mon Nov 20, 2017 7:10 pm

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Sun Aug 27, 2017 1:47 am 
Offline

Joined: Sun Aug 27, 2017 1:41 am
Posts: 2
I'm trying to draw the image of my player in the game, and it works for the most part, but there's a miniscule detail that's nagging at me. When I draw the player's image, some white pixels appear around the edges of the sprite that haven't appeared there when I've drawn it before.

This problem has only started occurring now that I've started to apply a rotation to the player sprite. Can rotations cause issues with this? Here is the drawing code in question.

Code:
@Override
public void render(Graphics g, long cTime) {
   getCurrentWeapon().render(g, cTime);
   
   Image image = getImage();
   if(image != null) {
      g.rotate(position.x, position.y, (float)Math.toDegrees(theta));
      g.drawImage(image, (position.x - (image.getWidth() / 2)),
                     (position.y - (image.getHeight() / 2)));
   } else {
      // Draw a shape to represent the missing player image.
      g.setColor(Color.red);
      g.fillOval((position.x - 20), (position.y - 20), 40, 40);
   }
}


And here is what is being drawn on the screen.

I'll say again. These white pixels were NOT present before I started drawing it this way, using the rotation.


Top
 Profile  
 
PostPosted: Tue Sep 05, 2017 3:28 pm 
Offline
Regular

Joined: Mon Dec 08, 2008 2:17 pm
Posts: 160
Hi packetpirate,

A similar question has been asked here

The reply of davedes has 3 solutions, check it out and tell us if one of them worked out for you :)


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 5 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