Visual Studio - Super Mario 横向卷轴 C#

本文关键字:横向 Mario Studio Super Visual | 更新日期: 2023-09-27 17:55:26

我正在尝试在超级马里奥兄弟中制作第一关,并且随着马里奥向右移动,我正在增加xstart,这是图像的开始,随着马里奥向右移动,速度恒定,但问题是每次马里奥的移动速度都比图像快并且他的图像宽度增加。

这是位图的绘制

g.DrawImage(im,
new Rectangle(0, 0, this.Width, this.Height), //dest.
new Rectangle(xstart, 0, this.Width, this.Height), //src.
 GraphicsUnit.Pixel);

而且我总是随着马里奥的移动而增加xstart,我在这里看不到任何问题。

player.x += 5;
xstart += 5;

Visual Studio - Super Mario 横向卷轴 C#

我的猜测是你必须阅读 https://msdn.microsoft.com/en-us/library/ms142040(v=vs.110).aspx
你似乎弄乱了参数。

也许您正在寻找类似的东西:
g.DrawImage(im, new Rectangle(xstart, 0, xstart + im.Width, im.Height), //dest area in win. new Rectangle(0, 0, im.Width, im.Height), //All the input img. GraphicsUnit.Pixel);