mirror of
https://github.com/linux-man/LoveFrames.git
synced 2024-11-18 16:04:22 +00:00
Add support for centering scaled images
This commit is contained in:
parent
28e6b8adcd
commit
81074e44b7
@ -419,15 +419,13 @@ function newobject:Center()
|
|||||||
if parent == base then
|
if parent == base then
|
||||||
local width = love.graphics.getWidth()
|
local width = love.graphics.getWidth()
|
||||||
local height = love.graphics.getHeight()
|
local height = love.graphics.getHeight()
|
||||||
|
self.x = width/2 - self.width * (self.scalex or 1)/2
|
||||||
self.x = width/2 - self.width/2
|
self.y = height/2 - self.height * (self.scaley or 1)/2
|
||||||
self.y = height/2 - self.height/2
|
|
||||||
else
|
else
|
||||||
local width = parent.width
|
local width = parent.width
|
||||||
local height = parent.height
|
local height = parent.height
|
||||||
|
self.staticx = width/2 - self.width * (self.scalex or 1)/2
|
||||||
self.staticx = width/2 - self.width/2
|
self.staticy = height/2 - self.height * (self.scaley or 1)/2
|
||||||
self.staticy = height/2 - self.height/2
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
@ -445,10 +443,10 @@ function newobject:CenterX()
|
|||||||
|
|
||||||
if parent == base then
|
if parent == base then
|
||||||
local width = love.graphics.getWidth()
|
local width = love.graphics.getWidth()
|
||||||
self.x = width/2 - self.width/2
|
self.x = width/2 - self.width * (self.scalex or 1)/2
|
||||||
else
|
else
|
||||||
local width = parent.width
|
local width = parent.width
|
||||||
self.staticx = width/2 - self.width/2
|
self.staticx = width/2 - self.width * (self.scalex or 1)/2
|
||||||
end
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
@ -466,10 +464,10 @@ function newobject:CenterY()
|
|||||||
|
|
||||||
if parent == base then
|
if parent == base then
|
||||||
local height = love.graphics.getHeight()
|
local height = love.graphics.getHeight()
|
||||||
self.y = height/2 - self.height/2
|
self.y = height/2 - self.height * (self.scaley or 1)/2
|
||||||
else
|
else
|
||||||
local height = parent.height
|
local height = parent.height
|
||||||
self.staticy = height/2 - self.height/2
|
self.staticy = height/2 - self.height * (self.scaley or 1)/2
|
||||||
end
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
|
Loading…
Reference in New Issue
Block a user