Hello,
I have a question I need to ask, the game I making demands that I control eleven characters, each character I control have to have the camera focused on the character. The screen is composed of four borders, one to the left, one to the right, one above and one down. When the character moves to the edge of either the four screens, the screen should scroll in the reverse direction that the character is heading. Let us say for example the character is moving to the edge of the right screen, then the level should scroll into the left and so on. This works correctly when the game focuses or the camera during the initial of the level focuses on the main character and it is centered into the screen. The problem happens when the user pushes the button to tell the game to control the next player and the camera focuses on the next player. When the camera focuses on the next player it is no longer centered in the screen regardless of te location of player, so what happens that the screen up scrolling when the character is not neve close to the edge of screen. By click here you get to see a video example of what I am talking about, it is a live feed of my game in action and the problem that it is arising with. Now originally the code I use to set the focus of the camera is like this:
camera.position = animatedPlayer[x].position;
That sets the X, Y coordinate of the camera to be the same as the player's X and Y corrdinate. The size of the actual map is 510 by 510, however the size of the actual window or viewPort or Windows resolution is 800 by 600. When the player (even though the map size is 510 by 510) reaches to the edge of the screen resolution which is 800 by 600 the screen scrolls. That is why I use an if statement to determine wether the player have reached the edge of the screen, if the player reaches the edge of the screen which is by 800 to 600 the screen or level scrolls accordingly. However, that remains on the position 0,0 where the height and width is 800 by 600. If the camera loses focus on the default player or the actual camera have set it's focus on the new player it is no longer centered, so what happens is that sometimes the player have to move outside the edge of screen and MORE AND MORE and more before the screen starts scrolling, because the camera is no longer following the player. Any suggestions on this matter.
