Remap Function ? #1904
Unanswered
GamesStudioTwo
asked this question in
Q&A
Replies: 2 comments 3 replies
-
maybe you can add to ax::utils::mapTo and create a PR? |
Beta Was this translation helpful? Give feedback.
2 replies
-
sure |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi there is there remap function? as I have not found it in the library I use this function a lot for box2d, here is the function I use it to set the sprite setAnchorPoint in because it maps 0 to 1. if not can you add the function to the next update of axmol its really handy.
static float MapTo(float x, float in_min, float in_max, float out_min, float out_max) {
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
Example:
say you have a slider that's is a weeerd 73px wide, but it will remap it to 0% to 100%
float myVol = MapTo( sliderPos ,0, 73, 0, 100);
Many thanks.
Beta Was this translation helpful? Give feedback.
All reactions