Slick Forums

Discuss the Slick 2D Library
It is currently Wed Oct 17, 2018 10:23 pm

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Sat Feb 18, 2012 8:53 am 
I don't no if anyone experiences this problem, but I really want an Image.drawCentered method. Currently, when drawing my character, I have to divide its width/height by 2, and then use that as the render position. I do this quite alot throughout my code, and others probably do too. I was wondering if I could implement an Image.drawCentered function.

Example:

Code:
/**
Draws the image at it's center
@author liamzebedee
@param x The x co-ordinate to draw the [centered] image at
@param y The y co-ordinate to draw the [centered] image at
*/
public void drawCentered(float x, float y) {
   this.draw(x - (this.getWidth() / 2), y - (this.getHeight() / 2));
}


Top
  
 
PostPosted: Sat Feb 18, 2012 1:10 pm 
Offline
Game Developer
User avatar

Joined: Thu Mar 03, 2011 6:22 pm
Posts: 534
an easier way is to just don't snap your entities to the center :) I always use the top left corner as the postion to draw. I always thought this was the right way :D

_________________
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  
 
PostPosted: Sat Feb 18, 2012 6:53 pm 
Offline
Slick Zombie

Joined: Sat Jan 27, 2007 7:10 pm
Posts: 1482
Is this what you're looking for?
http://hg.antonoff.info/kevglass/slick/ ... ava#cl-535


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


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:  
cron
Powered by phpBB® Forum Software © phpBB Group