# switch between player camera/non-camera positioning

Sorry if this sounds ambiguous. But I am writing a traditional top down game. And normally the player would be centered in the middle while moving the orthographic camera. However, I would like this to be dynamic. Therefore, use player.setPosition(x,y) near screen boundaries but center on player if its far from screen boundary.

This is some sample code:

public void centerCamOnPlayer() {
camera.position.set(player.getX() + (player.sprite.getOriginX()),
player.getY() + (player.sprite.getOriginY()),
0);
}

public void update() {
boolean shouldCenterOnChar = ???;
if (shouldCenterOnChar) {
centerCamOnPlayer();
} else {
player.setPosition(x,y);
}
}


Therefore render will call update(). However how do I determine the shouldCenterOnChar? I tried using frustum.pointInFrustum but its only when the sprite moves completely out of screen. I'm sure there is a better way to switch dynamically. Any one has an idea? Tks!

camera.position.set(clamp(player.getX() + (player.sprite.getOriginX()),