kaboom icon indicating copy to clipboard operation
kaboom copied to clipboard

`origin` comp making GameObj type inference not working

Open slmjkdbtl opened this issue 4 years ago • 10 comments

Version

v2000.1

What browsers are you seeing the problem on?

No response

What happened?

window.origin exists in browser and ts default definitions, which confuses ts with kaboom's own origin(): OriginComp, making game object type inference not working

What's the expected behavior?

window.origin should give kaboom's definition

Minimum reproducable code

// this will be a GameObj<any> instead of a GameObj<PosComp | RectComp | OriginComp>
const thing = add([
    pos(120),
    rect(80, 40),
    origin("center"),
])

Live demo

No response

Is there an existing issue for this?

  • [X] I've searched and there is no existing issue for this bug

slmjkdbtl avatar Nov 29 '21 23:11 slmjkdbtl

Chrome

Cannot reproduce

Info: Chrome 84.0.4147.125 OS: Ubuntu 18.04.3 LTS

Cannot reproduce on Chrome

however....

Visual Studio Code

Can reproduce

Info: Visual Studio Code 1.63.0 OS: Ubuntu 18.04.3 LTS

(VSC removed the type popup when I screenshotted, so here's the typing)

Can reproduce on Visual Studio Code

DaInfLoop avatar Dec 14 '21 17:12 DaInfLoop

Recomendations:

Rename to originpoint() Rename to opoint() Add a propety in all drawble things for use the origin, in TextCompOpt, SpriteCompOpt or RectCompOpt (this reminds me of noArea: boolean xD) In pos Comp add a option for set the origins

lajbel avatar Jan 01 '22 22:01 lajbel

origin as a property in drawable options actually makes a lot of sense, since it's completely tied to the drawables. I'll keep looking for ways to make it work with typescript, if no luck maybe have to resolve into one of these breaking changes

slmjkdbtl avatar Jan 03 '22 19:01 slmjkdbtl

Another issue similar to this: KaboomCtx#focus and HTMLElement#focus, making it when you build Kaboom with typescript, you can't do it.

Errors when building Kaboom with typescript

DaInfLoop avatar Jan 13 '22 08:01 DaInfLoop

I think changing the name and avoiding conflict is probably the best way to go.

Some candidates for origin replacement:

  • pivot
  • offset
  • anchor

slmjkdbtl avatar Feb 03 '22 21:02 slmjkdbtl

korigin (kaboom origin) oorigin (object origin) originn (origin no-conflict)

lajbel avatar Feb 04 '22 13:02 lajbel

These have a chance of causing more confusion I think 🤔 if we're proceeding with a breaking change might as well make it a normal word

slmjkdbtl avatar Feb 05 '22 20:02 slmjkdbtl

+1

On Sat, Feb 5, 2022 at 8:34 PM tga @.***> wrote:

These have a chance of causing more confusion I think 🤔 if we're proceeding with a breaking change might as well make it a normal word

— Reply to this email directly, view it on GitHub https://github.com/replit/kaboom/issues/451#issuecomment-1030694521, or unsubscribe https://github.com/notifications/unsubscribe-auth/AWDGLBHCFVPJJYA4TZTQEHTUZWCURANCNFSM5JAKZQLQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you are subscribed to this thread.Message ID: @.***>

DaInfLoop avatar Feb 05 '22 21:02 DaInfLoop

These have a chance of causing more confusion I think 🤔 if we're proceeding with a breaking change might as well make it a normal word

Oh I was only joking hh

lajbel avatar Feb 06 '22 20:02 lajbel

hh sry 😆

slmjkdbtl avatar Feb 08 '22 06:02 slmjkdbtl