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

2013/6/1

Enemy Help

FCG FCG

2013/6/1

#
When I hit my enemy it set a dead image, how can I make it so that when the dead image is set the player class can't die when it touches it.
danpost danpost

2013/6/1

#
Need more information. Do you have a boolean in the enemy class that signifies that the actor is dead? if so, do you have a public 'get' method in the class to retrieve that value of that boolean field? do you have an 'Enemy' class that is super to all you enemy classes (or just one enemy class)? Either way, what is the name of the class that encompasses all your enemies?
FCG FCG

2013/6/1

#
danpost wrote...
Need more information. Do you have a boolean in the enemy class that signifies that the actor is dead? if so, do you have a public 'get' method in the class to retrieve that value of that boolean field? do you have an 'Enemy' class that is super to all you enemy classes (or just one enemy class)? Either way, what is the name of the class that encompasses all your enemies?
I tried putting a boolean in my enemy class. But in my player class where it put Boolean I get the error operator && cannot be applied to java.lang.Class<enemy>,Boolean.
danpost danpost

2013/6/1

#
It would help to see what code you are trying to use (both how you are working the boolean in the enemy class and how you are trying to get is value in the player class.
FCG FCG

2013/6/1

#
danpost wrote...
It would help to see what code you are trying to use (both how you are working the boolean in the enemy class and how you are trying to get is value in the player class.
In my player class I have:
 enemy kills = (enemy) getOneIntersectingObject(enemy.class); 

if (kills.enemyKills == true)
// the code that kills me
in my enemy class:
public static boolean enemyKills = true;

if // I have code so when the enemy is dead 
enemyKills = false;
else 
enemyKills = true;

 public static boolean getenemyKills()  
    {  
        return enemyKills;  
    }  
FCG FCG

2013/6/1

#
With this code when hit my enemy the whole class turns false
danpost danpost

2013/6/1

#
Please show the method in which you increment the value of 'enemyKills' and tell me what class it is in.
FCG FCG

2013/6/1

#
danpost wrote...
Please show the method in which you increment the value of 'enemyKills' and tell me what class it is in.
what do you mean increment the value of "emenyKills".
danpost danpost

2013/6/1

#
FCG wrote...
what do you mean increment the value of "emenyKills".
Sorry, lost track of what the discussion was about (the name of the field through me momentarily). If you want each enemy to be controlled by a separate boolean 'enemyKills', then that field should not be static and the 'get' method that returns its value should not be, either.
FCG FCG

2013/6/1

#
danpost wrote...
FCG wrote...
what do you mean increment the value of "emenyKills".
Sorry, lost track of what the discussion was about (the name of the field through me momentarily). If you want each enemy to be controlled by a separate boolean 'enemyKills', then that field should not be static and the 'get' method that returns its value should not be, either.
After removing the static I get java.lang.NullPointerException error in my player class where it put if (kills.enemyKills == true)
danpost danpost

2013/6/2

#
Use 'if (kills != null && kills.enemyKills)'.
You need to login to post a reply.