I wrote the code to simulate the coil (like spinning), just rotate the mouse stripe, then there is no problem, but I need to rotation clockwise increases the value, and against - decreased. help me please.
I don’t understand what the problem you are asking about. What are the results of this code, and how is this different than what you want?
(It looks like English is not your first language, so this is fine, I’m just not sure what you’re asking.)
You just have to prepare for that specific case, and “loop” around for it. I like to use 180 degrees as a line - if the value changes by more than that, they’ve looped around.
This will probably work:
if (mPrevAng - ang > 180f) {
Value += ((int)(mPrevAng - ang)) - 360;
}
else if (mPrevAng - ang < -180f) {
Value += ((int)(mPrevAng - ang)) + 360;
}
else {
Value += ((int)(mPrevAng - ang));
}