2. Given $y=|x-2|-\frac{1}{2}|x|+|x+2|$, and $-1 \leqslant x \leqslant 2$. Then the difference between the maximum and minimum values of $y$ is ( ).
(A) 4
(B) 3
(C) 2
(D) 1
2. (D).
$$
y=\left\{\begin{array}{ll}
4+\frac{1}{2} x, & -1 \leqslant x \leqslant 0, \\
4-\frac{1}{2} x, & 0<x \leqslant 2 .
\end{array}\right.
$$

When $x=0$, $y_{\text {max }}=4$;
When $x=2$, $y_{\text {min }}=3$.
Thus $y_{\max }-y_{\min }=4-3=1$.