cc.Class({
    extends: cc.Component,

    properties: {
        label: {
            default: null,
            type: cc.Label
        },
        // defaults, set visually when attaching this script to the Canvas
        text: 'Hello, World!',

        muzzlePrefab: {
            default:null,
            type:cc.Prefab
        }
    },

    // use this for initialization
    onLoad: function () {
        this.label.string = this.text;
    },

    handelFire(){
        cc.log('handelFire')
        let muzzleFlashNode = cc.instantiate(this.muzzlePrefab);
        muzzleFlashNode.parent = this.node;
        muzzleFlashNode.position = cc.v3()
        let parsyses = muzzleFlashNode.getComponentsInChildren(cc.ParticleSystem3D);
        for (const parsys of parsyses) {
            parsys.stop()
            parsys.play()
        }
    },

    // called every frame
    update: function (dt) {

    },
});
