You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Originally posted by white16819 November 13, 2024
I'm newer to kaplay and ts.
How to add AreaComp's feature such as onCollide to a existed GameObj like below: const text = k.add([k.text("Test")])
I try to use function like this below: text.use(k.area())
Expect the 'text' GameObj's type change into GameObj<TextComp | AreaComp>,
but the 'text' Gameobj's type still be GameObj<TextComp>.
So if I invoke the 'onCollide' function in AreaComp, the ts check will raise the error: Property 'onCollide' does not exist on type 'GameObj<TextComp>'
Waiting for your suggestions.
The text was updated successfully, but these errors were encountered:
Discussed in #510
Originally posted by white16819 November 13, 2024
I'm newer to kaplay and ts.
How to add AreaComp's feature such as
onCollide
to a existed GameObj like below:const text = k.add([k.text("Test")])
I try to use function like this below:
text.use(k.area())
Expect the 'text' GameObj's type change into
GameObj<TextComp | AreaComp>
,but the 'text' Gameobj's type still be
GameObj<TextComp>
.So if I invoke the 'onCollide' function in AreaComp, the ts check will raise the error:
Property 'onCollide' does not exist on type 'GameObj<TextComp>'
Waiting for your suggestions.
The text was updated successfully, but these errors were encountered: