魔兽世界UI设计:创建可拖拽的背景图层及动画效果

本教程将引导您使用Lua脚本在魔兽世界UI设计中创建一个可拖拽的背景图层,并添加动画效果,以增强用户界面的视觉吸引力。lualocal MysteryKeyDrop = CreateFrame('Frame', 'MysteryKeyDrop', UIParent)MysteryKeyDrop:SetSize(600, 600)MysteryKeyDrop:SetScript('OnDragStart', MysteryKeyDrop.StartMoving)MysteryKeyDrop:SetScript('OnHide', MysteryKeyDrop.StopMovingOrSizing)MysteryKeyDrop:SetScript('OnDragStop', MysteryKeyDrop.StopMovingOrSizing)MysteryKeyDrop:SetPoint('CENTER', 0, 0)MysteryKeyDrop:SetBackdrop({bgFile = 'Interface\ICONS\damijingbeijing'})MysteryKeyDrop:Hide()

local MysteryKeyDrop1 = CreateFrame('Frame', 'MysteryKeyDrop1', MysteryKeyDrop)MysteryKeyDrop1:SetSize(256, 256)MysteryKeyDrop1:SetPoint('CENTER', 0, 70)MysteryKeyDrop1:SetBackdrop({bgFile = 'Interface\ICONS\damijingbeijingguangquanbeijing'})

-- 装饰元素local MysteryKeyDrop2 = CreateFrame('Frame', 'MysteryKeyDrop1', MysteryKeyDrop1)MysteryKeyDrop2:SetSize(320, 320)MysteryKeyDrop2:SetPoint('CENTER', 0, 0)MysteryKeyDrop2:SetBackdrop({bgFile = 'Interface\ICONS\damijingbeijinghua1'})

-- ... 其他装饰元素 ...

-- 文字框local MysteryLevel = MysteryKeyDrop:CreateFontString('MysteryLevel', 'OVERLAY', 'GameFontNormal') MysteryLevel:SetText('秘境难度:'..'1')MysteryLevel:SetFont(MyUFont, 40)MysteryLevel:SetPoint('TOP', MysteryKeyDrop, 'TOP', 0, -40)MysteryLevel:SetHeight(20)MysteryLevel:Hide()

-- ... 其他文字框 ...

-- 转动的圈圈1local MysteryKeyDrop6 = CreateFrame('Frame', 'MysteryKeyDrop1', MysteryKeyDrop1)MysteryKeyDrop6:SetSize(210, 210)MysteryKeyDrop6:SetPoint('CENTER', 0, 0)local texture = MysteryKeyDrop6:CreateTexture()texture:SetTexture('Interface\ICONS\damijingbeijingguangquan1')texture:SetAllPoints()texture:SetBlendMode('ADD')local MysteryKeyDrop6animation = texture:CreateAnimationGroup()local aa2 = MysteryKeyDrop6animation:CreateAnimation('Rotation')aa2:SetDegrees(360)aa2:SetDuration(10)aa2:SetSmoothing('OUT')MysteryKeyDrop6animation:SetLooping('BOUNCE')MysteryKeyDrop6animation:play()

-- ... 其他动画元素 ...

-- 按钮local MysteryCloseButten = CreateFrame('Button','MysteryCloseButten',MysteryKeyDrop)MysteryCloseButten:SetSize(40, 40)MysteryCloseButten:SetPoint('TOPRIGHT', -85, 0)MysteryCloseButten:EnableMouse(true)MysteryCloseButten:RegisterForDrag('LeftButton')MysteryCloseButten:Enable()MysteryCloseButten:SetNormalTexture('Interface\Buttons\UI-Panel-MinimizeButton-Up')MysteryCloseButten:SetPushedTexture('Interface\Buttons\UI-Panel-MinimizeButton-Down')MysteryCloseButten:SetHighlightTexture('Interface\Buttons\UI-Panel-MinimizeButton-Highlight','ADD')MysteryCloseButten:SetScript('OnClick',function(self) MysteryKeyDrop:Hide() end)

-- ... 其他按钮 ...

代码说明:

  1. 创建背景图层: 使用 CreateFrame('Frame', 'frameName', parentFrame) 创建一个框架作为背景图层,并设置其大小、位置和背景图片。2. 添加可拖拽功能: 使用 SetScript('OnDragStart', frame.StartMoving)SetScript('OnDragStop', frame.StopMovingOrSizing) 使背景图层可拖拽。3. 添加装饰元素: 创建额外的框架,并设置其背景图片和位置,以装饰背景图层。4. 添加文字框: 使用 CreateFontString('fontStringName', 'strata', 'font') 创建文字框,并设置其内容、字体、大小和位置。5. 创建动画效果: 使用 CreateAnimationGroup()CreateAnimation('animationType') 创建动画效果,例如旋转、缩放等。6. 添加按钮: 使用 CreateFrame('Button', 'buttonName', parentFrame, 'template') 创建按钮,并设置其纹理、大小、位置和点击事件。

通过以上步骤,您就可以在魔兽世界UI设计中创建出具有视觉吸引力的背景图层和动画效果,提升用户体


原文地址: https://www.cveoy.top/t/topic/8Kn 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录