xOy变量收入SCR
This commit is contained in:
@@ -32,7 +32,6 @@ local setFont=setFont
|
|||||||
|
|
||||||
local mx,my,mouseShow=-20,-20,false
|
local mx,my,mouseShow=-20,-20,false
|
||||||
local touching=nil--First touching ID(userdata)
|
local touching=nil--First touching ID(userdata)
|
||||||
xOy=love.math.newTransform()
|
|
||||||
joysticks={}
|
joysticks={}
|
||||||
|
|
||||||
local devMode
|
local devMode
|
||||||
@@ -93,7 +92,7 @@ local lastX,lastY=0,0--Last clickDown pos
|
|||||||
function love.mousepressed(x,y,k,touch)
|
function love.mousepressed(x,y,k,touch)
|
||||||
if touch then return end
|
if touch then return end
|
||||||
mouseShow=true
|
mouseShow=true
|
||||||
mx,my=xOy:inverseTransformPoint(x,y)
|
mx,my=SCR.xOy:inverseTransformPoint(x,y)
|
||||||
if devMode==1 then DBP(mx,my)end
|
if devMode==1 then DBP(mx,my)end
|
||||||
if SCN.swapping then return end
|
if SCN.swapping then return end
|
||||||
if mouseDown[SCN.cur]then
|
if mouseDown[SCN.cur]then
|
||||||
@@ -110,7 +109,7 @@ end
|
|||||||
function love.mousemoved(x,y,dx,dy,t)
|
function love.mousemoved(x,y,dx,dy,t)
|
||||||
if t then return end
|
if t then return end
|
||||||
mouseShow=true
|
mouseShow=true
|
||||||
mx,my=xOy:inverseTransformPoint(x,y)
|
mx,my=SCR.xOy:inverseTransformPoint(x,y)
|
||||||
if SCN.swapping then return end
|
if SCN.swapping then return end
|
||||||
dx,dy=dx/SCR.k,dy/SCR.k
|
dx,dy=dx/SCR.k,dy/SCR.k
|
||||||
if mouseMove[SCN.cur]then
|
if mouseMove[SCN.cur]then
|
||||||
@@ -124,7 +123,7 @@ function love.mousemoved(x,y,dx,dy,t)
|
|||||||
end
|
end
|
||||||
function love.mousereleased(x,y,k,touch)
|
function love.mousereleased(x,y,k,touch)
|
||||||
if touch or SCN.swapping then return end
|
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.release(mx,my)
|
||||||
WIDGET.moveCursor(mx,my)
|
WIDGET.moveCursor(mx,my)
|
||||||
if mouseUp[SCN.cur]then
|
if mouseUp[SCN.cur]then
|
||||||
@@ -146,7 +145,7 @@ function love.touchpressed(id,x,y)
|
|||||||
touching=id
|
touching=id
|
||||||
love.touchmoved(id,x,y,0,0)
|
love.touchmoved(id,x,y,0,0)
|
||||||
end
|
end
|
||||||
x,y=xOy:inverseTransformPoint(x,y)
|
x,y=SCR.xOy:inverseTransformPoint(x,y)
|
||||||
lastX,lastY=x,y
|
lastX,lastY=x,y
|
||||||
if touchDown[SCN.cur]then
|
if touchDown[SCN.cur]then
|
||||||
touchDown[SCN.cur](id,x,y)
|
touchDown[SCN.cur](id,x,y)
|
||||||
@@ -155,7 +154,7 @@ function love.touchpressed(id,x,y)
|
|||||||
end
|
end
|
||||||
function love.touchmoved(id,x,y,dx,dy)
|
function love.touchmoved(id,x,y,dx,dy)
|
||||||
if SCN.swapping then return end
|
if SCN.swapping then return end
|
||||||
x,y=xOy:inverseTransformPoint(x,y)
|
x,y=SCR.xOy:inverseTransformPoint(x,y)
|
||||||
if touchMove[SCN.cur]then
|
if touchMove[SCN.cur]then
|
||||||
touchMove[SCN.cur](id,x,y,dx/SCR.k,dy/SCR.k)
|
touchMove[SCN.cur](id,x,y,dx/SCR.k,dy/SCR.k)
|
||||||
end
|
end
|
||||||
@@ -172,7 +171,7 @@ function love.touchmoved(id,x,y,dx,dy)
|
|||||||
end
|
end
|
||||||
function love.touchreleased(id,x,y)
|
function love.touchreleased(id,x,y)
|
||||||
if SCN.swapping then return end
|
if SCN.swapping then return end
|
||||||
x,y=xOy:inverseTransformPoint(x,y)
|
x,y=SCR.xOy:inverseTransformPoint(x,y)
|
||||||
if id==touching then
|
if id==touching then
|
||||||
WIDGET.press(x,y)
|
WIDGET.press(x,y)
|
||||||
WIDGET.release(x,y)
|
WIDGET.release(x,y)
|
||||||
@@ -351,7 +350,7 @@ function love.resize(w,h)
|
|||||||
SCR.k=h/SCR.h0
|
SCR.k=h/SCR.h0
|
||||||
SCR.x,SCR.y=(w-h*SCR.w0/SCR.h0)/2,0
|
SCR.x,SCR.y=(w-h*SCR.w0/SCR.h0)/2,0
|
||||||
end
|
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
|
if BG.resize then BG.resize(w,h)end
|
||||||
|
|
||||||
SHADER.warning:send("w",w*SCR.dpi)
|
SHADER.warning:send("w",w*SCR.dpi)
|
||||||
@@ -405,7 +404,7 @@ function love.errorhandler(msg)
|
|||||||
needDraw=true
|
needDraw=true
|
||||||
elseif E=="focus"then
|
elseif E=="focus"then
|
||||||
needDraw=true
|
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
|
if count<3 then
|
||||||
count=count+1
|
count=count+1
|
||||||
SFX.play("ready")
|
SFX.play("ready")
|
||||||
@@ -426,7 +425,7 @@ function love.errorhandler(msg)
|
|||||||
gc.clear(BGcolor)
|
gc.clear(BGcolor)
|
||||||
gc.setColor(1,1,1)
|
gc.setColor(1,1,1)
|
||||||
gc.push("transform")
|
gc.push("transform")
|
||||||
gc.replaceTransform(xOy)
|
gc.replaceTransform(SCR.xOy)
|
||||||
gc.draw(errScrShot,100,365,nil,512/errScrShot:getWidth(),288/errScrShot:getHeight())
|
gc.draw(errScrShot,100,365,nil,512/errScrShot:getWidth(),288/errScrShot:getHeight())
|
||||||
setFont(120)gc.print(":(",100,40)
|
setFont(120)gc.print(":(",100,40)
|
||||||
setFont(38)gc.printf(text.errorMsg,100,200,SCR.w0-100)
|
setFont(38)gc.printf(text.errorMsg,100,200,SCR.w0-100)
|
||||||
@@ -518,7 +517,7 @@ function love.run()
|
|||||||
|
|
||||||
BG.draw()
|
BG.draw()
|
||||||
gc.push("transform")
|
gc.push("transform")
|
||||||
gc.replaceTransform(xOy)
|
gc.replaceTransform(SCR.xOy)
|
||||||
|
|
||||||
--Draw scene contents
|
--Draw scene contents
|
||||||
if Pnt[SCN.cur]then Pnt[SCN.cur]()end
|
if Pnt[SCN.cur]then Pnt[SCN.cur]()end
|
||||||
|
|||||||
@@ -726,7 +726,6 @@ function WIDGET.setLang(lang)
|
|||||||
W.text=lang[S][W.name]
|
W.text=lang[S][W.name]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function WIDGET.moveCursor(x,y)
|
function WIDGET.moveCursor(x,y)
|
||||||
@@ -777,7 +776,7 @@ function WIDGET.press(x,y)
|
|||||||
end
|
end
|
||||||
elseif W.type=="textBox"then
|
elseif W.type=="textBox"then
|
||||||
if MOBILE 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)
|
kb.setTextInput(true,0,y1,1,1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
3
main.lua
3
main.lua
@@ -36,7 +36,8 @@ SCR={
|
|||||||
W=0,H=0,--Fullscreen w/h in shader
|
W=0,H=0,--Fullscreen w/h in shader
|
||||||
rad=0,--Radius
|
rad=0,--Radius
|
||||||
k=1,--Scale size
|
k=1,--Scale size
|
||||||
dpi=1--DPI from gc.getDPIScale()
|
dpi=1,--DPI from gc.getDPIScale()
|
||||||
|
xOy=love.math.newTransform(),--Screen transformation object
|
||||||
}
|
}
|
||||||
|
|
||||||
CUSTOMENV={
|
CUSTOMENV={
|
||||||
|
|||||||
@@ -19,8 +19,8 @@ function back.draw()
|
|||||||
gc.clear(.1,.1,.1)
|
gc.clear(.1,.1,.1)
|
||||||
end
|
end
|
||||||
gc.push("transform")
|
gc.push("transform")
|
||||||
gc.replaceTransform(xOy)
|
gc.translate(SCR.w/2,SCR.h/2+20*sin(t*.02))
|
||||||
gc.translate(640,360)
|
gc.scale(SCR.k)
|
||||||
gc.scale(1.1626,1.26)
|
gc.scale(1.1626,1.26)
|
||||||
if -t%6.26<.1355 then
|
if -t%6.26<.1355 then
|
||||||
gc.translate(60*sin(t*.26),100*sin(t*.626))
|
gc.translate(60*sin(t*.26),100*sin(t*.626))
|
||||||
|
|||||||
@@ -105,8 +105,8 @@ function touchMove.mode(_,x,y,dx,dy)
|
|||||||
if not L[2]then
|
if not L[2]then
|
||||||
mapCam.x,mapCam.y=mapCam.x-dx,mapCam.y-dy
|
mapCam.x,mapCam.y=mapCam.x-dx,mapCam.y-dy
|
||||||
elseif not L[3]then
|
elseif not L[3]then
|
||||||
x,y=xOy:inverseTransformPoint(tc.getPosition(L[1]))
|
x,y=SCR.xOy:inverseTransformPoint(tc.getPosition(L[1]))
|
||||||
dx,dy=xOy:inverseTransformPoint(tc.getPosition(L[2]))--Not delta!!!
|
dx,dy=SCR.xOy:inverseTransformPoint(tc.getPosition(L[2]))--Not delta!!!
|
||||||
local d=(x-dx)^2+(y-dy)^2
|
local d=(x-dx)^2+(y-dy)^2
|
||||||
if d>100 then
|
if d>100 then
|
||||||
d=d^.5
|
d=d^.5
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ function touchMove.play()
|
|||||||
for n=1,#VK do
|
for n=1,#VK do
|
||||||
local B=VK[n]
|
local B=VK[n]
|
||||||
for i=1,#l do
|
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
|
if(x-B.x)^2+(y-B.y)^2<=B.r^2 then
|
||||||
goto next
|
goto next
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user