Overview
The multiple properties of Display class objects that are related to positioning and movement can be set using set() method. The parameter of this method is a single table. This method is useful in the case that more than two properties are to be set at the same time.
Syntax [bl]
where nk's (k=1,2,...,14) are numbers. Each element can be optionally specified.
if it is set as dx=1, it means the x-coordinate increases by 1 in every frame. if drot is set to -2, it means the rotational angle decreases by 2 degree in every frame. As a result of drot=-2, the object will rotate counterclockwise. Note that individual position can be set using
obj:setX(n1)
obj:setY(n2)
obj:setXY(n1,n2)
obj:setRot(n3)
obj:setScale(n4)
obj:setAlpha(n5)
obj:setScaleX(n6)
obj:setScaleY(n7)
methods of Display object. Note also that individual movement can be set using
obj:setDx(n8)
obj:setDy(n9)
obj:setDxDy(n8,n9)
obj:setDrot(n10)
obj:setDscale(n11)
obj:setDalpha(n12)
obj:setDscaleX(n13)
obj:setDscaleY(n14)
methods of Display object.
Examples
In the calling function in Lua language, if it receives only a single table, the parenthesis can be omitted.
The folloing example sets rot, xscale, and yscale at the same time at which the img object created.
It can be also specified elements for moving.
The properties x, y, and rot of img object will be changed by 1,2, and 2 in every frame, which raises a movement of the object.
This example sets drot, dxscale, and dyscale at the same time at which the img object created.
Note that if only one property is to set, it is more efficient to use setdx(), setdy(), setdalpha(), setdscale(),set drot(), setdxscale(), and setdyscale() methods.
By this, the 'star' object will rotate clockwise.
댓글 없음:
댓글 쓰기