Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xna 当玩家穿越障碍物时,生命值应该只减少1,但减少太多_Xna - Fatal编程技术网

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; }