Watchmaker Wiki

The ultimate watch maker for Android Wear!

tips:movehands

Differences

This shows you the differences between two versions of the page.

 tips:movehands [2016/02/25 22:49]jt3 [Smoothly Move Analog Hands from Current Time to Zero (12:00) and Back] tips:movehands [2016/02/25 22:55] (current)jt3 Both sides previous revision Previous revision 2016/02/25 22:55 jt3 2016/02/25 22:49 jt3 [Smoothly Move Analog Hands from Current Time to Zero (12:00) and Back] 2016/02/25 22:47 jt3 2016/02/25 22:41 jt3 2016/02/25 22:32 jt3 2016/02/25 22:30 jt3 2016/02/25 22:29 jt3 created 2016/02/25 22:55 jt3 2016/02/25 22:49 jt3 [Smoothly Move Analog Hands from Current Time to Zero (12:00) and Back] 2016/02/25 22:47 jt3 2016/02/25 22:41 jt3 2016/02/25 22:32 jt3 2016/02/25 22:30 jt3 2016/02/25 22:29 jt3 created Line 38: Line 38: In each hand's rotation field, The normal rotation value of the hands is simply multiplied by the value of tweens.move. ​ Remember, we earlier initialized this as "​1"​. ​ That's because anything multiplied by one is equal to itself, so if you multiply the rotational tag value by one, you get the rotational tag value; in this case: the current time.  As the animation (tween) moves toward zero, that rotational value is instead multiplied by a decreasing fraction between 1 and 0.  The result is that the hands slowly move counterclockwise back to zero. As it ramps from 0 to 1, the hands slowly move clockwise to the current time again. ​ Cool, huh? In each hand's rotation field, The normal rotation value of the hands is simply multiplied by the value of tweens.move. ​ Remember, we earlier initialized this as "​1"​. ​ That's because anything multiplied by one is equal to itself, so if you multiply the rotational tag value by one, you get the rotational tag value; in this case: the current time.  As the animation (tween) moves toward zero, that rotational value is instead multiplied by a decreasing fraction between 1 and 0.  The result is that the hands slowly move counterclockwise back to zero. As it ramps from 0 to 1, the hands slowly move clockwise to the current time again. ​ Cool, huh? - Then, all we need is a tap action. ​ This one simply moves (over the course of one second) the tween from 0 to 1, or from 1 to zero, depending on its current value. ​ (If you're not sure how the tween function works, [[:​lua|that'​s explained elsewhere in this wiki]].) Once the tween reaches the endpoint, it stays there until you tap again. ​ That's all there is to it.  ​ + Then, all we need is a tap action. ​ This one simply moves (over the course of one second) the tween from 0 to 1, or from 1 to 0, depending on its current value. ​ (If you're not sure how the tween function works, [[:​lua|that'​s explained elsewhere in this wiki]].) Once the tween reaches the endpoint, it stays there until you tap again. ​ That's all there is to it.  ​ One last thing: ​ Capitalization and auto-correct can get you into trouble. ​ You'll notice there is no capitalization in any of the example code.  That's because you have to be VERY careful with capitalization in any coding language. ​ There'​s nothing wrong with it, but you'll find that most coders only use it for clarification,​ and avoid it otherwise. ​ For example, a variable name like VarToMakeThingsEasierToRead kind of needs capitalization (or at least a good slap upside the head to the programmer that insists on using such long freaking variable names). Remember, Var_Num is not the same as var_num, when coding. ​ If you're having issues, check to make sure that something didn't get capitalized or auto-corrected against your will. One last thing: ​ Capitalization and auto-correct can get you into trouble. ​ You'll notice there is no capitalization in any of the example code.  That's because you have to be VERY careful with capitalization in any coding language. ​ There'​s nothing wrong with it, but you'll find that most coders only use it for clarification,​ and avoid it otherwise. ​ For example, a variable name like VarToMakeThingsEasierToRead kind of needs capitalization (or at least a good slap upside the head to the programmer that insists on using such long freaking variable names). Remember, Var_Num is not the same as var_num, when coding. ​ If you're having issues, check to make sure that something didn't get capitalized or auto-corrected against your will.
tips/movehands.txt ยท Last modified: 2016/02/25 22:55 by jt3