Tag Info

New answers tagged

0

If you want it to be in update, you can use the setCenterX and setCenterY methods. mouseImage.setCenterX(Mouse.getX()); mouseImage.setCenterY(Mouse.getY()); However Y coordinates are going to be reversed. If you want them to correspond to proper ones you can do: mouseImage.setCenter(container.getInput().getMouseY());


0

I got around my problem by re-writing my code to remove ComponentListener. Doing this I got a single response to a left-click (or right-click). This doesn't differentiate between left or right-clicks - it just picks up clicks, but that works for me. My test code is posted below. package testslick2dbutton; import java.util.logging.Level; import ...


0

In my experience the AbstractComponent section of slick has some problems. I am quite sure there are some bugs and so I stopped using it. The rest of the slick framework seems to work fine though. Try alternatives like Nifty GUI which is compatible with slick


1

This is most likely a rounding error. I'm guessing that x and y are ints. Keeping track of the x and y values as floats, I expect will fix the issue. Consider if the values are being floored: Moving Left 10 - 1.6 = 8 Moving Right 10 + 1.6 = 11


0

You can useDisplay.getWidth() / 2 - (Your truetypefont).getWidth(your text) / 2 to center it horizontally


1

You should read the Javadocs for Slicks TrueTypeFont. It has a Method public int getWidth(java.lang.String whatchars) to get the width of a particular String. To draw perfectly centered it is then simply int positionX = (windowWidth - textWidth) / 2;



Top 50 recent answers are included