Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add other compnent feature to existed GameObj #512

Open
lajbel opened this issue Nov 14, 2024 Discussed in #510 · 0 comments
Open

feat: Add other compnent feature to existed GameObj #512

lajbel opened this issue Nov 14, 2024 Discussed in #510 · 0 comments
Assignees
Labels
types A TypeScript related bug

Comments

@lajbel
Copy link
Collaborator

lajbel commented Nov 14, 2024

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.

@lajbel lajbel added this to KAPLAY.js Nov 14, 2024
@lajbel lajbel moved this to WIP in KAPLAY.js Nov 14, 2024
@lajbel lajbel self-assigned this Nov 28, 2024
@lajbel lajbel added the types A TypeScript related bug label Nov 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
types A TypeScript related bug
Projects
Status: WIP
Development

No branches or pull requests

1 participant