xOy变量收入SCR

This commit is contained in:
MrZ626
2020-11-10 10:43:10 +08:00
parent 7b49053e6d
commit 9410b320d4
6 changed files with 18 additions and 19 deletions

View File

@@ -32,7 +32,6 @@ local setFont=setFont
local mx,my,mouseShow=-20,-20,false
local touching=nil--First touching ID(userdata)
xOy=love.math.newTransform()
joysticks={}
local devMode
@@ -93,7 +92,7 @@ local lastX,lastY=0,0--Last clickDown pos
function love.mousepressed(x,y,k,touch)
if touch then return end
mouseShow=true
mx,my=xOy:inverseTransformPoint(x,y)
mx,my=SCR.xOy:inverseTransformPoint(x,y)
if devMode==1 then DBP(mx,my)end
if SCN.swapping then return end
if mouseDown[SCN.cur]then
@@ -110,7 +109,7 @@ end
function love.mousemoved(x,y,dx,dy,t)
if t then return end
mouseShow=true
mx,my=xOy:inverseTransformPoint(x,y)
mx,my=SCR.xOy:inverseTransformPoint(x,y)
if SCN.swapping then return end
dx,dy=dx/SCR.k,dy/SCR.k
if mouseMove[SCN.cur]then
@@ -124,7 +123,7 @@ function love.mousemoved(x,y,dx,dy,t)
end
function love.mousereleased(x,y,k,touch)
if touch or SCN.swapping then return end
mx,my=xOy:inverseTransformPoint(x,y)
mx,my=SCR.xOy:inverseTransformPoint(x,y)
WIDGET.release(mx,my)
WIDGET.moveCursor(mx,my)
if mouseUp[SCN.cur]then
@@ -146,7 +145,7 @@ function love.touchpressed(id,x,y)
touching=id
love.touchmoved(id,x,y,0,0)
end
x,y=xOy:inverseTransformPoint(x,y)
x,y=SCR.xOy:inverseTransformPoint(x,y)
lastX,lastY=x,y
if touchDown[SCN.cur]then
touchDown[SCN.cur](id,x,y)
@@ -155,7 +154,7 @@ function love.touchpressed(id,x,y)
end
function love.touchmoved(id,x,y,dx,dy)
if SCN.swapping then return end
x,y=xOy:inverseTransformPoint(x,y)
x,y=SCR.xOy:inverseTransformPoint(x,y)
if touchMove[SCN.cur]then
touchMove[SCN.cur](id,x,y,dx/SCR.k,dy/SCR.k)
end
@@ -172,7 +171,7 @@ function love.touchmoved(id,x,y,dx,dy)
end
function love.touchreleased(id,x,y)
if SCN.swapping then return end
x,y=xOy:inverseTransformPoint(x,y)
x,y=SCR.xOy:inverseTransformPoint(x,y)
if id==touching then
WIDGET.press(x,y)
WIDGET.release(x,y)
@@ -351,7 +350,7 @@ function love.resize(w,h)
SCR.k=h/SCR.h0
SCR.x,SCR.y=(w-h*SCR.w0/SCR.h0)/2,0
end
xOy=xOy:setTransformation(w/2,h/2,nil,SCR.k,nil,SCR.w0/2,SCR.h0/2)
SCR.xOy=SCR.xOy:setTransformation(w/2,h/2,nil,SCR.k,nil,SCR.w0/2,SCR.h0/2)
if BG.resize then BG.resize(w,h)end
SHADER.warning:send("w",w*SCR.dpi)
@@ -405,7 +404,7 @@ function love.errorhandler(msg)
needDraw=true
elseif E=="focus"then
needDraw=true
elseif E=="touchpressed"or E=="mousepressed"or E=="keypressed"and a=="space"then
elseif E=="touchpressed"and b<100 or E=="mousepressed" and a==2 or E=="keypressed"and a=="space"then
if count<3 then
count=count+1
SFX.play("ready")
@@ -426,7 +425,7 @@ function love.errorhandler(msg)
gc.clear(BGcolor)
gc.setColor(1,1,1)
gc.push("transform")
gc.replaceTransform(xOy)
gc.replaceTransform(SCR.xOy)
gc.draw(errScrShot,100,365,nil,512/errScrShot:getWidth(),288/errScrShot:getHeight())
setFont(120)gc.print(":(",100,40)
setFont(38)gc.printf(text.errorMsg,100,200,SCR.w0-100)
@@ -518,7 +517,7 @@ function love.run()
BG.draw()
gc.push("transform")
gc.replaceTransform(xOy)
gc.replaceTransform(SCR.xOy)
--Draw scene contents
if Pnt[SCN.cur]then Pnt[SCN.cur]()end

View File

@@ -726,7 +726,6 @@ function WIDGET.setLang(lang)
W.text=lang[S][W.name]
end
end
end
function WIDGET.moveCursor(x,y)
@@ -777,7 +776,7 @@ function WIDGET.press(x,y)
end
elseif W.type=="textBox"then
if MOBILE then
local _,y1=xOy:transformPoint(0,W.y+W.h)
local _,y1=SCR.xOy:transformPoint(0,W.y+W.h)
kb.setTextInput(true,0,y1,1,1)
end
end

View File

@@ -36,7 +36,8 @@ SCR={
W=0,H=0,--Fullscreen w/h in shader
rad=0,--Radius
k=1,--Scale size
dpi=1--DPI from gc.getDPIScale()
dpi=1,--DPI from gc.getDPIScale()
xOy=love.math.newTransform(),--Screen transformation object
}
CUSTOMENV={

View File

@@ -19,8 +19,8 @@ function back.draw()
gc.clear(.1,.1,.1)
end
gc.push("transform")
gc.replaceTransform(xOy)
gc.translate(640,360)
gc.translate(SCR.w/2,SCR.h/2+20*sin(t*.02))
gc.scale(SCR.k)
gc.scale(1.1626,1.26)
if -t%6.26<.1355 then
gc.translate(60*sin(t*.26),100*sin(t*.626))

View File

@@ -105,8 +105,8 @@ function touchMove.mode(_,x,y,dx,dy)
if not L[2]then
mapCam.x,mapCam.y=mapCam.x-dx,mapCam.y-dy
elseif not L[3]then
x,y=xOy:inverseTransformPoint(tc.getPosition(L[1]))
dx,dy=xOy:inverseTransformPoint(tc.getPosition(L[2]))--Not delta!!!
x,y=SCR.xOy:inverseTransformPoint(tc.getPosition(L[1]))
dx,dy=SCR.xOy:inverseTransformPoint(tc.getPosition(L[2]))--Not delta!!!
local d=(x-dx)^2+(y-dy)^2
if d>100 then
d=d^.5

View File

@@ -81,7 +81,7 @@ function touchMove.play()
for n=1,#VK do
local B=VK[n]
for i=1,#l do
local x,y=xOy:inverseTransformPoint(tc.getPosition(l[i]))
local x,y=SCR.xOy:inverseTransformPoint(tc.getPosition(l[i]))
if(x-B.x)^2+(y-B.y)^2<=B.r^2 then
goto next
end