Motor Sınıfı
GuiObject
*Bu içerik, yapay zekâ (beta) kullanılarak çevrildi ve hatalar içerebilir. Sayfayı İngilizce görüntülemek için buraya tıkla.
Özet
Özellikler
Yöntemler
TweenPosition(endPosition: UDim2,easingDirection: Enum.EasingDirection,easingStyle: Enum.EasingStyle,time: number,override: boolean,callback: function):boolean |
TweenSize(endSize: UDim2,easingDirection: Enum.EasingDirection,easingStyle: Enum.EasingStyle,time: number,override: boolean,callback: function):boolean |
TweenSizeAndPosition(endSize: UDim2,endPosition: UDim2,easingDirection: Enum.EasingDirection,easingStyle: Enum.EasingStyle,time: number,override: boolean,callback: function):boolean |
Olaylar
DragBegin(initialPosition: UDim2):RBXScriptSignal |
DragStopped(x: number,y: number):RBXScriptSignal |
InputBegan(input: InputObject):RBXScriptSignal |
InputChanged(input: InputObject):RBXScriptSignal |
InputEnded(input: InputObject):RBXScriptSignal |
MouseEnter(x: number,y: number):RBXScriptSignal |
MouseLeave(x: number,y: number):RBXScriptSignal |
MouseMoved(x: number,y: number):RBXScriptSignal |
TouchLongPress(touchPositions: {any},state: Enum.UserInputState):RBXScriptSignal |
TouchPan(touchPositions: {any},totalTranslation: Vector2,velocity: Vector2,state: Enum.UserInputState):RBXScriptSignal |
TouchPinch(touchPositions: {any},scale: number,velocity: number,state: Enum.UserInputState):RBXScriptSignal |
TouchRotate(touchPositions: {any},rotation: number,velocity: number,state: Enum.UserInputState):RBXScriptSignal |
TouchSwipe(swipeDirection: Enum.SwipeDirection,numberOfTouches: number):RBXScriptSignal |
TouchTap(touchPositions: {any}):RBXScriptSignal |
Devralınan Üyeler
GuiBase2d kaynağından 12 tane devralındı
Instance kaynağından 57 tane devralındı
Object kaynağından 6 tane devralındı
Devralan
API Referansı
Özellikler
Active
Kod Örnekleri
TextButton Aktif Debounce
-- Bu LocalScript'i bir TextButton (veya ImageButton) içine yerleştirin
local textButton = script.Parent
textButton.Text = "Bana tıklayın"
textButton.Active = true
local function onActivated()
-- Bu bir debounce gibi davranır
textButton.Active = false
-- 5'ten geri sayım yapın
for i = 5, 1, -1 do
textButton.Text = "Zaman: " .. i
task.wait(1)
end
textButton.Text = "Bana tıklayın"
textButton.Active = true
end
textButton.Activated:Connect(onActivated)AnchorPoint
Kod Örnekleri
AnchorPoint Demo
local guiObject = script.Parent
while true do
-- Sol üst
guiObject.AnchorPoint = Vector2.new(0, 0)
guiObject.Position = UDim2.new(0, 0, 0, 0)
task.wait(1)
-- Üst
guiObject.AnchorPoint = Vector2.new(0.5, 0)
guiObject.Position = UDim2.new(0.5, 0, 0, 0)
task.wait(1)
-- Sağ üst
guiObject.AnchorPoint = Vector2.new(1, 0)
guiObject.Position = UDim2.new(1, 0, 0, 0)
task.wait(1)
-- Sol
guiObject.AnchorPoint = Vector2.new(0, 0.5)
guiObject.Position = UDim2.new(0, 0, 0.5, 0)
task.wait(1)
-- Tam merkez
guiObject.AnchorPoint = Vector2.new(0.5, 0.5)
guiObject.Position = UDim2.new(0.5, 0, 0.5, 0)
task.wait(1)
-- Sağ
guiObject.AnchorPoint = Vector2.new(1, 0.5)
guiObject.Position = UDim2.new(1, 0, 0.5, 0)
task.wait(1)
-- Sol alt
guiObject.AnchorPoint = Vector2.new(0, 1)
guiObject.Position = UDim2.new(0, 0, 1, 0)
task.wait(1)
-- Alt
guiObject.AnchorPoint = Vector2.new(0.5, 1)
guiObject.Position = UDim2.new(0.5, 0, 1, 0)
task.wait(1)
-- Sağ alt
guiObject.AnchorPoint = Vector2.new(1, 1)
guiObject.Position = UDim2.new(1, 0, 1, 0)
task.wait(1)
endAutomaticSize
Kod Örnekleri
ScreenGui'de LocalScript
-- Çıktı için metin etiketleri/yazı tipleri/boyutlar dizisi
local labelArray = {
{ text = "Lorem", font = Enum.Font.Creepster, size = 50 },
{ text = "ipsum", font = Enum.Font.IndieFlower, size = 35 },
{ text = "dolor", font = Enum.Font.Antique, size = 55 },
{ text = "sit", font = Enum.Font.SpecialElite, size = 65 },
{ text = "amet", font = Enum.Font.FredokaOne, size = 40 },
}
-- Otomatik boyutlu bir ana çerçeve oluştur
local parentFrame = Instance.new("Frame")
parentFrame.AutomaticSize = Enum.AutomaticSize.XY
parentFrame.BackgroundColor3 = Color3.fromRGB(90, 90, 90)
parentFrame.Size = UDim2.fromOffset(25, 100)
parentFrame.Position = UDim2.fromScale(0.1, 0.1)
parentFrame.Parent = script.Parent
-- Bir liste yerleşimi ekle
local listLayout = Instance.new("UIListLayout")
listLayout.Padding = UDim.new(0, 5)
listLayout.Parent = parentFrame
-- Görsel estetik için yuvarlak köşeler ve padding ayarla
local roundedCornerParent = Instance.new("UICorner")
roundedCornerParent.Parent = parentFrame
local uiPaddingParent = Instance.new("UIPadding")
uiPaddingParent.PaddingTop = UDim.new(0, 5)
uiPaddingParent.PaddingLeft = UDim.new(0, 5)
uiPaddingParent.PaddingRight = UDim.new(0, 5)
uiPaddingParent.PaddingBottom = UDim.new(0, 5)
uiPaddingParent.Parent = parentFrame
for i = 1, #labelArray do
-- Diziden otomatik boyutlandırılan bir metin etiketi oluştur
local childLabel = Instance.new("TextLabel")
childLabel.AutomaticSize = Enum.AutomaticSize.XY
childLabel.Size = UDim2.fromOffset(75, 15)
childLabel.Text = labelArray[i]["text"]
childLabel.Font = labelArray[i]["font"]
childLabel.TextSize = labelArray[i]["size"]
childLabel.TextColor3 = Color3.new(1, 1, 1)
childLabel.Parent = parentFrame
-- Görsel estetik
local roundedCorner = Instance.new("UICorner")
roundedCorner.Parent = childLabel
local uiPadding = Instance.new("UIPadding")
uiPadding.PaddingTop = UDim.new(0, 5)
uiPadding.PaddingLeft = UDim.new(0, 5)
uiPadding.PaddingRight = UDim.new(0, 5)
uiPadding.PaddingBottom = UDim.new(0, 5)
uiPadding.Parent = childLabel
task.wait(2)
endBackgroundColor
BackgroundColor3
Kod Örnekleri
Gökkuşağı Çerçevesi
-- Bu kodu bir Çerçeve içinde LocalScript'e koyun
local frame = script.Parent
while true do
for hue = 0, 255, 4 do
-- HSV = ton, doygunluk, değer
-- 0'dan 1'e tekrar tekrar dönersek, bir gökkuşağı elde ederiz!
frame.BorderColor3 = Color3.fromHSV(hue / 256, 1, 1)
frame.BackgroundColor3 = Color3.fromHSV(hue / 256, 0.5, 0.8)
task.wait()
end
endBorderColor
BorderColor3
Kod Örnekleri
Düğme Vurgusu
-- Beni bir GuiObject'in içine koy, tercihen bir ImageButton/TextButton
local button = script.Parent
local function onEnter()
button.BorderSizePixel = 2
button.BorderColor3 = Color3.new(1, 1, 0) -- Sarı
end
local function onLeave()
button.BorderSizePixel = 1
button.BorderColor3 = Color3.new(0, 0, 0) -- Siyah
end
-- Olayları bağla
button.MouseEnter:Connect(onEnter)
button.MouseLeave:Connect(onLeave)
-- Varsayılan durumumuz "üzerine gelinmemiş"
onLeave()BorderSizePixel
Kod Örnekleri
Düğme Vurgusu
-- Beni bir GuiObject'in içine koy, tercihen bir ImageButton/TextButton
local button = script.Parent
local function onEnter()
button.BorderSizePixel = 2
button.BorderColor3 = Color3.new(1, 1, 0) -- Sarı
end
local function onLeave()
button.BorderSizePixel = 1
button.BorderColor3 = Color3.new(0, 0, 0) -- Siyah
end
-- Olayları bağla
button.MouseEnter:Connect(onEnter)
button.MouseLeave:Connect(onLeave)
-- Varsayılan durumumuz "üzerine gelinmemiş"
onLeave()Draggable
NextSelectionDown
Kod Örnekleri
Oyun Denetleyici Seçim Ağı Oluşturma
-- Aşağıdaki kodu kullanarak Gamepad seçim ağını ayarlayın
local container = script.Parent:FindFirstChild("Container")
local grid = container:GetChildren()
local rowSize = container:FindFirstChild("UIGridLayout").FillDirectionMaxCells
for _, gui in pairs(grid) do
if gui:IsA("GuiObject") then
local pos = gui.Name
-- Sol kenar
gui.NextSelectionLeft = container:FindFirstChild(pos - 1)
-- Sağ kenar
gui.NextSelectionRight = container:FindFirstChild(pos + 1)
-- Yukarı
gui.NextSelectionUp = container:FindFirstChild(pos - rowSize)
-- Aşağı
gui.NextSelectionDown = container:FindFirstChild(pos + rowSize)
end
end
-- Aşağıdaki kodu kullanarak Gamepad seçim ağını test edin
local GuiService = game:GetService("GuiService")
local UserInputService = game:GetService("UserInputService")
GuiService.SelectedObject = container:FindFirstChild("1")
function updateSelection(input)
if input.UserInputType == Enum.UserInputType.Keyboard then
local key = input.KeyCode
local selectedObject = GuiService.SelectedObject
if not selectedObject then
return
end
if key == Enum.KeyCode.Up then
if not selectedObject.NextSelectionUp then
GuiService.SelectedObject = selectedObject
end
elseif key == Enum.KeyCode.Down then
if not selectedObject.NextSelectionDown then
GuiService.SelectedObject = selectedObject
end
elseif key == Enum.KeyCode.Left then
if not selectedObject.NextSelectionLeft then
GuiService.SelectedObject = selectedObject
end
elseif key == Enum.KeyCode.Right then
if not selectedObject.NextSelectionRight then
GuiService.SelectedObject = selectedObject
end
end
end
end
UserInputService.InputBegan:Connect(updateSelection)NextSelectionLeft
Kod Örnekleri
Oyun Denetleyici Seçim Ağı Oluşturma
-- Aşağıdaki kodu kullanarak Gamepad seçim ağını ayarlayın
local container = script.Parent:FindFirstChild("Container")
local grid = container:GetChildren()
local rowSize = container:FindFirstChild("UIGridLayout").FillDirectionMaxCells
for _, gui in pairs(grid) do
if gui:IsA("GuiObject") then
local pos = gui.Name
-- Sol kenar
gui.NextSelectionLeft = container:FindFirstChild(pos - 1)
-- Sağ kenar
gui.NextSelectionRight = container:FindFirstChild(pos + 1)
-- Yukarı
gui.NextSelectionUp = container:FindFirstChild(pos - rowSize)
-- Aşağı
gui.NextSelectionDown = container:FindFirstChild(pos + rowSize)
end
end
-- Aşağıdaki kodu kullanarak Gamepad seçim ağını test edin
local GuiService = game:GetService("GuiService")
local UserInputService = game:GetService("UserInputService")
GuiService.SelectedObject = container:FindFirstChild("1")
function updateSelection(input)
if input.UserInputType == Enum.UserInputType.Keyboard then
local key = input.KeyCode
local selectedObject = GuiService.SelectedObject
if not selectedObject then
return
end
if key == Enum.KeyCode.Up then
if not selectedObject.NextSelectionUp then
GuiService.SelectedObject = selectedObject
end
elseif key == Enum.KeyCode.Down then
if not selectedObject.NextSelectionDown then
GuiService.SelectedObject = selectedObject
end
elseif key == Enum.KeyCode.Left then
if not selectedObject.NextSelectionLeft then
GuiService.SelectedObject = selectedObject
end
elseif key == Enum.KeyCode.Right then
if not selectedObject.NextSelectionRight then
GuiService.SelectedObject = selectedObject
end
end
end
end
UserInputService.InputBegan:Connect(updateSelection)NextSelectionRight
Kod Örnekleri
Oyun Denetleyici Seçim Ağı Oluşturma
-- Aşağıdaki kodu kullanarak Gamepad seçim ağını ayarlayın
local container = script.Parent:FindFirstChild("Container")
local grid = container:GetChildren()
local rowSize = container:FindFirstChild("UIGridLayout").FillDirectionMaxCells
for _, gui in pairs(grid) do
if gui:IsA("GuiObject") then
local pos = gui.Name
-- Sol kenar
gui.NextSelectionLeft = container:FindFirstChild(pos - 1)
-- Sağ kenar
gui.NextSelectionRight = container:FindFirstChild(pos + 1)
-- Yukarı
gui.NextSelectionUp = container:FindFirstChild(pos - rowSize)
-- Aşağı
gui.NextSelectionDown = container:FindFirstChild(pos + rowSize)
end
end
-- Aşağıdaki kodu kullanarak Gamepad seçim ağını test edin
local GuiService = game:GetService("GuiService")
local UserInputService = game:GetService("UserInputService")
GuiService.SelectedObject = container:FindFirstChild("1")
function updateSelection(input)
if input.UserInputType == Enum.UserInputType.Keyboard then
local key = input.KeyCode
local selectedObject = GuiService.SelectedObject
if not selectedObject then
return
end
if key == Enum.KeyCode.Up then
if not selectedObject.NextSelectionUp then
GuiService.SelectedObject = selectedObject
end
elseif key == Enum.KeyCode.Down then
if not selectedObject.NextSelectionDown then
GuiService.SelectedObject = selectedObject
end
elseif key == Enum.KeyCode.Left then
if not selectedObject.NextSelectionLeft then
GuiService.SelectedObject = selectedObject
end
elseif key == Enum.KeyCode.Right then
if not selectedObject.NextSelectionRight then
GuiService.SelectedObject = selectedObject
end
end
end
end
UserInputService.InputBegan:Connect(updateSelection)NextSelectionUp
Kod Örnekleri
Oyun Denetleyici Seçim Ağı Oluşturma
-- Aşağıdaki kodu kullanarak Gamepad seçim ağını ayarlayın
local container = script.Parent:FindFirstChild("Container")
local grid = container:GetChildren()
local rowSize = container:FindFirstChild("UIGridLayout").FillDirectionMaxCells
for _, gui in pairs(grid) do
if gui:IsA("GuiObject") then
local pos = gui.Name
-- Sol kenar
gui.NextSelectionLeft = container:FindFirstChild(pos - 1)
-- Sağ kenar
gui.NextSelectionRight = container:FindFirstChild(pos + 1)
-- Yukarı
gui.NextSelectionUp = container:FindFirstChild(pos - rowSize)
-- Aşağı
gui.NextSelectionDown = container:FindFirstChild(pos + rowSize)
end
end
-- Aşağıdaki kodu kullanarak Gamepad seçim ağını test edin
local GuiService = game:GetService("GuiService")
local UserInputService = game:GetService("UserInputService")
GuiService.SelectedObject = container:FindFirstChild("1")
function updateSelection(input)
if input.UserInputType == Enum.UserInputType.Keyboard then
local key = input.KeyCode
local selectedObject = GuiService.SelectedObject
if not selectedObject then
return
end
if key == Enum.KeyCode.Up then
if not selectedObject.NextSelectionUp then
GuiService.SelectedObject = selectedObject
end
elseif key == Enum.KeyCode.Down then
if not selectedObject.NextSelectionDown then
GuiService.SelectedObject = selectedObject
end
elseif key == Enum.KeyCode.Left then
if not selectedObject.NextSelectionLeft then
GuiService.SelectedObject = selectedObject
end
elseif key == Enum.KeyCode.Right then
if not selectedObject.NextSelectionRight then
GuiService.SelectedObject = selectedObject
end
end
end
end
UserInputService.InputBegan:Connect(updateSelection)Selectable
Kod Örnekleri
Metin Kutusu Seçimini Sınırlama
local GuiService = game:GetService("GuiService")
local textBox = script.Parent
local function gainFocus()
textBox.Selectable = true
GuiService.SelectedObject = textBox
end
local function loseFocus(_enterPressed, _inputObject)
GuiService.SelectedObject = nil
textBox.Selectable = false
end
-- Fokus Kaybı ve Fokus Kazanma olayı tetiklenecektir çünkü textBox
-- TextBox türündedir
textBox.Focused:Connect(gainFocus)
textBox.FocusLost:Connect(loseFocus)Size
Kod Örnekleri
Sağlık Çubuğu
local Players = game:GetService("Players")
local player = Players.LocalPlayer
-- Script'i bir LocalScript'e yapıştırın
-- bir Çerçeve içinde yer alan bir Çerçeveye
local frame = script.Parent
local container = frame.Parent
container.BackgroundColor3 = Color3.new(0, 0, 0) -- siyah
-- Bu fonksiyon, humanoid'in sağlık durumu değiştiğinde çağrılır
local function onHealthChanged()
local human = player.Character.Humanoid
local percent = human.Health / human.MaxHealth
-- İç çubuğun boyutunu değiştirin
frame.Size = UDim2.new(percent, 0, 1, 0)
-- Sağlık çubuğunun rengini değiştirin
if percent < 0.1 then
frame.BackgroundColor3 = Color3.new(1, 0, 0) -- kırmızı
elseif percent < 0.4 then
frame.BackgroundColor3 = Color3.new(1, 1, 0) -- sarı
else
frame.BackgroundColor3 = Color3.new(0, 1, 0) -- yeşil
end
end
-- Bu fonksiyon, oyuncu doğduğunda çağrılır
local function onCharacterAdded(character)
local human = character:WaitForChild("Humanoid")
-- Desen: bir kez şimdi güncelle, sonra sağlık değiştiğinde her zaman
human.HealthChanged:Connect(onHealthChanged)
onHealthChanged()
end
-- Doğma dinleyicimizi bağlayın; eğer zaten doğduysa çağırın
player.CharacterAdded:Connect(onCharacterAdded)
if player.Character then
onCharacterAdded(player.Character)
endTransparency
Visible
Kod Örnekleri
UI Penceresi
local gui = script.Parent
local window = gui:WaitForChild("Window")
local toggleButton = gui:WaitForChild("ToggleWindow")
local closeButton = window:WaitForChild("Close")
local function toggleWindowVisbility()
-- Boolean'ı `not` anahtar kelimesini kullanarak ters çevir
window.Visible = not window.Visible
end
toggleButton.Activated:Connect(toggleWindowVisbility)
closeButton.Activated:Connect(toggleWindowVisbility)Yöntemler
TweenPosition
TweenSize
TweenSizeAndPosition
Olaylar
DragBegin
DragStopped
InputBegan
Parametreler
Kod Örnekleri
Görsel Nesnede Girişin Başlangıcını İzleme
-- InputBegan olayını kullanmak için, GuiObject'ı belirtmelisiniz
local gui = script.Parent
-- Çeşitli kullanıcı girişi türleri için birden fazla kullanım durumu sağlayan bir örnek fonksiyon
local function inputBegan(input)
if input.UserInputType == Enum.UserInputType.Keyboard then
print("Bir tuşa basılıyor! Tuş:", input.KeyCode)
elseif input.UserInputType == Enum.UserInputType.MouseButton1 then
print("Sol fare butonuna tıklandı, konum:", input.Position)
elseif input.UserInputType == Enum.UserInputType.MouseButton2 then
print("Sağ fare butonuna tıklandı, konum:", input.Position)
elseif input.UserInputType == Enum.UserInputType.Touch then
print("Bir dokunmatik ekran girişi başladı, konum:", input.Position)
elseif input.UserInputType == Enum.UserInputType.Gamepad1 then
print("Bir gamepad'de bir düğmeye basılıyor! Düğme:", input.KeyCode)
end
end
gui.InputBegan:Connect(inputBegan)InputChanged
Parametreler
Kod Örnekleri
GuiObject Giriş Değişti Demo
local UserInputService = game:GetService("UserInputService")
local gui = script.Parent
local function printMovement(input)
print("Pozisyon:", input.Position)
print("Hareket Delta:", input.Delta)
end
local function inputChanged(input)
if input.UserInputType == Enum.UserInputType.MouseMovement then
print("Fare taşındı!")
printMovement(input)
elseif input.UserInputType == Enum.UserInputType.MouseWheel then
print("Fare tekerleği döndürüldü!")
print("Tekerlek Hareketi:", input.Position.Z)
elseif input.UserInputType == Enum.UserInputType.Gamepad1 then
if input.KeyCode == Enum.KeyCode.Thumbstick1 then
print("Sol thumbstick hareket etti!")
printMovement(input)
elseif input.KeyCode == Enum.KeyCode.Thumbstick2 then
print("Sağ thumbstick hareket etti!")
printMovement(input)
elseif input.KeyCode == Enum.KeyCode.ButtonL2 then
print("Sol tetik üzerindeki basınç değişti!")
print("Basınç:", input.Position.Z)
elseif input.KeyCode == Enum.KeyCode.ButtonR2 then
print("Sağ tetik üzerindeki basınç değişti!")
print("Basınç:", input.Position.Z)
end
elseif input.UserInputType == Enum.UserInputType.Touch then
print("Kullanıcının parmağı ekranda hareket ediyor!")
printMovement(input)
elseif input.UserInputType == Enum.UserInputType.Gyro then
local _rotInput, rotCFrame = UserInputService:GetDeviceRotation()
local rotX, rotY, rotZ = rotCFrame:toEulerAnglesXYZ()
local rot = Vector3.new(math.deg(rotX), math.deg(rotY), math.deg(rotZ))
print("Kullanıcının mobil cihazının rotasyonu değişti!")
print("Pozisyon", rotCFrame.p)
print("Dönüş:", rot)
elseif input.UserInputType == Enum.UserInputType.Accelerometer then
print("Kullanıcının mobil cihazının ivmesi değişti!")
printMovement(input)
end
end
gui.InputChanged:Connect(inputChanged)InputEnded
Parametreler
Kod Örnekleri
Bir GuiObject'taki Girişin Sonunu Takip Etme
-- InputChanged olayını kullanmak için bir GuiObject belirtmelisiniz
local gui = script.Parent
-- Çeşitli kullanıcı giriş türleri için birden fazla kullanım durumları sağlayan bir örnek fonksiyon
local function inputEnded(input)
if input.UserInputType == Enum.UserInputType.Keyboard then
print("Bir tuş bırakıldı! Tuş:", input.KeyCode)
elseif input.UserInputType == Enum.UserInputType.MouseButton1 then
print("Sol fare düğmesi bırakıldı", input.Position)
elseif input.UserInputType == Enum.UserInputType.MouseButton2 then
print("Sağ fare düğmesi bırakıldı", input.Position)
elseif input.UserInputType == Enum.UserInputType.Touch then
print("Bir dokunmatik ekran girişi bırakıldı", input.Position)
elseif input.UserInputType == Enum.UserInputType.Gamepad1 then
print("Bir oyun kumandasında bir tuş bırakıldı! Tuş:", input.KeyCode)
end
end
gui.InputEnded:Connect(inputEnded)MouseEnter
Kod Örnekleri
Bir Mouse'un GuiObject İçine Girdiği Yeri Yazdırma
local guiObject = script.Parent
guiObject.MouseEnter:Connect(function(x, y)
print("Kullanıcının fare imleci GuiObject'e konumda girdi", x, ",", y)
end)MouseWheelBackward
MouseWheelForward
SelectionGained
Kod Örnekleri
GUI Seçimi Yönetimi
local guiObject = script.Parent
local function selectionGained()
print("Kullanıcı bu düğmeyi gamepad ile seçti.")
end
guiObject.SelectionGained:Connect(selectionGained)SelectionLost
Kod Örnekleri
GUI Seçimi Kaybını İşleme
local guiObject = script.Parent
local function selectionLost()
print("Kullanıcı artık bunu oyun koluyla seçili durumda değil.")
end
guiObject.SelectionLost:Connect(selectionLost)TouchLongPress
Parametreler
Kod Örnekleri
Dokunma Uzun Basma ile UI Elemanını Taşı
local frame = script.Parent
frame.Active = true
local dragging = false
local basePosition
local startTouchPosition
local borderColor3
local backgroundColor3
local function onTouchLongPress(touchPositions, state)
if state == Enum.UserInputState.Begin and not dragging then
-- Bir sürükleme başlat
dragging = true
basePosition = frame.Position
startTouchPosition = touchPositions[1]
-- Sürüklemenin gerçekleştiğini göstermek için çerçeveyi renklendir
borderColor3 = frame.BorderColor3
backgroundColor3 = frame.BackgroundColor3
frame.BorderColor3 = Color3.new(1, 1, 1) -- Beyaz
frame.BackgroundColor3 = Color3.new(0, 0, 1) -- Mavi
elseif state == Enum.UserInputState.Change then
local touchPosition = touchPositions[1]
local deltaPosition =
UDim2.new(0, touchPosition.X - startTouchPosition.X, 0, touchPosition.Y - startTouchPosition.Y)
frame.Position = basePosition + deltaPosition
elseif state == Enum.UserInputState.End and dragging then
-- Sürüklemeyi durdur
dragging = false
frame.BorderColor3 = borderColor3
frame.BackgroundColor3 = backgroundColor3
end
end
frame.TouchLongPress:Connect(onTouchLongPress)TouchPan
GuiObject.TouchPan(
Parametreler
Kod Örnekleri
Kaydırma UI Elemanı
local innerFrame = script.Parent
local outerFrame = innerFrame.Parent
outerFrame.BackgroundTransparency = 0.75
outerFrame.Active = true
outerFrame.Size = UDim2.new(1, 0, 1, 0)
outerFrame.Position = UDim2.new(0, 0, 0, 0)
outerFrame.AnchorPoint = Vector2.new(0, 0)
outerFrame.ClipsDescendants = true
local dragging = false
local basePosition
local function onTouchPan(_touchPositions, totalTranslation, _velocity, state)
if state == Enum.UserInputState.Begin and not dragging then
dragging = true
basePosition = innerFrame.Position
outerFrame.BackgroundTransparency = 0.25
elseif state == Enum.UserInputState.Change then
innerFrame.Position = basePosition + UDim2.new(0, totalTranslation.X, 0, totalTranslation.Y)
elseif state == Enum.UserInputState.End and dragging then
dragging = false
outerFrame.BackgroundTransparency = 0.75
end
end
outerFrame.TouchPan:Connect(onTouchPan)TouchPinch
GuiObject.TouchPinch(
Parametreler
Kod Örnekleri
Yumru/Çekme Ölçeklendirme
local innerFrame = script.Parent
local outerFrame = innerFrame.Parent
outerFrame.BackgroundTransparency = 0.75
outerFrame.Active = true
outerFrame.Size = UDim2.new(1, 0, 1, 0)
outerFrame.Position = UDim2.new(0, 0, 0, 0)
outerFrame.AnchorPoint = Vector2.new(0, 0)
outerFrame.ClipsDescendants = true
local dragging = false
local uiScale = Instance.new("UIScale")
uiScale.Parent = innerFrame
local baseScale
local function onTouchPinch(_touchPositions, scale, _velocity, state)
if state == Enum.UserInputState.Begin and not dragging then
dragging = true
baseScale = uiScale.Scale
outerFrame.BackgroundTransparency = 0.25
elseif state == Enum.UserInputState.Change then
uiScale.Scale = baseScale * scale -- Burada çarpma işlemi var
elseif state == Enum.UserInputState.End and dragging then
dragging = false
outerFrame.BackgroundTransparency = 0.75
end
end
outerFrame.TouchPinch:Connect(onTouchPinch)TouchRotate
GuiObject.TouchRotate(
Parametreler
Kod Örnekleri
Dokunma Dönmesi
local innerFrame = script.Parent
local outerFrame = innerFrame.Parent
outerFrame.BackgroundTransparency = 0.75
outerFrame.Active = true
outerFrame.Size = UDim2.new(1, 0, 1, 0)
outerFrame.Position = UDim2.new(0, 0, 0, 0)
outerFrame.AnchorPoint = Vector2.new(0, 0)
outerFrame.ClipsDescendants = true
local dragging = false
local baseRotation = innerFrame.Rotation
local function onTouchRotate(_touchPositions, rotation, _velocity, state)
if state == Enum.UserInputState.Begin and not dragging then
dragging = true
baseRotation = innerFrame.Rotation
outerFrame.BackgroundTransparency = 0.25
elseif state == Enum.UserInputState.Change then
innerFrame.Rotation = baseRotation + rotation
elseif state == Enum.UserInputState.End and dragging then
dragging = false
outerFrame.BackgroundTransparency = 0.75
end
end
outerFrame.TouchRotate:Connect(onTouchRotate)TouchSwipe
Parametreler
Kod Örnekleri
Zıplayan Renk Seçici
local frame = script.Parent
frame.Active = true
-- Başarılı bir kaydırmada çerçevenin ne kadar zıplaması gerektiği
local BOUNCE_DISTANCE = 50
-- Çerçevenin mevcut durumu
local basePosition = frame.Position
local hue = 0
local saturation = 128
local function updateColor()
frame.BackgroundColor3 = Color3.fromHSV(hue / 256, saturation / 256, 1)
end
local function onTouchSwipe(swipeDir, _touchCount)
-- Kaydırma yönüne bağlı olarak BackgroundColor3'ü değiştir
local deltaPos
if swipeDir == Enum.SwipeDirection.Right then
deltaPos = UDim2.new(0, BOUNCE_DISTANCE, 0, 0)
hue = (hue + 16) % 255
elseif swipeDir == Enum.SwipeDirection.Left then
deltaPos = UDim2.new(0, -BOUNCE_DISTANCE, 0, 0)
hue = (hue - 16) % 255
elseif swipeDir == Enum.SwipeDirection.Up then
deltaPos = UDim2.new(0, 0, 0, -BOUNCE_DISTANCE)
saturation = (saturation + 16) % 255
elseif swipeDir == Enum.SwipeDirection.Down then
deltaPos = UDim2.new(0, 0, 0, BOUNCE_DISTANCE)
saturation = (saturation - 16) % 255
else
deltaPos = UDim2.new()
end
-- Rengi güncelle ve çerçeveyi biraz zıplat
updateColor()
frame.Position = basePosition + deltaPos
frame:TweenPosition(basePosition, Enum.EasingDirection.Out, Enum.EasingStyle.Bounce, 0.7, true)
end
frame.TouchSwipe:Connect(onTouchSwipe)
updateColor()TouchTap
Parametreler
Kod Örnekleri
Şeffaflık Anahtarını Değiştir
local frame = script.Parent
frame.Active = true
local function onTouchTap()
-- Arka plan şeffaflığını değiştir
if frame.BackgroundTransparency > 0 then
frame.BackgroundTransparency = 0
else
frame.BackgroundTransparency = 0.75
end
end
frame.TouchTap:Connect(onTouchTap)