Game Development Reference
In-Depth Information
Aligning the Images
All images have an anchor point on which they are hinged; when an image is rotated, it is this point
that determines how the rotation takes place. The anchor point is a numerical value from 0 to 1,
which represents the height or width of the image. This is illustrated in Figure 9-11 . You can think of
this value as a percentage: 0 being the top and 100 being the bottom on the y-axis and 0 being the
left and 100 being the right on the x-axis. To get our value, we simply divide this percentage by 100.
Figure 9-11. A bitmap object with the anchor point set at 0, 0
The center anchor point would be 0.5 on both x- and y-axis. Consider the following code:
local birdie = newImage("post-it.png", 100, 100)
birdie:setAnchorPoint(0.5,0.5)
birdie:setRotation(45)
Notice that the image is rotated around the center of the image when run. Now try to change the 0.5,
0.5 to different numbers to observe the effect of the anchor point.
 
Search WWH ::




Custom Search