You’ll have to let me know if my question doesn’t belong here. I am doing java game programming, but the code is written in Ruby using JRuby. I figured you guys might still be a good place to find help.
I’m using the ScissorStack in libgdx to clip my map when the player enters a room. I have it working through trial and error, but when I zoom in on the map it ruins the clipping. I clearly don’t understand the whole ScissorStack calculate scissor process.
Here is the code where I setup the scissors:
@scissor.x = (@player.room.x - @cam.position.x) * C::TILE_SIZE + Gdx.graphics.width / 2
@scissor.y = (@player.room.y - @cam.position.y) * C::TILE_SIZE + Gdx.graphics.height / 2
@scissor.width = @player.room.width * C::TILE_SIZE
@scissor.height = @player.room.height * C::TILE_SIZE
ScissorStack.push_scissors(@scissor)
The @player.room object is a libgdx Rectangle that is in tmx map units, and it corresponds to the player’s current room outline. As long as I don’t change the @cam.zoom this seems to clip correctly. I’ve tried using the calculateScissors method, the toWindowCoordinates method, and the camera’s unproject method. And a bunch of permutations of those methods.