Apply AffineTransform to Slick2D?

[s]With, Java2D, I did like this:


	@Override
	public void draw(Graphics2D g) 
	{		
		AffineTransform transformer = new AffineTransform();
		transformer.translate(-(Math.min(stage.width-stage.visibleWidth,   Math.max(0, main.posX - stage.visibleWidth  / 2))), 
					     		  -(Math.min(stage.height-stage.visibleHeight, Math.max(0, main.posY - stage.visibleHeight / 2))));
		g.setTransform(transformer);
	//...
	}

This works perfect.
I tried similar in Slick2D:

@Override
	public void render(GameContainer gc, Graphics g) throws SlickException 
	{
		g.translate(-(Math.min(stage.width-stage.visibleWidth,   Math.max(0, main.posX - stage.visibleWidth  / 2))), 
						-(Math.min(stage.height-stage.visibleHeight, Math.max(0, main.posY - stage.visibleHeight / 2))));
	//...
	}

This however, did not work at all. The result was that every thing in the window was black.
How do I fix this?[/s]

EDIT: This was an mistake by me. translate works fine for slick2d

Why not use object.draw(x, y, 0.0f); , and then in the gameLoop, set the x and the y to the mouse location. :slight_smile:

I do not think that will be a good idea. I am trying to archive what I explained here:


Afaik, this can only be done with AffineTransform.