整理代码
This commit is contained in:
@@ -32,6 +32,7 @@ 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)
|
||||||
|
local xOy=SCR.xOy
|
||||||
joysticks={}
|
joysticks={}
|
||||||
|
|
||||||
local devMode
|
local devMode
|
||||||
@@ -92,7 +93,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=SCR.xOy:inverseTransformPoint(x,y)
|
mx,my=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
|
||||||
@@ -109,7 +110,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=SCR.xOy:inverseTransformPoint(x,y)
|
mx,my=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
|
||||||
@@ -123,7 +124,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=SCR.xOy:inverseTransformPoint(x,y)
|
mx,my=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
|
||||||
@@ -145,7 +146,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=SCR.xOy:inverseTransformPoint(x,y)
|
x,y=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)
|
||||||
@@ -154,7 +155,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=SCR.xOy:inverseTransformPoint(x,y)
|
x,y=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
|
||||||
@@ -171,7 +172,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=SCR.xOy:inverseTransformPoint(x,y)
|
x,y=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)
|
||||||
@@ -350,7 +351,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
|
||||||
SCR.xOy=SCR.xOy:setTransformation(w/2,h/2,nil,SCR.k,nil,SCR.w0/2,SCR.h0/2)
|
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)
|
||||||
@@ -425,7 +426,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(SCR.xOy)
|
gc.replaceTransform(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)
|
||||||
@@ -516,7 +517,7 @@ function love.run()
|
|||||||
|
|
||||||
BG.draw()
|
BG.draw()
|
||||||
gc.push("transform")
|
gc.push("transform")
|
||||||
gc.replaceTransform(SCR.xOy)
|
gc.replaceTransform(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
|
||||||
|
|||||||
Reference in New Issue
Block a user