forked from goosefx/mexico
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRect.lua
More file actions
33 lines (28 loc) · 687 Bytes
/
Rect.lua
File metadata and controls
33 lines (28 loc) · 687 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
local mexico = require "mexico"
--
-- Mexico wrapper for a corona rectangle.
--
local Rect = mexico.class(mexico.DisplayObject)
--
-- Magic new function, since corona creates the object
-- and not we.
--
Rect.new = function(styles)
local l = styles.left or 0
local t = styles.top or 0
local w = styles.width or display.contentWidth
local h = styles.height or display.contentHeight
return display.newRect(l, t, w, h)
end
--
-- Constructor
--
function Rect:init(styles)
local styles = table.mexico.clone(styles)
styles["left"] = nil
styles["top"] = nil
styles["width"] = nil
styles["height"] = nil
mexico.DisplayObject.init(self, styles)
end
return Rect