- 13.5k
- 10
- 56
- 82
YouDivide the position of each layer by the "distance" you want it to createhave from the camera.
For example: Create a couple of variables representingto represent the camera position, - cameraXcameraX
and cameraYcameraY
. You then want to setSet these to equal the position of your character, possibly adding on a bit extra in the direction of movement.
To position theThe main layer, it's would just: be positioned at
mainLayer.x = -cameraX;
mainLayer.x = -cameraX;
for the middle layer, at something like:
middleLayer.x = -cameraX * 0.5;
middleLayer.x = -cameraX * 0.5;
forand the far layer: at
farLayer.x = -cameraX * 0.2;
farLayer.x = -cameraX * 0Change the constants as needed.2;
You want to create a couple of variables representing the camera position - cameraX and cameraY. You then want to set these to equal the position of your character, possibly adding on a bit extra in the direction of movement.
To position the main layer, it's just:
mainLayer.x = -cameraX;
for the middle layer, something like:
middleLayer.x = -cameraX * 0.5;
for the far layer:
farLayer.x = -cameraX * 0.2;
Divide the position of each layer by the "distance" you want it to have from the camera.
For example: Create a couple of variables to represent the camera position, cameraX
and cameraY
. Set these to equal the position of your character, possibly adding on a bit extra in the direction of movement.
The main layer would just be positioned at
mainLayer.x = -cameraX;
the middle layer at something like
middleLayer.x = -cameraX * 0.5;
and the far layer at
farLayer.x = -cameraX * 0.2;
Change the constants as needed.
You want to create a couple of variables representing the camera position - cameraX and cameraY. You then want to set these to equal the position of your character, possibly adding on a bit extra in the direction of movement.
To position the main layer, it's just:
mainLayer.x = -cameraX;
for the middle layer, something like:
middleLayer.x = -cameraX * 0.5;
for the far layer:
farLayer.x = -cameraX * 0.2;