在 XNA 4.0 中实现可移动平台的问题
本文关键字:可移动 平台 问题 实现 XNA | 更新日期: 2023-09-27 18:35:34
我目前正在学习本教程:http://robotfootgames.com/xna-tutorials/78-xna-platformer-starter-kit-movable-platforms
它基于以下代码示例:http://xbox.create.msdn.com/en-US/education/catalog/sample/platformer
除了这段代码之外,一切似乎都可以工作,它给了我一堆错误:
private Rectangle HandleCollision(Rectangle bounds, TileCollision collision, Rectangle tileBounds)
{
Vector2 depth = RectangleExtensions.GetIntersectionDepth(bounds, tileBounds);
if (depth != Vector2.Zero)
{
float absDepthX = Math.Abs(depth.X);
float absDepthY = Math.Abs(depth.Y);
// Resolve the collision along the shallow axis.
if (absDepthY < absDepthX || collision == TileCollision.Platform)
{
// If we crossed the top of a tile, we are on the ground.
if (previousBottom <= tileBounds.Top)
isOnGround = true;
// Ignore platforms, unless we are on the ground.
if (collision == TileCollision.Impassable || IsOnGround)
{
// Resolve the collision along the Y axis.
Position = new Vector2(Position.X, Position.Y + depth.Y);
// Perform further collisions with the new bounds.
bounds = BoundingRectangle;
}
}
else if (collision == TileCollision.Impassable) // Ignore platforms.
{
// Resolve the collision along the X axis.
Position = new Vector2(Position.X + depth.X, Position.Y);
// Perform further collisions with the new bounds.
bounds = BoundingRectangle;
}
}
return bounds;
}
有谁知道如何解决以下错误(我尝试了自己,它似乎只会导致代码进一步中断):
<
"'它'这个名字在当前上下文中不存在"
看起来有人没有正确转义他们的 HTML。只需将每个<
替换为<
,代码就可以工作。