Spring774
2025-10-30 4d84b498fbb08b9f177b5d9a39e2fedd0522f16f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import Global from "./Global";
 
const { ccclass, property } = cc._decorator;
 
@ccclass
export default class Prop extends cc.Component {
 
    @property
    propType: number = 0;
 
    private manager = null;
    reuse(manager) {
        this.manager = manager;
    }
 
    // 只在两个碰撞体开始接触时被调用一次
    onBeginContact(contact: cc.PhysicsContact, selfCollider: cc.Collider, otherCollider: cc.Collider) {
        if (otherCollider.tag == Global.TAG_WALL_BOTTOM) {//球到底了
            this.node.runAction(cc.callFunc(this.recycle, this));
        }else{
            this.manager.pickupProp(this.propType);
            this.node.runAction(cc.callFunc(this.recycle, this));
        }
    }
 
    recycle() {
        this.manager.recycleProp(this);
    }
}