因此,基于我创造Pacman游戏的事情。
我目前能够显示地图(使用c#图形创建自己的地图,(位于Cell.cs但与此问题无关。)
我目前仍然坚持如何让Pacman在地图上显示但却极度挣扎。我的" MovingPacman"文件似乎无法找到我的表单上的图片框(表单本身被称为" Gameboard"并且图片框被称为" mapPictureBox")。
但说实话,这些错误可能并不重要,因为我甚至不确定我是否正确地展示和移动pacman。
任何帮助都会受到赞赏,因为我在2周内没有取得进展。任何其他问题都让我知道。
这是我尝试加载pacman的地方
private void mapPictureBox_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
g.DrawImage(pacmanImage[currentMouthPosition], xPosition, yPosition, 32, 32);
}
//load event
private void Gameboard_Load(object sender, EventArgs e)
{
//load images
pacmanImage[0] = Image.FromFile("C:\\Users\\Peter\\Documents\\PacmanGame\\PacMan_Game\\PacMan_Game\\images\\pac32_left_close.png");
pacmanImage[1] = Image.FromFile("C:\\Users\\Peter\\Documents\\PacmanGame\\PacMan_Game\\PacMan_Game\\level1.txt\\pac32_left_open.png");
pacmanImage[2] = Image.FromFile("C:\\Users\\Peter\\Documents\\PacmanGame\\PacMan_Game\\PacMan_Game\\level1.txt\\pac32_left_wide.png");
pacmanImage[3] = Image.FromFile("C:\\Users\\Peter\\Documents\\PacmanGame\\PacMan_Game\\PacMan_Game\\level1.txt\\pac32_left_widest.png");
}
然后打开我试着打电话
mapPicturebox.Invalidate();
但它在当前上下文中并不存在。