Game Development Reference
In-Depth Information
noTint
The
tint
function changes the color of the sprite according to the multiply effect in
image-processing packages. The
noTint
function removes all of the tinting while drawing
the sprites.
Transformation Functions
The display objects that we can create can be transformed in various ways, including rotating
and scaling, with functions like
rotate
,
scale
,
translate
, and
zLevel (what a lot of developers
refer to as the z-Index)
. These functions apply the respective transformations to all subsequent
drawings, not just an individual display object.
Rotate
The
rotate
function takes the angle arguments in degrees.
rotate(30)
rect (226,226,52,52)
Scale
The
scale
function takes the scaling parameters either as a single scaling factor that is applied to all
the axes, or as individual axes.
scale(amount)
scale(xScale, yScale)
scale(xScale, yScale, zScale)
Translate
The translate function specifies an amount to displace the subsequent drawings.
Displacement
is
like an offset that is added to the coordinates.
rect(0,0,50,50)
translate(20,20)
rect(0,0,50,50)
translate(40,40)
rect(0,0,50,50)
Note
All of the transformation functions are relative, which means that they will perform the
operations of the given value from the current value. For example,
rotate(10)
will rotate the object
10 degrees from its current position.
Transform functions change the
display matrix
. The display matrix is like a stack, where the current
settings can be saved using the
pushMatrix
function and the original settings can be restored using
the
popMatrix
function. In certain cases, you can also reset the entire display matrix to its default
values using the
resetMatrix
function.