Script v1_7_1_0
- AI
- Animals
- Collections
- Contracts
- Debug
- Economy
- Elements
- EnvironmentalScore
- Errors
- Events
- GUI
- AnimalScreen
- AnimationElement
- BitmapElement
- BoxLayoutElement
- BreadcrumbsElement
- ButtonElement
- ButtonOverlay
- ChatWindow
- CheckedOptionElement
- ClearElement
- ColorPickButtonElement
- ConstructionScreen
- ContextActionDisplay
- ControlBarDisplay
- DialogElement
- DynamicFadedBitmapElement
- FillLevelsDisplay
- FlowLayoutElement
- FocusManager
- FrameElement
- FrameReferenceElement
- GameInfoDisplay
- GameInfoDisplayMobile
- GamePausedDisplay
- Gui
- GuiDataSource
- GuiElement
- GuiMixin
- GuiOverlay
- GuiProfile
- GuiSoundPlayer
- GuiTopDownCamera
- GuiTopDownCursor
- GuiUtils
- HUDDisplayElement
- HUDElement
- HUDFrameElement
- HUDPopupMessage
- HUDSliderElement
- HUDTextDisplay
- IndexChangeSubjectMixin
- IndexStateElement
- InfoDisplay
- InfoHUDBox
- InGameIcon
- IngameMap
- IngameMapElement
- InputGlyphElement
- InputGlyphElementUI
- InputHelpDisplay
- KeyValueInfoHUDBox
- ListElement
- ListItemElement
- MapOverlayGenerator
- MixerWagonHUDExtension
- MultiTextOptionElement
- MultiValueTween
- Overlay
- PagingElement
- PictureElement
- PlatformIconElement
- PlayerControlPadDisplay
- PlaySampleMixin
- RenderElement
- RoundStatusBar
- ScreenElement
- ScrollingLayoutElement
- SettingsModel
- SideNotification
- SideNotificationMobile
- SliderElement
- SpeakerDisplay
- SpeedMeterDisplay
- SpeedSliderDisplay
- StatusBar
- SteeringSliderDisplay
- TabbedMenu
- TabbedMenuFrameElement
- TabbedMenuWithDetails
- TableElement
- TableHeaderElement
- TerrainLayerElement
- TextBackdropElement
- TextElement
- TextInputElement
- ThreePartBitmapElement
- TimerElement
- ToggleButtonElement
- TopNotification
- Tween
- TweenSequence
- VariableWorkWidthHUDExten...
- VehicleHUDExtension
- VehicleSchemaDisplay
- VideoElement
- WardrobeScreen
- Handtools
- Hud
- I3d
- Input
- Jobs
- Maps
- Materials
- Misc
- Objects
- Parameters
- Placeables
- Placement
- Player
- Shop
- Sounds
- Specialization
- Specializations
- StateMachine
- Statistics
- Tasks
- Triggers
- Utils
- Vehicles
Engine v1_7_1_0
- AI
- Animation
- Camera
- Entity
- Fillplanes
- general
- General
- I3D
- Input
- Lighting
- Math
- Network
- Node
- NoteNode
- Overlays
- Particle System
- Physics
- Rendering
- Scenegraph
- Shape
- Sound
- Spline
- String
- Terrain Detail
- Text Rendering
- Tire Track
- VoiceChat
- XML
Foundation Reference
HUDDisplayElement
DescriptionHUD display element whose subclasses implement more complex HUD display subsystems.Parent
HUDElementFunctions
- animateHide
- animateShow
- animationSetPositionX
- animationSetPositionY
- getHidingTranslation
- new
- onAnimateVisibilityFinished
- setScale
- setVisible
- storeOriginalPosition
animateHide
DescriptionAnimate this element on hiding.Definition
animateHide()Code
94 | function HUDDisplayElement:animateHide() |
95 | local transX, transY = self:getHidingTranslation() |
96 | local startX, startY = self:getPosition() |
97 | |
98 | local sequence = TweenSequence.new(self) |
99 | sequence:insertTween(MultiValueTween.new(self.setPosition, {startX, startY}, {startX + transX, startY + transY}, HUDDisplayElement.MOVE_ANIMATION_DURATION), 0) |
100 | sequence:addCallback(self.onAnimateVisibilityFinished, false) |
101 | sequence:start() |
102 | self.animation = sequence |
103 | end |
animateShow
DescriptionAnimate this element on showing.Definition
animateShow()Code
107 | function HUDDisplayElement:animateShow() |
108 | HUDDisplayElement:superClass().setVisible(self, true) |
109 | |
110 | local startX, startY = self:getPosition() |
111 | |
112 | local sequence = TweenSequence.new(self) |
113 | sequence:insertTween(MultiValueTween.new(self.setPosition, {startX, startY}, {self.origX, self.origY}, HUDDisplayElement.MOVE_ANIMATION_DURATION), 0) |
114 | sequence:addCallback(self.onAnimateVisibilityFinished, true) |
115 | sequence:start() |
116 | self.animation = sequence |
117 | end |
animationSetPositionX
DescriptionAnimation setter function for X position.Definition
animationSetPositionX()Code
82 | function HUDDisplayElement:animationSetPositionX(x) |
83 | self:setPosition(x, nil) |
84 | end |
animationSetPositionY
DescriptionAnimation setter function for Y position.Definition
animationSetPositionY()Code
88 | function HUDDisplayElement:animationSetPositionY(y) |
89 | self:setPosition(nil, y) |
90 | end |
getHidingTranslation
DescriptionGet the screen space translation for hiding. Override in sub-classes if a different translation is required.Definition
getHidingTranslation()Return Values
float | Screen | space X translation |
float | Screen | space Y translation |
76 | function HUDDisplayElement:getHidingTranslation() |
77 | return 0, -0.5 |
78 | end |
new
DescriptionCreate a new HUD display element.Definition
new(table subClass, table overlay, table parentHudElement)Arguments
table | subClass | Subclass metatable for inheritance |
table | overlay | Wrapped Overlay instance |
table | parentHudElement | [optional] Parent HUD element of the newly created HUD element |
table | HUDDisplayElement | instance |
23 | function HUDDisplayElement.new(overlay, parentHudElement, customMt) |
24 | local self = HUDDisplayElement:superClass().new(overlay, parentHudElement, customMt or HUDDisplayElement_mt) |
25 | |
26 | self.origX, self.origY = 0, 0 -- original positions, stored to support stable animation states |
27 | self.animationState = nil |
28 | |
29 | return self |
30 | end |
onAnimateVisibilityFinished
DescriptionCalled when a hiding or showing animation has finished.Definition
onAnimateVisibilityFinished()Code
121 | function HUDDisplayElement:onAnimateVisibilityFinished(isVisible) |
122 | if not isVisible then -- delayed call when hiding |
123 | HUDDisplayElement:superClass().setVisible(self, isVisible) |
124 | end |
125 | end |
setScale
DescriptionSimplification of scale setter because these high-level elements always use a uniform scale.Definition
setScale()Code
61 | function HUDDisplayElement:setScale(uiScale) |
62 | HUDDisplayElement:superClass().setScale(self, uiScale, uiScale) |
63 | end |
setVisible
DescriptionSet this element's visibility with optional animation.Definition
setVisible(bool isVisible, bool animate)Arguments
bool | isVisible | True is visible, false is not. |
bool | animate | If true, the element will play an animation before applying the visibility change. |
36 | function HUDDisplayElement:setVisible(isVisible, animate) |
37 | if animate and self.animation:getFinished() then |
38 | if isVisible then |
39 | self:animateShow() |
40 | else |
41 | self:animateHide() |
42 | end |
43 | else |
44 | self.animation:stop() |
45 | HUDDisplayElement:superClass().setVisible(self, isVisible) |
46 | |
47 | local posX, posY = self:getPosition() |
48 | local transX, transY = self:getHidingTranslation() |
49 | if isVisible then |
50 | self:setPosition(self.origX, self.origY) |
51 | else |
52 | self:setPosition(posX + transX, posY + transY) |
53 | end |
54 | end |
55 | |
56 | self.animationState = isVisible |
57 | end |
storeOriginalPosition
DescriptionStore the current element position as its original positions.Definition
storeOriginalPosition()Code
67 | function HUDDisplayElement:storeOriginalPosition() |
68 | self.origX, self.origY = self:getPosition() |
69 | end |