4

次のようなコードがあるとします。

Crafty.c("SomeType",{//do something... });
var obj=Crafty.e("SomeType");

オブジェクトの型をチェックする機能があるかどうか誰か教えてもらえますか?

元:

Crafty.isComponent(obj,"SomeType")==true

また

Crafty.getComponents(obj)=="SomeType"
4

1 に答える 1

4

ああ、Crafty.jsファイルから、コンポーネントをチェックするための.has()関数があることがわかりました。:)

    /**@
    * #.has
    * @comp Crafty Core
    * @sign public Boolean .has(String component)
    * Returns `true` or `false` depending on if the
    * entity has the given component.
    *
    * For better performance, simply use the `.__c` object
    * which will be `true` if the entity has the component or
    * will not exist (or be `false`).
    */
于 2012-10-13T06:51:37.290 に答える