From cdf149afcab2d29a8e439b46be3c6fb6e98d1038 Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Sun, 28 Nov 2021 05:20:29 +0800 Subject: [PATCH] =?UTF-8?q?=E7=95=A5=E5=BE=AE=E4=BC=98=E5=8C=96=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E8=83=8C=E6=99=AF=E7=BB=98=E5=88=B6=E6=80=A7?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- parts/backgrounds/custom.lua | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/parts/backgrounds/custom.lua b/parts/backgrounds/custom.lua index 97e0d77e..54fba8a1 100644 --- a/parts/backgrounds/custom.lua +++ b/parts/backgrounds/custom.lua @@ -1,16 +1,26 @@ --Secret custom background -local gc=love.graphics +local gc_clear,gc_setColor=love.graphics.clear,love.graphics.setColor local back={} + local image=false local alpha=.26 -function back.draw() + +local mx,my,k + +function back.init() + back.resize() +end +function back.resize() + mx,my=SCR.w*.5,SCR.h*.5 if image then - gc.clear(.1,.1,.1) - gc.setColor(1,1,1,alpha) - local k=math.max(SCR.w/image:getWidth(),SCR.h/image:getHeight()) - mDraw(image,SCR.w*.5,SCR.h*.5,nil,k) + k=math.max(SCR.w/image:getWidth(),SCR.h/image:getHeight()) end end +function back.draw() + gc_clear(.1,.1,.1) + gc_setColor(1,1,1,alpha) + mDraw(image,mx,my,nil,k) +end function back.event(a,img) if a then alpha=a end if img then image=img end