Hey all,
New here, but the community seems great. As the title says, I’m trying to use a JScrollPane as a camera in my game. My main problem is that I can’t center the camera on the player. I can make the camera scroll when the player hits the edge with scrollRectToVisible(), but even that breaks after a bit, allowing the character to walk off screen. A good example of what I’m trying to do is Notch’s Left 4k Dead. I looked at the source for that, but everything seems to be somewhat hacked together. I have looked at the Java API for methods that would help me follow the player but none of them seem to work. I’ve toyed around with changing the underlying JViewPort but that didn’t work either.
Any help would be appreciated with this problem.