kaplay icon indicating copy to clipboard operation
kaplay copied to clipboard

feat: name component

Open mflerackers opened this issue 1 year ago • 5 comments

name(name: string) // Since label is for ui

Provides obj.name

Allows assigning a name to an object. This name does not need to be unique. The reason for this component is to have an alternative way to query objects. Currently tags are used, but tags also assign behavior. As in onUpdate("tagged", tagged => {}). It you have a character existing of different parts, and want to animate it with a predefined animation, you need a practical way to reference parts. Using names we can locate pelvis/upper-left-leg/lower-left-leg/left-foot easily.

mflerackers avatar May 26 '24 04:05 mflerackers

Hmm, sounds good, a replacement for tags, user still can use "tag as components", but this should be the new way

lajbel avatar May 26 '24 11:05 lajbel

So get instead of be for get "tags", is for get object with certain comp

lajbel avatar May 26 '24 11:05 lajbel

It's to be able to get a button with a specific name for example. Now you can do get("button") to get all buttons, but you can't get the "toggle-sound" button. Some people try to use tags for this, but this doesn't work so good.

get({
  includes:["button"],
  name:"sound-mute"
})

Will give you the button with name sound-toggle. Names, unlike tags, will support wildcards. So "sound-*" can give you all sound related objects, if you have named them so.

mflerackers avatar May 26 '24 11:05 mflerackers

Will not break original get()?

lajbel avatar May 26 '24 12:05 lajbel

No, the original get(string | [string]) will only work with tags. The new get(GetOpt) will work with new features like names.

mflerackers avatar May 26 '24 12:05 mflerackers