Example 2. For $x$, $y$ satisfying the inequality $\frac{x^{2}}{4}+y^{2} \leqslant 1$, find the maximum and minimum values of the function $z=x-y$.

 untranslated text remains unchanged:
将上面的文本翻译成英文，请保留源文本的换行和格式，直接输出翻译结果。 

Note: The note at the end is not part of the translation but is provided to clarify the instruction. The actual translation does not include this note.
Solve: First, determine the domain of $x$ and $y$, which is the closed region $D$ enclosed by an ellipse centered at point $\mathrm{O}$ with a major semi-axis of 2 and a minor semi-axis of 1. (Figure 2).

Let $x-y=k$, i.e., $y=x-k$, which represents a family of parallel lines with a slope of 1 and a y-intercept of $-k$.

When the moving line with a slope of 1 passes through region $D$, the minimum and maximum intercepts are the maximum and minimum values of $z=x-y$. It is easy to see that the moving line with a slope of 1 has the maximum and minimum intercepts when it is tangent to the ellipse. Therefore, the problem is converted to finding the intercept values of the moving line when it is tangent to the ellipse. Solve the system of equations:
$$
\left\{\begin{array}{l}
x^{2} + y^{2} = 1, \\
x - y = k
\end{array} \Leftrightarrow \left\{\begin{array}{l}
5 x^{2} - 8 k x + 4 k^{2} - 4 = 0, \\
y = x - k .
\end{array}\right.\right.
$$

The line $y=x-k$ is tangent to the ellipse $\Longleftrightarrow 5 x^{2} - 8 k x + 4 k^{2} - 4 = 0$ has a double root $\Leftrightarrow (-8 k)^{2} - 20(4 k^{2} - 4) = 0 \Leftrightarrow k = \pm \sqrt{5}$.
$$
\therefore z_{\max} = \sqrt{5}, z_{\min} = -\sqrt{5}.
$$