Example 7 Find the range of real number $a$ for which the equation $\sqrt{a+\sqrt{a+\sin x}}=\sin x$ has real solutions.

Translate the above text into English, please keep the original text's line breaks and format, and output the translation result directly.
Solve $\sin \geqslant 0$, square to get $\sqrt{a+\sin x}=\sin ^{2} x-a$, so $a \leqslant \sin ^{2} x$. Square and rearrange to get $a^{2}-\left(2 \sin ^{2} x+1\right) a+\sin ^{4} x-\sin x=0$, this is a quadratic equation in $a$. $\Delta=$ $\left(2 \sin ^{2} x+1\right)^{2}-4\left(\sin ^{4} x-\sin x\right)=4 \sin ^{2} x+4 \sin x+1=(2 \sin x+1)^{2}$, so $a=$ $\frac{1}{2}\left[2 \sin ^{2} x+1 \pm(2 \sin x+1)\right]$. Among them, $a=\sin ^{2} x+\sin x+1>\sin ^{2} x$, so discard; $a=$ $\sin ^{2} x-\sin x$, when $0 \leqslant \sin x \leqslant 1$, we have $a \in\left[-\frac{1}{4}, 0\right]$. When $a=0$, we get $\sin x=0$ or 1, there are real solutions; when $a=-\frac{1}{4}$, $\sin x=\frac{1}{2}$, there are real solutions. Therefore, the range of $a$ is $\left[-\frac{1}{4}, 0\right]$.