Watchmaker Wiki

The ultimate watch maker for Android Wear!

User Tools

Site Tools


tips:movehands

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
tips:movehands [2016/02/25 21:47] jt3tips:movehands [2016/02/25 21:55] (current) jt3
Line 5: Line 5:
 This has been done countless times, and in many ways.  The [[https://plus.google.com/+JamesTaylor3rd/posts/7cgJDCp5Htn|earliest method that I know of]] in Watchmaker came long before animation or scripting were available features of the program, and were done purely though tags and maths. Nowadays, it can be done much smoother, much easier, and with very little code.  In fact, recently, I held a "Coding Challenge" to see if the brightest coding minds could come up with an even better solution.  [[https://plus.google.com/u/0/110228601105403324630|Mark Shoulson]] came up with a brilliant one, which is the basis for this wiki.  (For reference, [[https://plus.google.com/u/0/+JamesTaylor3rd/posts/hdgeA9RmsH6|here's the original challenge post]].)  This has been done countless times, and in many ways.  The [[https://plus.google.com/+JamesTaylor3rd/posts/7cgJDCp5Htn|earliest method that I know of]] in Watchmaker came long before animation or scripting were available features of the program, and were done purely though tags and maths. Nowadays, it can be done much smoother, much easier, and with very little code.  In fact, recently, I held a "Coding Challenge" to see if the brightest coding minds could come up with an even better solution.  [[https://plus.google.com/u/0/110228601105403324630|Mark Shoulson]] came up with a brilliant one, which is the basis for this wiki.  (For reference, [[https://plus.google.com/u/0/+JamesTaylor3rd/posts/hdgeA9RmsH6|here's the original challenge post]].) 
  
-So... what's the point?  When would you ever use this?  Well, there are many reasons, but an analog stopwatch is probably the most common.  When activating the stopwatch, you'll want the hands to move to the zero position, and again when you reset the stopwatch.  Then, when you leave stopwatch mode, you'll want to move them back to the current time.  Simulating realistic movement adds to the analog effect, and really adds a sense of realism to your watch face.+So... what's the point?  When would you ever use this?  Well, there are many reasons, but an analog stopwatch is probably the most common.  When activating the stopwatch, you'll want the hands to move to the zero position, and again when you reset the stopwatch.  Then, when you leave stopwatch mode, you'll want to move them back to the current time.  Simulating realistic movement adds to the analog effect, and adds a sense of realism to your watch face.
  
 ===== Example ===== ===== Example =====
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 21:55 by jt3