mirror of
https://github.com/TangentFoxy/Pop.Box.git
synced 2024-12-15 12:44:20 +00:00
fixed movement bug + move args to setSize() optional
This commit is contained in:
parent
d031150cd2
commit
2cf8a656ee
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
busted/
|
@ -20,9 +20,9 @@ function element:move(x, y)
|
|||||||
self.x = self.x + x
|
self.x = self.x + x
|
||||||
self.y = self.y + y
|
self.y = self.y + y
|
||||||
|
|
||||||
for i=1,#element.child do
|
for i=1,#self.child do
|
||||||
if not element.child[i].excludeMovement then
|
if not self.child[i].excludeMovement then
|
||||||
element.child[i]:move(x - oldX, y - oldY)
|
self.child[i]:move(x - oldX, y - oldY)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -49,9 +49,9 @@ function element:setPosition(x, y)
|
|||||||
self.y = y - self.h
|
self.y = y - self.h
|
||||||
end
|
end
|
||||||
|
|
||||||
for i=1,#element.child do
|
for i=1,#self.child do
|
||||||
if not element.child[i].excludeMovement then
|
if not self.child[i].excludeMovement then
|
||||||
element.child[i]:move(x - oldX, y - oldY)
|
self.child[i]:move(x - oldX, y - oldY)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -78,21 +78,24 @@ function element:getPosition()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function element:setSize(w, h)
|
function element:setSize(w, h)
|
||||||
if self.horizontal == "center" then
|
if w then
|
||||||
self.x = self.x - (w - self.w)/2
|
if self.horizontal == "center" then
|
||||||
elseif self.horizontal == "right" then
|
self.x = self.x - (w - self.w)/2
|
||||||
self.x = self.x - (w - self.w)
|
elseif self.horizontal == "right" then
|
||||||
|
self.x = self.x - (w - self.w)
|
||||||
|
end
|
||||||
|
self.w = w
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.vertical == "center" then
|
if h then
|
||||||
self.y = self.y - (h - self.h)/2
|
if self.vertical == "center" then
|
||||||
elseif self.vertical == "bottom" then
|
self.y = self.y - (h - self.h)/2
|
||||||
self.y = self.y - (h - self.h)
|
elseif self.vertical == "bottom" then
|
||||||
|
self.y = self.y - (h - self.h)
|
||||||
|
end
|
||||||
|
self.h = h
|
||||||
end
|
end
|
||||||
|
|
||||||
self.w = w
|
|
||||||
self.h = h
|
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user