im currently making a gta style game, but ive come across a problem, which i cant figure out how to solve.
im trying to make it, so the character always stays in the middle of the screen i.e. the background moves instead, but i havent been able to figure out a way, to implement it.
Also note, that i still want the player to be able to rotate on the spot (so the background does not rotate), and then when the player moves forward or backwards, the background moves.
i only started construction of this game 10mins ago, but thought if i dont solve this problem now, it will only be harder to solve as i progress through the making of the game. The current code i have for the character is as follows:
onClipEvent(load){
movementSpeed=5
rotationSpeed=15
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) { this._rotation += rotationSpeed; }
if (Key.isDown(Key.LEFT)) { this._rotation -= rotationSpeed; }
if (Key.isDown(Key.UP)) {
this._y += movementSpeed*Math.cos((_rotation+180)*(Math.PI/180));
this._x -= movementSpeed*Math.sin((_rotation+180)*(Math.PI/180));
}
if (Key.isDown(Key.DOWN)) {
this._y -= (movementSpeed/3)*Math.cos((_rotation+180)*(Math.PI/180));
this._x += (movementSpeed/3)*Math.sin((_rotation+180)*(Math.PI/180));
}
}
so at the moment, the character rotates on the spot, and moves forwards and backwards.
thx for your help in advance⦠i hope :ne: