Depends how your enemy is moving :) what logic are you using to move, it is bullet moving left/right? When they attack you can set speed 0 or disable bullet, then if player moves away so distance between player and enemy is greater than 20 for example, then you set speed back to normal or enable bullet. Distance check is distance(player.x,player.y,enemy.x,enemy.y) > 20.