I’m looking for any samples/example relating to a side scroller. Setting up an actor with camera attached to it.
Thx [import]uid: 7177 topic_id: 1367 reply_id: 301367[/import]
I’m looking for any samples/example relating to a side scroller. Setting up an actor with camera attached to it.
Thx [import]uid: 7177 topic_id: 1367 reply_id: 301367[/import]
I’m not quite sure if there’s sample code for that lying around anywhere.
However, a good place to start is Display Groups
Read up on them here
You could have a display group called dgGame, in which you place all of the objects on the screen.
This could act as your camera.
For example, if the player (let’s call him “Mario”) moves to either side of the screen the camera moves.
In your code you’d check if Mario’s X is either less than somewhere around 20. If so, move dgGame to the left.
You’d do something similar for moving the “Camera” (dgGame) to the right.
There are probably better ways of doing this, but that’s my take on the situation =) [import]uid: 7366 topic_id: 1367 reply_id: 3774[/import]
DisplayGroups are a good pointer…
But first you need to choose how wide your scene is and what it contains.
There are 2 basic ways to do it:
You place your world into a “frame” and move that behind the “screen” window. As the maximum width of textures are limited you need to do something where your playfield either “jumps” back… or you use 2 groups and move the one which is fully off-screen back in to the other side. This way the object movement is only relative to the world it lives in.
All objects are moved by themselves and you use coordinates bigger or smaller (negative) to create the illusion of “endless” movement. The object movement is relative to the camera.
You can also use a combination of 1 and 2 … for example having a landscape (enemies) scrolling by in the background but the objects are local.
It is pretty nice to use the “Stage Bounds” to find where which object is on the screen. [import]uid: 6928 topic_id: 1367 reply_id: 3779[/import]
Great! Thanks for the info:
[import]uid: 7177 topic_id: 1367 reply_id: 3781[/import]