假设我有一个如下所示的代码。
Crafty.c("SomeType",{//do something... });
var obj=Crafty.e("SomeType");有没有人能告诉我有没有检查对象类型的函数?
例如:
Crafty.isComponent(obj,"SomeType")==true或
Crafty.getComponents(obj)=="SomeType"发布于 2012-10-13 14:51:37
Ah从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`).
*/https://stackoverflow.com/questions/12870687
复制相似问题