diff options
author | chai <chaifix@163.com> | 2021-11-17 01:04:33 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-11-17 01:04:33 +0800 |
commit | 867543de42a0c3d7fa6554e5e9672fe469ae9386 (patch) | |
tree | 0f937e9bfeb32f03ac401ecc6e41d4308d76a57a /Data/BuiltIn/Libraries | |
parent | 9421ca53788e51a92b28056e06af3d9dd6b4d92c (diff) |
*Rect
Diffstat (limited to 'Data/BuiltIn/Libraries')
-rw-r--r-- | Data/BuiltIn/Libraries/GameLab/Engine/Math/Rect.lua | 44 | ||||
-rw-r--r-- | Data/BuiltIn/Libraries/GameLab/init.lua | 2 |
2 files changed, 41 insertions, 5 deletions
diff --git a/Data/BuiltIn/Libraries/GameLab/Engine/Math/Rect.lua b/Data/BuiltIn/Libraries/GameLab/Engine/Math/Rect.lua index e7f29c6..afadee8 100644 --- a/Data/BuiltIn/Libraries/GameLab/Engine/Math/Rect.lua +++ b/Data/BuiltIn/Libraries/GameLab/Engine/Math/Rect.lua @@ -1,4 +1,5 @@ local Rect = GameLab.GlobalClass("GameLab.Engine.Math.Rect")
+local Vector2 = GameLab.Include("GameLab.Engine.Math.Vector2")
Rect.Ctor = function(self, x, y, width, height)
self.x = x or 0
@@ -8,12 +9,12 @@ Rect.Ctor = function(self, x, y, width, height) end
Rect.Set = function(self, rect)
- if rect._type and rect._type.fullName == "GameLab.Engine.Math.Rect" then
+ if rect.Is and rect:Is(Rect) then
self.x = rect.x or rect.x
self.y = rect.y or rect.y
self.width = rect.z or rect.width
self.height = rect.w or rect.height
- else
+ else
self.x = rect.x or rect[1]
self.y = rect.y or rect[2]
self.width = rect.z or rect[3]
@@ -21,13 +22,46 @@ Rect.Set = function(self, rect) end
end
-Rect.GetPosition = function(self)
- local v = GameLab.Engine.Math.Vector2(self.x, self.y)
+Rect.get_xy = function(self)
+ local v = Vector2(self.x, self.y)
return v
end
+Rect.get_location = function(self)
+ local v = Vector2(self.x, self.y)
+ return v
+end
+
+Rect.get_position = Rect.get_location
+
+Rect.get_wh = function(self)
+ local v = Vector2(self.width, self.height)
+ return v
+end
+
+Rect.get_size = function(self)
+ local v = Vector2(self.width, self.height)
+ return v
+end
+
+Rect.get_w = function(self)
+ return self.width
+end
+
+Rect.set_w = function(self, w)
+ self.width = w
+end
+
+Rect.get_h = function(self)
+ return self.height
+end
+
+Rect.set_h = function(self, h)
+ self.height = h
+end
+
Rect.GetSize = function(self)
- local v = GameLab.Engine.Math.Vector2(self.width, self.height)
+ local v = Vector2(self.width, self.height)
return v
end
diff --git a/Data/BuiltIn/Libraries/GameLab/init.lua b/Data/BuiltIn/Libraries/GameLab/init.lua index b0c3780..de60ca3 100644 --- a/Data/BuiltIn/Libraries/GameLab/init.lua +++ b/Data/BuiltIn/Libraries/GameLab/init.lua @@ -27,6 +27,8 @@ GameLab.Find = function(name) return m
end
+GameLab.Include = GameLab.Find
+
local import = GameLab.Import(...)
import "Package"
|