I usually deal with 2 variables, when the constant of motion is a function $\Phi $ such that $\frac {\partial\Phi }{\partial x}\cdot\dot x+\frac {\partial\Phi }{\partial y} \cdot\dot y=0$. Usually it works to take $\frac {\partial\Phi }{\partial x}= \dot y, \frac {\partial\Phi }{\partial y}=-\dot x $ (ah by the way, can it not work?) and then proceed from there.
Or if we are given the potential energy, then the sum of potential energy and kinetic energy will be $\Phi $.
But having never seen an exercise with only a variable, I'm a bit confused here.
Multiply by $2\dot{x}$ and integrate: $$ \dot{x}^2=\frac{1}{2}\cos{2x} + A, $$ where $A$ is a constant. So the derivative of $$ \dot{x}^2-\frac{1}{2}\cos{2x} $$ with respect to $t$ is zero, and it must therefore be a constant of motion. (It is in fact related to the total energy, the first term being the kinetic bit, the second potential. It's close to a simple pendulum with the true gravitational potential energy included, rather than the small-angle approximation used in the simple harmonic motion solution.