This site requires JavaScript, please enable it in your browser!
Greenfoot back
ha2an
ha2an wrote ...

4 days ago

how do I attack an enemie nearby?

ha2an ha2an

4 days ago

#
If I use my code it says 'bad Operand typed for binary Operator '&&''
private boolean amSchlagenlinks = false;

       public void linksSchlagen()
        {
          if(Greenfoot.isKeyDown("left") && wasgeht == 1 && Pingpong==0)
          {
            setImage(Links1);
            wasgeht ++;
        }
         else if (wasgeht == 2)
         {
             setImage(Links2);
             wasgeht ++;
            }
        else if (wasgeht == 3)
        {
         setImage(Links3);
         wasgeht ++;
        }
        else if (wasgeht == 4)
        {
         setImage(Links4);
         wasgeht ++;
        }
        else if (wasgeht == 5)
        {
         setImage(Links5);
         wasgeht = 1;
         Pingpong=10;
         amSchlagenlinks = true;
         amSchlagenlinks = false;
        }


       public void attack()
{
  if (getObjectsAtOffset(getX() -1, getY(), Skelett.class) && amSchlagenlinks = true)
  { Skelettleben --;
      
danpost danpost

4 days ago

#
In line 37, the first expression for the if condition is not a boolean (it is a List object). Also, the second part will always be true as you are assigning that value to it and not comparing that value to it.
You need to login to post a reply.