TGViewer
Moth Moth @namlessmoth · 44 subscribers
Post #130 81
Вобщем переписал управление свайпами с использованием своего палгина для мультитача
Проверил - всё работает
И выложил свой плагин в дискорде discord.com/channels/883781994583056384/1178765569487556748
Вот переписанный вариант управления:
export default function swipeComp() {
let left
let right
let up

return {
id: "swipeComp",
require: [],
direction: vec2(0),
move: false,
isAction: false,
action: false,

add() {

right = this.add([
pos(width() / 2, height()),
rect(width() / 2, height()/2),
opacity(0),
fixed(),
area(),
anchor("botleft"),
multitouch(),
])

left = this.add([
pos(0,height()),
rect(width() / 2, height()/2),
opacity(0),
fixed(),
area(),
anchor("botleft"),
multitouch(),
])

up = this.add([
pos(),
rect(width(), height()/2),
opacity(0),
fixed(),
area(),
multitouch(),
])

onResize(() => {
left.pos = vec2(0,height())
left.width = width() / 2
left.height = height() / 2
right.pos = vec2(width() / 2, height())
right.width = width() / 2
right.height = height() / 2
up.pos = vec2(0)
up.width = width()
up.height = height() / 2
})

up.onPointUpdate(() => {
if (this.isAction) return
this.direction.y = -1
})

right.onPoint(() => {
if (this.isAction) return
this.direction.x = 1
this.parent.trigger("startMove")
})

left.onPoint(() => {
if (this.isAction) return
this.direction.x = -1
this.parent.trigger("startMove")
})

right.onPointUpdate(() => {
if (this.isAction) return
this.direction.x += 0.1
})

left.onPointUpdate(() => {
if (this.isAction) return
this.direction.x -= 0.1
})

this.onPointUpdate(() => {
this.parent.trigger("input", this.direction.unit())
})

this.onPointEnd((num) => {
if (num <= 1) {
this.parent.trigger("endMove")
this.direction = vec2(0)
}
})

let lastTouchPos = null

this.onTouchStart(() => {
lastTouchPos = mousePos()
})

this.onTouchMove(() => {

this.isAction = true

if (mousePos().dist(lastTouchPos) > 10) {
this.parent.trigger("action")
if (!this.action) {
this.parent.trigger("startAction")
this.action = true
}

this.direction = mousePos().sub(lastTouchPos).unit()
}

lastTouchPos = mousePos()
})

this.onTouchEnd(() => {
lastTouchPos = null
this.direction = vec2(0)
this.move = false
this.action = false
this.isAction = false
})

}
}
}

Предыдущий вариант тут можете сравнить
Discord Discord - A New Way to Chat with Friends & Communities Discord is the easiest way to communicate over voice, video, and text. Chat, hang out, and stay close with your friends and communities.
  • ❤ 2
More from @namlessmoth
  1. Mar 7, 2026Как сломать босса одним прокачанным навыком Причём первую заратану я победил точно так же,…
  2. Mar 3, 2026Наиграл уже 150+ часов и даже не прошел половину игры Мне капец как не везёт почти в каждо…
  3. Feb 17, 2026Один месяц подписки на впн Вдруг кому надо https://t.me/gruVPNbot?start=g_UZhunlWNfFC_2127…
  4. Feb 16, 2026оставлю тут, чтобы не потерять вам смотреть нельзя, это только для меня
  5. Feb 13, 2026Вчера сделал всего три задания и все три оказались не правильными 1) Задание: Проведите ре…
  6. Feb 12, 2026Оказалось что всё-таки можно сдавать несколько заданий за один раз. Я вчера сдал 7 заданий…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →