Early-type variables in the Magellanic Clouds: I.β Cephei stars in the LMC bar