问题描述
为此制作我自己的系统很容易,但我认为 .NET 库虽然庞大,但可能已经有一个专为此目的而制作的类.
It would be easy enough to make my own system for this, but I'm figuring that the .NET library, being as massive as it is, probably already has a class made for this very purpose.
对于命中检测,我的 VB.NET 游戏使用两个 2D 数组来存储关卡中每个像素的状态.这些数组中的每个元素都是一个 Byte(或者更准确地说,是一个基于 Byte 的标志枚举类型的值).
For hit detection, my VB.NET game uses two 2D arrays that store the state of each pixel in the level. Each element in these arrays is a Byte (or, more accurately, a value of a flag enumeration type based on Byte).
Public TiHD(,) As HitDT ''//State of each pixel in the level based on
''// its underlying tile.
Public SpHD(,) As HitDT ''//State of each pixel in the level based on
''// sprite occupation.
<Flags> _
Public Enum HitDT As Byte
Solid = 1
Danger = 2
Water = 4
Healing = 8
Restore = 16
AreaExit = 32
End Enum
我很高兴能够只给每个精灵 &平铺自己的 2D 命中检测数据阵列(定义对象的哪些像素是实心的、危险的等),可以以指定的偏移量直接写入 TiHD 或 SpHD.
I would enjoy being able to just give each sprite & tile its own 2D array of hit detection data (defining which pixels of the object are solid, dangerous, etc) that can be directly written to TiHD or SpHD at a specified offset.
我敢打赌 .NET 有一个可以为我做这件事的类.
大概我只需要将 TiHD 或 SpHD 传递给构造函数,然后我就可以使用该对象来间接修改具有扩展功能的数组(类似于使用 Graphics 对象来修改位图).有这样的课吗?
I'm willing to bet that .NET has a class that can do this for me.
Presumably I would just have to pass TiHD or SpHD to the constructor, and then I would be able to use the object to indirectly modify the array with extended functionality (similar to using a Graphics object to modify a Bitmap). Is there such a class?
推荐答案
您是否尝试过使用 Buffer.BlockCopy
?
Have you tried using Buffer.BlockCopy
?
这篇关于.NET:将一个二维数组写入另一个数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!