12345678910111213141516171819202122232425262728293031 |
- import { _decorator, Component } from 'cc';
- import { GunBase } from './GunBase';
- import { PoolManager } from '../../core/manager/PoolManager';
- const { ccclass, property } = _decorator;
- @ccclass('BulletBase')
- export class BulletBase extends Component {
- public isDead: boolean = false;
- //枪的数据 在gunBase中
- public gunBase: GunBase = null!;
- //子弹自动回收的时间5s
- private recycleTime: number = 3;
-
- constructor(){
- super();
- this.isDead = false;
- }
-
- start() {
- this.scheduleOnce(this.autoRecycle.bind(this),this.recycleTime);
- }
- public autoRecycle(){
- if(!this.isDead){
- this.isDead = true;
- PoolManager.putNode(this.node);
- }
- }
- }
|