Script v1.7.1.0
- AI
- Animals
- Contracts
- Debug
- Economy
- Effects
- Events
- Farms
- GUI
- Handtools
- I3d
- Materials
- Misc
- Objects
- Placeables
- Player
- Shop
- Sounds
- Specializations
- Triggers
- Utils
- Vehicles
- Weather
Engine v1.7.1.0
- AI
- Animation
- Camera
- Entity
- Fillplanes
- General
- I3D
- Input
- Lighting
- Math
- Network
- Node
- Overlays
- Particle System
- Physics
- JointConstructor:setActors
- JointConstructor:setJointTransforms
- addDifferential
- addForce
- addImpulse
- addTorque
- addTorqueImpulse
- addVehicleLink
- computeWheelShapeTireForces
- createCCT
- createWheelShape
- getAngularDamping
- getAngularVelocity
- getCCTCollisionFlags
- getCenterOfMass
- getCollisionMask
- getDensity
- getLinearDamping
- getLinearVelocity
- getMass
- getMotorRotationSpeed
- getRigidBodyType
- getVelocityAtLocalPos
- getVelocityAtWorldPos
- getVolume
- getWheelShapeAxleSpeed
- getWheelShapeContactForce
- getWheelShapeContactNormal
- getWheelShapeContactObject
- getWheelShapeContactPoint
- getWheelShapePosition
- getWheelShapeSlip
- moveCCT
- overlapBox
- overlapSphere
- raycastAll
- raycastClosest
- removeCCT
- setAngularDamping
- setAngularVelocity
- setCenterOfMass
- setCollisionMask
- setFrictionVelocity
- setJointDrive
- setLinearDamping
- setLinearVelocity
- setMass
- setRigidBodyType
- setSolverIterationCount
- setWheelShapeForcePoint
- setWheelShapeProps
- setWheelShapeTireFriction
- simulatePhysics
- simulatePhysicsTimeScale
- updateDifferential
- Rendering
- Scenegraph
- Shape
- Sound
- Spline
- String
- Terrain Detail
- Text Rendering
- Tire Track
- XML
- general
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 transX, transY = self:getHidingTranslation() |
111 | local startX, startY = self:getPosition() |
112 | |
113 | local sequence = TweenSequence.new(self) |
114 | sequence:insertTween(MultiValueTween:new(self.setPosition, {startX, startY}, {self.origX, self.origY}, HUDDisplayElement.MOVE_ANIMATION_DURATION), 0) |
115 | sequence:addCallback(self.onAnimateVisibilityFinished, true) |
116 | sequence:start() |
117 | self.animation = sequence |
118 | 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 |
22 | function HUDDisplayElement.new(subClass, overlay, parentHudElement) |
23 | if not subClass or subClass == HUDDisplayElement then |
24 | subClass = HUDDisplayElement_mt |
25 | end |
26 | |
27 | local self = HUDDisplayElement:superClass().new(subClass, overlay, parentHudElement) |
28 | |
29 | self.origX, self.origY = 0, 0 -- original positions, stored to support stable animation states |
30 | |
31 | return self |
32 | end |
onAnimateVisibilityFinished
DescriptionCalled when a hiding or showing animation has finished.Definition
onAnimateVisibilityFinished()Code
122 | function HUDDisplayElement:onAnimateVisibilityFinished(isVisible) |
123 | if not isVisible then -- delayed call when hiding |
124 | HUDDisplayElement:superClass().setVisible(self, isVisible) |
125 | end |
126 | 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. |
38 | function HUDDisplayElement:setVisible(isVisible, animate) |
39 | if animate and self.animation:getFinished() then |
40 | if isVisible then |
41 | self:animateShow() |
42 | else |
43 | self:animateHide() |
44 | end |
45 | else |
46 | self.animation:stop() |
47 | HUDDisplayElement:superClass().setVisible(self, isVisible) |
48 | |
49 | local posX, posY = self:getPosition() |
50 | local transX, transY = self:getHidingTranslation() |
51 | if isVisible then |
52 | self:setPosition(self.origX, self.origY) |
53 | else |
54 | self:setPosition(posX + transX, posY + transY) |
55 | end |
56 | end |
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 |