메뉴 건너뛰기

창작에 관련된 질문이나 간단한 팁, 예제를 올리는 곳

-- 안드로이드/iOS 등등의 터치스크린 입력을 받는 기기에서는 총 3가지의 콜백 함수를 사용한다:

-- love.touchpressed / love.touchmoved / love.touchreleased

-- 다만 위 3가지 함수는 마우스 클릭으로는 발생하지 않으므로 추가적인 처리가 필요하다.


-- 아래의 코드는 터치 입력을 touches{} 테이블에 저장한다.

-- touches[id] = {x, y, 눌린 시간}

-- 새로운 테이블 키를 추가하는 식으로 여러가지 정보(맨 처음에 눌린 위치 등)를 추가적으로 처리할 수 있다. 


local touches = {}


function love.load()

    count = 0

end


function love.draw()

local k, v

for k, v in pairs(touches) do

love.graphics.print(tostring(k) .. ":" .. math.floor(v[1]) .. ":" .. math.floor(v[2]) .. ":".. math.floor(v[3]), v[1], v[2])

end

love.graphics.print(count, 0, 0)

end


function love.touchpressed( id, x, y, dx, dy, pressure )

touches[id] = {x, y, 0}

count = count + 1

end


function love.touchmoved( id, x, y, dx, dy, pressure )

if touches[id] ~= nil then

touches[id][1] = x

touches[id][2] = y

end

end


function love.touchreleased( id, x, y, dx, dy, pressure )

touches[id] = nil

count = count - 1

end


function love.mousepressed( x, y, button, istouch, presses )

if istouch == false then 

love.touchpressed( "mouse", x, y, 0, 0, 1 )

end

end


function love.mousemoved( x, y, dx, dy, istouch )

if istouch == false then

if love.mouse.isDown(1) then

love.touchmoved( "mouse", x, y, dx, dy, 1 )

end

end

end


function love.mousereleased( x, y, button, istouch, presses )

if istouch == false then

love.touchreleased( "mouse", x, y, 0, 0, 0)

end

end


function love.update(dt)

-- 눌린 시간 갱신

local k, v

for k, v in pairs(touches) do

v[3] = v[3] + dt

end

end


제스처를 인식하는 기능 같은 건 없으므로

핀치 줌, 스와이프, 더블탭, 롱프레스 등등의 이벤트를 처리하고 싶으면 직접 인식하는 코드를 짜야 합니다.

분류 :
조회 수 :
20
등록일 :
2020.11.12
00:38:39 (*.47.15.167)
엮인글 :
게시글 주소 :
https://hondoom.com/zbxe/index.php?mid=study&document_srl=818623
List of Articles
번호 제목 글쓴이 조회 수sort 추천 수 날짜 최근 수정일
» love2d에서 안드로이드 터치 제스처 인식하기 노루발 20   2020-11-12 2020-11-12 00:38
-- 안드로이드/iOS 등등의 터치스크린 입력을 받는 기기에서는 총 3가지의 콜백 함수를 사용한다: -- love.touchpressed / love.touchmoved / love.touchreleased -- 다만 위 3가지 함수는 마우스 클릭으로는 발생하지 않으므로 추가적인 처리가 필요하다. -- ...  
4 certbot을 이용한 HTTPS 인증서 발급 및 적용 노루발 18   2021-01-12 2021-01-12 16:57
snap 설치 및 업데이트 sudo snap install core; sudo snap refresh core certbot 설치 sudo snap install --classic certbot 심볼릭 링크 생성 sudo ln -s /snap/bin/certbot /usr/bin/certbot nginx에 맞춰 자동 설정 sudo certbot --nginx 알아서 다 해주기...  
3 리캡챠 적용 [1] 노루발 11   2021-01-08 2021-01-11 12:15
XE 회원가입 시 구글 리캡챠 인증 추가하기 : 네이버 블로그 (naver.com)  
2 Bootstrap4 container class가 적용된 div의 양 옆에 설정하지 않은 margin이 생김 노루발 5   2024-02-07 2024-02-07 14:25
문제: <div class="container"> TEST </div> 위와 같은 페이지를 브라우저에서 렌더링 시 div의 양 옆에 설정하지 않은 빈 margin이 생김. 해결: <div class="container-fluid"> TEST </div> margin을 0으로 주고 width를 100%로 주고 등등 별걸 다 해봤는데 ...  
1 express.js 세션 적용 후 리다이렉트 시 세션 적용이 제대로 안 되는 문제점 노루발 4   2024-02-07 2024-02-07 14:23
문제: logout.js router.get('/', (req, res) => { req.session.destroy(); res.redirect('/login'); }); login.js if (result[0] !== undefined) { // 로그인에 성공하였으므로 세션을 할당 req.session.uid = result[0].uid; req.session.us...