cc.Class({
    extends: cc.Component,

    properties: {
        headshotEffectPrefab: cc.Prefab, // 爆头动画预制件
    },

    // use this for initialization
    onLoad: function () {
        this.node.on('headshot', this.playBigHeadshotEffect, this);
    },

    // 播放超大爆头动画
    playBigHeadshotEffect: function (event) {
        let targetPosition = event.detail.position; // 获取爆头位置
        let effectNode = cc.instantiate(this.headshotEffectPrefab); // 实例化预制件
        effectNode.parent = this.node; // 将动画添加到当前节点
        effectNode.setPosition(targetPosition); // 设置动画位置
    },
});