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
Tween
DescriptionTween class which linearly interpolates a quantity from a start value to an end value over a given duration.Functions
applyValue
DescriptionApply a value via the setter function.Definition
applyValue()Code
92 | function Tween:applyValue(newValue) |
93 | if self.functionTarget ~= nil then |
94 | self.setter(self.functionTarget, newValue) |
95 | else |
96 | self.setter(newValue) |
97 | end |
98 | end |
getDuration
DescriptionGet this tween's duration in milliseconds.Definition
getDuration()Code
39 | function Tween:getDuration() |
40 | return self.duration |
41 | end |
getFinished
DescriptionCheck if this tween has finished.Definition
getFinished()Code
45 | function Tween:getFinished() |
46 | return self.isFinished |
47 | end |
new
DescriptionCreate a new Tween.Definition
new(function setterFunction, float startValue, float endValue, float duration, table customMt)Arguments
function | setterFunction | Value setter function. Signature: callback(value) or callback(target, value). |
float | startValue | Original value |
float | endValue | Target value |
float | duration | Duration of tween in milliseconds |
table | customMt | Subclass metatable for inheritance |
20 | function Tween.new(setterFunction, startValue, endValue, duration, customMt) |
21 | local self = setmetatable({}, customMt or Tween_mt) |
22 | |
23 | self.setter = setterFunction |
24 | self.startValue = startValue |
25 | self.endValue = endValue |
26 | self.duration = duration |
27 | self.elapsedTime = 0 |
28 | |
29 | self.isFinished = duration == 0 |
30 | self.functionTarget = nil |
31 | |
32 | self.curveFunc = Tween.CURVE.LINEAR |
33 | |
34 | return self |
35 | end |
reset
DescriptionReset this tween to play it again.Definition
reset()Code
51 | function Tween:reset() |
52 | self.elapsedTime = 0 |
53 | self.isFinished = self.duration == 0 |
54 | end |
setCurve
DescriptionSet the curve function. Defaults to Tween.CURVE.LINEARDefinition
setCurve()Code
102 | function Tween:setCurve(func) |
103 | self.curveFunc = func or Tween.CURVE.LINEAR |
104 | end |
setTarget
DescriptionSet a callback target for this tween. If a target has been set, the setter function must support receiving the target as its first argument.Definition
setTarget()Code
59 | function Tween:setTarget(target) |
60 | self.functionTarget = target |
61 | end |
tweenValue
DescriptionGet the current tween value.Definition
tweenValue()Code
86 | function Tween:tweenValue(t) |
87 | return MathUtil.lerp(self.startValue, self.endValue, self.curveFunc(t)) |
88 | end |
update
DescriptionUpdate the tween's state.Definition
update()Code
65 | function Tween:update(dt) |
66 | if self.isFinished then |
67 | return |
68 | end |
69 | |
70 | self.elapsedTime = self.elapsedTime + dt |
71 | |
72 | local newValue |
73 | if self.elapsedTime >= self.duration then |
74 | self.isFinished = true |
75 | newValue = self:tweenValue(1) |
76 | else |
77 | local t = self.elapsedTime / self.duration |
78 | newValue = self:tweenValue(t) |
79 | end |
80 | |
81 | self:applyValue(newValue) |
82 | end |