这个角色工作得不太好,因为有了这个纹路。让我们用一些图片:

这是绿色的特征,浅绿色是spriteBox。黑色代表“世界”。
在雪碧的底部,在50%的纹理宽度,有一个热点。(在红十字会的中央)
我用这个热点从底部探测碰撞。这里一切正常。

但是,如果玩家跑向右边,跳到1像素太晚了(太晚了意味着:当热点不在黑色像素= Texture.Width / 2 - 1之上时),玩家就不能跳下去,并且会掉下来。即使他50%-1倍的身体接触到了世界。这就是问题所在。

着陆也有同样的问题。

如果我添加更多的热点,在这里它会变成:字符将浮动。所以我不知道怎么做..。
希望你能帮上忙。
发布于 2013-11-26 15:19:27
看一个类似蠕虫的游戏,它们有几个热点,如你的第三个例子,但它们是交错的,以匹配雪碧,它们也会根据使用的精灵改变(如面向左/右)。
阅读下面的Worm2D页面:
worms2d.info
发布于 2013-11-26 01:50:49
下面是我所做工作的代码示例:
public Boolean TouchingPlatformUpdater(Vector2 charapos){
int[] BasePlatforms = { Convert.ToInt16(platformapos1.X), Convert.ToInt16(platformapos1.Y), Convert.ToInt16(platformapos2.X), Convert.ToInt16(platformapos2.Y), Convert.ToInt16(platformapos3.X), Convert.ToInt16(platformapos3.Y), Convert.ToInt16(platformapos4.X), Convert.ToInt16(platformapos4.Y), Convert.ToInt16(platformapos5.X), Convert.ToInt16(platformapos5.Y), Convert.ToInt16(platformapos6.X), Convert.ToInt16(platformapos6.Y), Convert.ToInt16(platformapos7.X), Convert.ToInt16(platformapos7.Y), Convert.ToInt16(platformapos8.X), Convert.ToInt16(platformapos8.Y), Convert.ToInt16(platformapos9.X), Convert.ToInt16(platformapos9.Y), Convert.ToInt16(platformapos10.X), Convert.ToInt16(platformapos10.Y), Convert.ToInt16(platformapos11.X), Convert.ToInt16(platformapos11.Y), Convert.ToInt16(platformapos12.X), Convert.ToInt16(platformapos12.Y), Convert.ToInt16(platformapos13.X), Convert.ToInt16(platformapos13.Y), Convert.ToInt16(platformapos14.X), Convert.ToInt16(platformapos14.Y), Convert.ToInt16(platformapos15.X), Convert.ToInt16(platformapos15.Y) };
for (int Item = 0; Item < BasePlatforms.Length; Item = Item + 2)
{
try
{
if (charapos.X > BasePlatforms[Item] - 15 && charapos.X < BasePlatforms[Item] + 60 && charapos.Y > BasePlatforms[Item + 1] - 14 && charapos.Y < BasePlatforms[Item + 1])
{
return true;
}
}
catch { }
}
return false;我的“玩家”是一个正方形,平台也是如此,但是你也可以在更好的水平上对脚的面积和世界做同样的事情。它所做的是检查玩家是否在一个平台覆盖的区域内。然而,你必须找到一种使曲线工作的方法。
总的来说,您的系统有很大的缺陷。换到我的概念,或者另找一个用。热点问题看上去不太好用。虽然我可以为您修复您的代码,但是您没有为我们提供任何代码来帮助您修复。如果您在这个问题中得到了代码,请在Zeusoflightning125@gmail.com告诉我,我将编辑我的答案。
https://stackoverflow.com/questions/20206336
复制相似问题