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

2013/5/8

HitCounter

Hawx_ Hawx_

2013/5/8

#
Is this right, In actor :
 int hitCounter = 5; 
In the actor , in it's own method:
{  
            if(getOneIntersectingObject(DarkPlasma.class) != null){
                hitCounter--;  
                if (hitCounter = 1) {  
                    Greenfoot.stop() ;
                }  
            }
        }
I keep getting a error at
if (hitCounter = 1) {
saying , "incompatible types". I trying to make it so that when the player gets hit 5 times by "DarkPlasma" the game stops.
danpost danpost

2013/5/8

#
The comparison operator for equality is two equal signs (==), not one.
Hawx_ Hawx_

2013/5/8

#
thanks
danpost danpost

2013/5/8

#
You should make it like below if you want 5 hits before game over
if (hitCounter == 0) {
Also, you may want to remove any intersecting DarkPlasma or one may end up registered as multiple hits on your player.
You need to login to post a reply.