Continuity proof for compact domain

I posted the question about continuity, Let me assume that the function $f(x,y,z,w)$ is continuous. Is the $\max_{w} f(x,y,z,w)$ continuous?

and got the answer that the function is continuous when the domain of the function is a compact set.

Now I want to know how to prove it, "If $$f(x,y,z,w)$$ is continuous and domains of $$x,y,z,w$$ are all compact set, then $$\max_{w} f(x,y,z,w)$$ is continuous."

You can't prove it, because it's not true. A two-dimensional counterexample: Let $$f(x,w)=w$$ on the cross-shaped set $$\{(x,w): -2\le x,w\le 2\text{ and }\min(|x|,|w|)\le 1\}$$. For this clearly continuous function, $$\max_w f(x,w)=\begin{cases}1&-2\le x< 1\\ 2&-1\le x\le 1\\ 1& 1 What additional conditions would we need to make this work? Convexity of the domain should do it.
• It should work if the domain is a cartesian product, $\{(x,w) : x \in A, w \in B\}$, $B$ is compact, and $A$ locally compact. Continuity in $x$ is a local property and global properties of $f$ wrt. $x$ should not be needed. – Hans Engler Mar 20 at 13:21