CPolygon:SetPt
The SetPt function changes the (x,y) values for a point already in the CPolygon. If the index is outside the range [1, CPolygon:Count()], the method fails.
bSuccess = CPolygon:SetPt( nIndex, x, y ) bSuccess = CPolygon:SetPt( nIndex, array ) bSuccess = CPolygon:SetPt( nIndex, CPoint ) where |
nIndex is the index where to insert the point.
x, y are two numbers that replace the (x,y) values at index nIndex.
array is a Lua array with containing indices [1] and [2] that are used as the x and y values.
CPoint is a CPoint object whose (x,y) values replace those at index nIndex.
bSuccess is the returned success code. On success it is true, otherwise false.
The following script creates a CPolygon object and then changes the (x,y) values at index 5.
|
|
|
-- create a CPolygon with 6 points |
|
-- result: [5] = 3,8 |
|
|
|
-- change x,y at index [5] |
|
|
|
-- result: [5] = 100,200 |
|
|
|
|
|
-- create a table with at least index 1 and 2 |
|
-- change x,y at index [5] |
|
|
|
-- result: [5] = 10,11 |
|
|
The next example follows the above script by attempting to change the value at index [21], which does not already exist in the CPolygon:
|
-- change x,y at index [21] |
|
|
|
|
|
-- result: Point not set |