The x/y scales of a display object (image, sprite, group... etc.) are stored in xScale/yScale properties. If a display object is created, the default values of these properties are 1s. There are two methods that modify scale of the display object. First one is direct setting xScale/yScale properties of the object and the other one is obj:scale(mx, my) function call. Actually, I had been misunderstanding that the two methods take the same action to the object. It can be easily misunderstood that obj:scale(mx, my) is the same as obj.xScale, obj.yScale = xm, ym ,
However, the obj:scale(xm, ym) method performs multiplication xm/ym values and the xScale/yScale properties. That is, obj:scale(xm, ym) is the same as
obj.xScale, obj.yScale = obj.xScale*xm, obj.yScale*ym
Let's see the following example.
However, the obj:scale(xm, ym) method performs multiplication xm/ym values and the xScale/yScale properties. That is, obj:scale(xm, ym) is the same as
obj.xScale, obj.yScale = obj.xScale*xm, obj.yScale*ym
Let's see the following example.
local img = display.newImage("some_image.png")
img:scale(1.5, 2.0)
.
.
.
img:scale(0.5, 0.5)
.
.
.
img:scale(0.5, 0.5)
The result of second img:scale() call is xScale = 0.75 (1.5 times 0.5) and yScale = 1. (2.0 times 0.5)
The angle is stored in the obj.rotation property in degree. The default value of this property is 0 when created. The modification of the angle of a display object is also performed by two methods. One is direct setting of obj.rotation property and the other method is obj:rotate(dr) function call. Similar to the former case, one must be cautious to the fact that the function obj:rotate(dr) adds dr degree (angle) to the obj.rotation property. That is obj:rotate(dr) is the same as obj.rotation = obj.rotation + dr.
The angle is stored in the obj.rotation property in degree. The default value of this property is 0 when created. The modification of the angle of a display object is also performed by two methods. One is direct setting of obj.rotation property and the other method is obj:rotate(dr) function call. Similar to the former case, one must be cautious to the fact that the function obj:rotate(dr) adds dr degree (angle) to the obj.rotation property. That is obj:rotate(dr) is the same as obj.rotation = obj.rotation + dr.
댓글 없음:
댓글 쓰기