미니 게임을 만들고 있습니다. 나는 좌회전 할 때이 코드 내 플레이어를 회전하려면 오른쪽 picPlayer.Image.RotateFlip(RotateFlipType.RotateNoneFlipX)
내 이동 코드는 다음과 같습니다C#에서 한 번만 그림 상자를 회전하려면?
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
//when one of the movement keys are pressed,
//makes it's variable true.
if (e.KeyCode == Keys.Right || e.KeyCode == Keys.D)
{
moveRight = true;
}
}
또한, 내 타이머의 프로그램입니다 :
private void tmrMovementPlayer_Tick(object sender, EventArgs e)
{
//whenever right arrow is pressed,
if (moveRight == true)
{
//decrease the x variable by 5 (moves right)
x = x + PLAYER_SPEED;
//check for boundaries (if the player is out of the screen)
if (x >= this.ClientSize.Width - picPlayer.Width)
{
//if yes, set it back to the boundary.
x = this.ClientSize.Width - picPlayer.Width;
}
//check the subprogram for info
MovePlayer();
}
}
나는이 시점에서 무엇을해야합니까? 감사.
안녕하세요, 저는 두 가지 방법 모두에 사용했습니다. 멈추고 다시 오른쪽을 클릭하면 다시 회전하기 때문에 작동하지 않습니다. 말하자면 나는 오른쪽으로 가고있다. 멈 추면 여전히 올바른 방향을보고 있지만 다시 오른쪽을 누르면 다시 회전하고 왼쪽을 봅니다. – Qedized
그리고 ... (! moveRight) 의미는 무엇입니까? 내 말은, 무슨 뜻이야! 그 코드에서 의미가 있습니까? – Qedized
! 부울 반대를 의미합니다. 따라서 moveRight가 현재 false이면! moveRight는 true로 평가됩니다. –