Timer in java, cant get the player to flinch 3 seconds -
i'm trying make player flinch when gets attacked. cant timer right, disable collision when mobs touch player cant able collision between player , mobs after 3 seconds. cant right.. please :/
code
if(flinching == false) { if(tempobject.getid() == objectid.firstmob) { currenthealth = health; if(getbounds().intersects(tempobject.getbounds())) { currenthealth = health; health -= 5; flinching = true; long current_frame_time = system.nanotime()/1000000000; //seconds long last_frame_time = current_frame_time; long current_frame_time2 = system.nanotime()/1000000000; while(current_frame_time2 - last_frame_time != 3) current_frame_time2 = system.nanotime()/1000000000; if(current_frame_time2 - last_frame_time == 3) flinching = false; system.out.println(flinching); system.out.println(health); if(health == 0) { alive = 0; if(alive == 0){ alive = 1; handler.removeobject(this); handler.restartlevel(); handler.respwan(); } } }
Comments
Post a Comment