Xna 当玩家穿越障碍物时,生命值应该只减少1,但减少太多
下图显示了玩家的消极生活。。。。因为在道路上有障碍物相交…我想要的解决方案是在相交后只减少一点生命Xna 当玩家穿越障碍物时,生命值应该只减少1,但减少太多,xna,Xna,下图显示了玩家的消极生活。。。。因为在道路上有障碍物相交…我想要的解决方案是在相交后只减少一点生命 if (Texture.playerrect.Intersects(Texture.mirchirect) || Texture.playerrect.Intersects(Texture.crabrect) || Texture.playerrect.Intersects(Texture.stonerect) || Texture.playerrect.Intersects(Te
if (Texture.playerrect.Intersects(Texture.mirchirect) || Texture.playerrect.Intersects(Texture.crabrect) || Texture.playerrect.Intersects(Texture.stonerect) || Texture.playerrect.Intersects(Texture.cactusrect))
{
die = true;
currentframe = 19;
}
else { die = false; }
if (die)
{
life -= 1;
}
可能是因为代码每秒更新60帧,并且
die==true
,那么对象的寿命将每秒减少60帧,而不是1。可能是因为代码每秒更新60帧,并且die==true
,那么对象的寿命将每秒减少60帧,而不是1。可能是因为代码每秒更新60帧,并且die==true
,那么对象的寿命将每秒减少60帧,而不是1。可能是因为代码每秒更新60帧,并且die==true
,那么对象的寿命将每秒减少60帧,而不是1。可能的方式。。。在障碍物中添加一个bollean变量PlayerHitted
,当发生碰撞时,如果PlayerHitted
为false(默认),则将PlayerHitted
更新为true
这样,如果障碍物击中玩家,就会有信息。可能的方式。。。在障碍物中添加一个bollean变量
PlayerHitted
,当发生碰撞时,如果PlayerHitted
为false(默认),则将PlayerHitted
更新为true
if (Texture.playerrect.Intersects(Texture.mirchirect) || Texture.playerrect.Intersects(Texture.crabrect) || Texture.playerrect.Intersects(Texture.stonerect) || Texture.playerrect.Intersects(Texture.cactusrect))
{
die = true;
currentframe = 19;
if (!Update)
{
life--;
Update = true;
}
}
else { die = false; Update = false; }
这样,如果障碍物击中玩家,就会有信息。可能的方式。。。在障碍物中添加一个bollean变量
PlayerHitted
,当发生碰撞时,如果PlayerHitted
为false(默认),则将PlayerHitted
更新为true
if (Texture.playerrect.Intersects(Texture.mirchirect) || Texture.playerrect.Intersects(Texture.crabrect) || Texture.playerrect.Intersects(Texture.stonerect) || Texture.playerrect.Intersects(Texture.cactusrect))
{
die = true;
currentframe = 19;
if (!Update)
{
life--;
Update = true;
}
}
else { die = false; Update = false; }
这样,如果障碍物击中玩家,就会有信息。可能的方式。。。在障碍物中添加一个bollean变量
PlayerHitted
,当发生碰撞时,如果PlayerHitted
为false(默认),则将PlayerHitted
更新为true
if (Texture.playerrect.Intersects(Texture.mirchirect) || Texture.playerrect.Intersects(Texture.crabrect) || Texture.playerrect.Intersects(Texture.stonerect) || Texture.playerrect.Intersects(Texture.cactusrect))
{
die = true;
currentframe = 19;
if (!Update)
{
life--;
Update = true;
}
}
else { die = false; Update = false; }
这样,当障碍物击中玩家时,就会得到信息可能重复的@DavorMlinaric thnxdude@DavorMlinaric那个布尔逻辑在我的代码中不起作用……wyh??可能是@DavorMlinaric thnx的重复dude@DavorMlinaric那个布尔逻辑在我的代码中不起作用……wyh??可能是@DavorMlinaric thnx的重复dude@DavorMlinaric那个布尔逻辑在我的代码中不起作用……wyh??可能是@DavorMlinaric thnx的重复dude@DavorMlinaric这个布尔逻辑在我的代码中不起作用了…wyh??它减少了27到3个OITS减少了27到3个OITS减少了27到3个OITS减少了27到3个OITS只在生命减少1.它生命减少1后,不使用代码再次减少生命1.生命减少1后,不使用代码再次减少生命1.生命减少1后,不使用代码再次减少生命1.生命减少1后,不使用代码再次减少生命1.生命不再减少
if (Texture.playerrect.Intersects(Texture.mirchirect) || Texture.playerrect.Intersects(Texture.crabrect) || Texture.playerrect.Intersects(Texture.stonerect) || Texture.playerrect.Intersects(Texture.cactusrect))
{
die = true;
currentframe = 19;
if (!Update)
{
life--;
Update = true;
}
}
else { die = false; Update = false; }