Game Development Reference
In-Depth Information
Tiling is very much similar to scaling, and it's basically repeaing the texture on X and Y
axes. So, if we set the Tiling X: 0.5 , Y: 1.0 , we see the result as shown in the previous figure
with the texture on X-axis that scales half size, but it sill looks the same in Y. We also see
that the second image will show only the first left side of the texture (the first frame of our
character). Now, if we want to show the right side of our texture what will we do? We will
use Offset in Material , which will give a different result from Tiling . The Offset basically tells
us the staring posiion of our texture. So, if we set the Offset X: 0.0 , Y: 0.0 , this means that
our texture will display from the top-left corner of the original texture. On the other hand,
if we set Offset X: 0.5 , Y: 0.0 , we will see the result that our texture's start point is at the
middle of the original texture image, and we will see our material show the right side of our
texture (the second frame of our character, as we can see in the following figure):
We can change the Tiling by calling the material.mainTextureScale funcion to set the
X ile and Y ile, and use calling material.mainTextureOffset to set the X and Y Offset .
After learning this technique, we can manage our sprite image by just changing the number
of Tiling and Offset of our character Material in the next step.
Creating CharacterControl class and
SpriteManager class
In this secion, we will create new Unity JavaScript code to control the movement of our
character, and a sprite animaion for each acion of our character. We have a choice to
use Unitron (Mac), UniSciTE (Windows), or MonoDevelop, but in this topic we will use
MonoDevelop as our scriping editor instead of Unitron or UniSciTE. MonoDevelop is mainly
designed for C# and .NET environment, so if you are comfortable with C#, you will probably
love it. However, we will sill use it to edit our JavaScript because it has a lot of funcions that
will help us to write the script faster and debug beter, such as inding and replacing words in
the whole project by pressing Command + Shift + F in Mac or Control + Shift + F in Windows,
and autocomplete, to name a few. Moving from Unity JavaScript to C# is also a comparaively
smooth transiion.
 
Search WWH ::




Custom Search