diff options
Diffstat (limited to 'examples/resources/lib/rectangle.lua')
| -rw-r--r-- | examples/resources/lib/rectangle.lua | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/examples/resources/lib/rectangle.lua b/examples/resources/lib/rectangle.lua index 3de80e4..6e08f52 100644 --- a/examples/resources/lib/rectangle.lua +++ b/examples/resources/lib/rectangle.lua @@ -2,7 +2,6 @@ if table.unpack == nil then table.unpack = unpack end - local Vector2 = Vector2 or require( "vector2" ) local Rectangle = {} @@ -73,6 +72,17 @@ function Rectangle:newR( r ) return object end +function Rectangle:newV( position, size ) + local object = setmetatable( {}, metatable ) + + object.x = position.x + object.y = position.y + object.width = size.x + object.height = size.y + + return object +end + function Rectangle:set( x, y, width, height ) self.x = x or 0 self.y = y or self.x @@ -91,6 +101,13 @@ function Rectangle:setR( r ) self.height = r.height end +function Rectangle:setV( position, size ) + self.x = position.x + self.y = position.y + self.width = size.x + self.height = size.y +end + function Rectangle:serialize() return "Rectangle:new("..self.x..","..self.y..","..self.width..","..self.height..")" end @@ -221,6 +238,20 @@ function Rectangle:tempR( r ) return object end +function Rectangle:tempV( position, size ) + local object = tempPool[ curTemp ] + + curTemp = curTemp < TEMP_COUNT and curTemp + 1 or 1 + + object.x = position.x + object.y = position.y + object.width = size.x + object.height = size.y + + return object +end + + function Rectangle:getTempId() return curTemp end |
