1.2.0 • Published 11 months ago

@rbxts/component v1.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

@rbxts/component

A simple tag-based component library for Roblox TS.

import { Component, TagComponent } from "@rbxts/component"
import { RunService } from "@rbxts/services"

@Component({
    Tag: "Rainbow"
})
export class Rainbow extends TagComponent<Part> {
    public ResetColor!: Color3

    public Speed = 100
    public Hue = 0

    public Start() {
        this.ResetColor = this.Instance.Color // we need to remember the part's original color to revert it later

        this.Trove.add(RunService.Heartbeat.Connect((DeltaTime: number) => {
            this.Instance.Color = Color3.fromHSV(this.Hue/360, 1, 1)
            this.Hue += DeltaTime * this.Speed

            if(this.Hue > 360) {
                this.Hue = 0
            }
        })) // we add this to the built in trove so the RenderStepped connection gets disconnected the instance this component is attached to is destroyed, or the Rainbow tag is removed

        this.Trove.add(() => {
            this.Instance.Color = this.ResetColor
        }) // we also want to reset the part to it's original color, so let's do this
    }
}
1.2.0

11 months ago

1.1.1

11 months ago

1.1.0

11 months ago

1.1.2

11 months ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

0.1.0-test

2 years ago

0.0.1-test

2 years ago

0.0.0-test

2 years ago