In this entry we will make the camera follow the player when is near the edge of the screen, and also add a automatic camera movement if the player started reaching the mid section of screen, and push the player as the camera moves if the player hits the left side of screen, similar to old games .
We need 1 sprite call it player and add platformer behavior on it and a local variable named oldX.
1 tiled background call it whatever you want i usually go with ground and give it a solid behavior so the player has something to stay on
next we place the tiledbackground in the screen and the player i did arrange the tiledbackground a bit different and you can also do a similar construction if you by following the bellow image if not a simple straight floor would work also.
Moving on the event sheet
we need 1 Global variable and we call it ScrollTrigerDist and here we give it a 300 pixels this will be our distance measure when we trigger the camera to follow the player, you can change it to 200 500 100 whatever you like to suit your needs.
If you don't want the automatic camera pan then that concludes the entire tutorial and you should have something similar to the bellow image
Now if you want the screen the start moving after the player reaches half of the screen and then the camera to continuously move to right side while pushing the player if is on left edge of camera. We add a 2nd global variable and call it Trigger value 0.
And disable/remove the 1st two events on Line 1 and 2 in the above picture.
And then we add the following events
Now to push the player with the camera we add the following event
And you should have something like the bellow image.
And this would conclude this short two pieces example. Don't worry as always there's a download link at the bottom of the page.
"File me" - Download