I will make a platform game. imagine the enemy have zone arround him, if player get in to the zone, enemy moving. If player get out the zone enemy stop moving. please help me code the method.
I use this method for Enemy
And, this method for player
But, not working like my expect :( Please help mee
Thanks a lot before
public void cekPlayer() { int x = ((player) getWorld().getObjects(player.class).get(0)).getnilaiX(); int y = ((player) getWorld().getObjects(player.class).get(0)).getnilaiY(); if(y < getY() +5 && y > getY() -5 && jumping==false){ jump(); }if ( x < getX()+5 && x > getX() -5 && jumping==false){ jump(); } }
public int getnilaiX() { return getX(); } public int getnilaiY() { return getY(); }