关于 anim.play();

在脚本里这么写
onCollisionEnter: function (other, self) {
var anim = this.getComponent(cc.Animation);

 // 如果没有指定播放哪个动画,并且有设置 defaultClip 的话,则会播放 defaultClip 动画
  anim.play();
//this.node.destroy

},
已经设置了defaultClip 动画, 为什么报play找不到

plane.rar (1.5 MB)

这是因为你的 Bullet component 继承了 Enity component, Entity component 里有 onCollisionEnter 这个函数,所以 Bullet 实体在碰撞了后会 进入 onCollisionEnter 这个函数,但是 Bullet 实体却没有 Animation 这个组件造成的。

你调试下就可以发现 var anim = this.getComponent(cc.Animation); 是 anim 为 null, 表示获取不到 Animation 组件

我懂了,谢谢,这个是我在网上找到得一个框架,准备补完的公布出来的。