Skip to main content

IntSpring

Observable

Inherits Observable

Observable object which simulates critically damped spring easing towards another observable's value, rounding to the nearest integer towards the target value.

Useful for UI components like currency counters.

Constructor


Dex.IntSpring

Dex.IntSpring<T>(
    target: Observable<T>
    angularFrequency: number?
) -> IntSpring<T>

Creates an easing observable that simulates the behavior of a critically damped spring, constrained to the Integer range. Rounds the current position towards the target value, which is useful for UI components like currency or ammo counters.

INFO

IntSprings must currently be Subscribed or Mounted to exhibit expected behavior. This is a requirement for all realtime-simulated observables, which enables safe garbage collection when writing Dex components.

Functions

ResetVelocity

IntSpring:ResetVelocity() → ()

Sets the velocity of the spring to the zero (or the origin vector). Useful in conjunction with Spring:SetPosition

CurrentTarget

IntSpring:CurrentTarget() → ()

Gets the current value of the spring's target observable.

SetPosition

IntSpring:SetPosition() → ()

Moves the current position of the spring to a new value, keeping the current velocity intact.

Show raw api
{
    "functions": [
        {
            "name": "ResetVelocity",
            "desc": "Sets the velocity of the spring to the zero (or the origin vector). Useful\nin conjunction with [Spring:SetPosition]",
            "params": [],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 148,
                "path": "src/Observables/EasedObject.luau"
            }
        },
        {
            "name": "CurrentTarget",
            "desc": "Gets the current value of the spring's target observable.",
            "params": [],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 170,
                "path": "src/Observables/EasedObject.luau"
            }
        },
        {
            "name": "SetPosition",
            "desc": "Moves the current position of the spring to a new value, keeping the current\nvelocity intact.",
            "params": [],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 200,
                "path": "src/Observables/EasedObject.luau"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "IntSpring",
    "desc": "#### Inherits [Observable]\n\nObservable object which simulates critically damped spring easing towards\nanother observable's value, rounding to the nearest integer towards the\ntarget value.\n\nUseful for UI components like currency counters.\n\n## Constructor\n\n---\n\n### Dex.IntSpring\n```ts\nDex.IntSpring<T>(\n    target: Observable<T>\n    angularFrequency: number?\n) -> IntSpring<T>\n```\n\nCreates an easing observable that simulates the behavior of a critically\ndamped spring, constrained to the Integer range. Rounds the current position\ntowards the target value, which is useful for UI components like currency or\nammo counters.\n\n:::info\nIntSprings must currently be ***Subscribed*** or ***Mounted*** to exhibit\nexpected behavior. This is a requirement for all realtime-simulated\nobservables, which enables safe garbage collection when writing Dex\ncomponents.\n:::",
    "tags": [
        "Observable"
    ],
    "source": {
        "line": 78,
        "path": "src/Observables/IntSpring.luau"
    }
}