Engine Class
KeyframeSequenceProvider
*เนื้อหานี้แปลโดยใช้ AI (เวอร์ชัน Beta) และอาจมีข้อผิดพลาด หากต้องการดูหน้านี้เป็นภาษาอังกฤษ ให้คลิกที่นี่
สรุป
วิธีการ
GetAnimations(userId: User):Instance |
GetAnimationsAsync(userId: User):Instance |
GetKeyframeSequence(assetId: ContentId):Instance |
GetKeyframeSequenceAsync(assetId: ContentId):Instance |
GetKeyframeSequenceById(assetId: number,useCache: boolean):Instance |
RegisterActiveKeyframeSequence(keyframeSequence: Instance):ContentId |
RegisterKeyframeSequence(keyframeSequence: Instance):ContentId |
ตัวอย่างโค้ด
สร้างแอนิเมชันชั่วคราว
local KeyframeSequenceProvider = game:GetService("KeyframeSequenceProvider")
local function createPreviewAnimation(keyframeSequence)
local hashId = KeyframeSequenceProvider:RegisterKeyframeSequence(keyframeSequence)
local Animation = Instance.new("Animation")
Animation.AnimationId = hashId
return Animation
end
local keyframeSequence = Instance.new("KeyframeSequence")
local animation = createPreviewAnimation(keyframeSequence)
print(animation)เอกสารอ้างอิงเกี่ยวกับ API
วิธีการ
GetAnimations
GetAnimationsAsync
พารามิเตอร์
ส่งค่ากลับ
ตัวอย่างโค้ด
KeyframeSequenceProvider GetAnimationsAsync
local KeyframeSequenceProvider = game:GetService("KeyframeSequenceProvider")
local USER_ID = 0 -- ใส่ UserId ของคุณที่นี่
local function extractPages(pagesObject)
local array = {}
while true do
local thisPage = pagesObject:GetCurrentPage()
for _, v in pairs(thisPage) do
table.insert(array, v)
end
if pagesObject.IsFinished then
break
end
pagesObject:AdvanceToNextPageAsync()
end
return array
end
local inventoryPages = KeyframeSequenceProvider:GetAnimationsAsync(USER_ID)
local animationIds = extractPages(inventoryPages)
for _, id in pairs(animationIds) do
print(id)
end
print("ทั้งหมด: ", #animationIds)GetKeyframeSequence
GetKeyframeSequenceAsync
พารามิเตอร์
assetId:ContentId |
ส่งค่ากลับ
ตัวอย่างโค้ด
การสร้าง KeyframeSequence ของการแอนิเมชัน
local KeyframeSequenceProvider = game:GetService("KeyframeSequenceProvider")
local ANIMATION_ID = "rbxassetid://507771019"
-- ดึง KeyframeSequence สำหรับ asset
local keyframeSequence
local success, err = pcall(function()
keyframeSequence = KeyframeSequenceProvider:GetKeyframeSequenceAsync(ANIMATION_ID)
end)
if success then
-- ทำซ้ำแต่ละ keyframe และพิมพ์ค่าเวลาของมัน
local keyframeTable = keyframeSequence:GetKeyframes()
for key, value in keyframeTable do
print(`เวลาของ keyframe หมายเลข {key} คือ: {value.Time}`)
end
else
print(`เกิดข้อผิดพลาดในการดึง KeyframeSequence: {err}`)
endGetKeyframeSequenceById
RegisterActiveKeyframeSequence
พารามิเตอร์
ส่งค่ากลับ
ContentId
ตัวอย่างโค้ด
สร้างแอนิเมชันชั่วคราว
local KeyframeSequenceProvider = game:GetService("KeyframeSequenceProvider")
local function createPreviewAnimation(keyframeSequence)
local hashId = KeyframeSequenceProvider:RegisterKeyframeSequence(keyframeSequence)
local Animation = Instance.new("Animation")
Animation.AnimationId = hashId
return Animation
end
local keyframeSequence = Instance.new("KeyframeSequence")
local animation = createPreviewAnimation(keyframeSequence)
print(animation)RegisterKeyframeSequence
พารามิเตอร์
ส่งค่ากลับ
ContentId
ตัวอย่างโค้ด
KeyframeSequenceProvider:RegisterKeyframeSequence
local KeyframeSequenceProvider = game:GetService("KeyframeSequenceProvider")
local asset = KeyframeSequenceProvider:RegisterKeyframeSequence(workspace.KeyframeSequence)
local animation = Instance.new("Animation")
animation.Name = "การทดสอบการเคลื่อนไหว"
animation.AnimationId = asset
animation.Parent = workspace