The energy $E$ of the partical within the well must be invariant with respect to coordinate system chosen by the observer. Therefore, its value must be derived in a fashion independent of the position of the well. The Bohr-Sommerfeld rule for the quantizaation of momentum allows for this derivation of the value of $k$ in a frame-independent fashion.
It can be shown that for a constant potential $V(x)$ in a region with turning points $x_{a}$ and $x_{b}$, the ground state energy $E_{1}$ can be calculated from
\[ \int_{x_{a}}^{x_{b}} k_{1} dx = n \pi \notag \]
with
\[ k_{1} = \sqrt{\frac{2mE_{1}}{\hbar^{2}}} \notag \]
as a generalization of the Bohr-Sommerfeld quantizatuion rule.
The next set of energy levels is given by
\[ \int_{x_{0}}^{x_{0}+ L} k_{n} dx = n \pi \qquad n=2,3 \cdots \notag \]
which gives
\[ k_{n} = \frac{n \pi}{L} \qquad n=\pm 1, \pm 2, \pm 3, \dots \tag{1} \label{Eq:n-length} \]
Keeping in mind that
\[ k_{n} = \sqrt{\frac{2mE_{n}}{\hbar^{2}}} \tag{2} \label{Eq:k} \]
Substituting Eq.\eqref{Eq:k} into Eq.\eqref{Eq:n-length} and solving for $E$ results in
\[ E_{n} = \frac{n^{2} \pi^{2} \hbar^{2}}{2 m L^{2}} \notag \]
The quantization of energy is the same as that noted in the traditional approach. However, obtaining the result from the Wilson-Sommerfeld rule relies on the length $L$ of the well which is invariant.