Rotating screen not centered on player{SOLVED}


(billy2000) #1

Hai. So i have been playing with the RotatingWorld made by @zachwlewis in his tutorial and i did a code for my needs. But for some kind of weird reason the screen wont have the center on player’s center when its rotating.All the code is in my world so here it is:

override public function update():void
	{
		super.update();
		
		rotateTheWorld();
		
	}
	//lets rotate the world now
	public function rotateTheWorld():void
	{
		player = FP.world.getInstance("player");
		player.t.text = "cx: " + FP.screen.originX + " cy: " + FP.screen.originY;
		centerScreenAt(player.x, player.y);
		
		if (FP.screen.angle % 180 == 0) {
			
			if(Input.pressed(Key.SPACE)){
				//upwards = !upwards;
				
				FP.screen.originX = player.x;
				FP.screen.originY = player.y;
				angle += 4;
			}
		}
		else{
			rotateMovement();
		}
		//statAngle = angle;
	}
	public function rotateMovement():void
	{
		angle += 4;
		
	}

All i had found about this is that if i dont make the camera to follow my player :

//centerScreenAt(player.x, player.y);

the screen’s center is on the player when its rotating. Also tried to not use that line when the screen was rotating but with same result. Any ideas?Thx


(billy2000) #2

if it helps with something …here is the projectGravityKnight.zip (216.7 KB)


(billy2000) #3

I don’t rly know how but i solved it .Ty guys anyways :smile: