12345678910111213141516171819202122232425262728293031 |
- import FObject from "../object/FObject";
- const {ccclass, property} = cc._decorator;
- @ccclass
- export default class FGrassShard extends cc.Component {
- public count:number = 0;
- onBeginContact(contact: cc.PhysicsContact, selfCollider: cc.PhysicsCollider, otherCollider: cc.PhysicsCollider){
- if(otherCollider.node.group == 'A'){
- let sobject = otherCollider.node.getComponent(FObject);
- if(sobject){
- this.count ++;
- this.node.opacity = 100;
- }
- }
- }
- onEndContact(contact: cc.PhysicsContact, selfCollider: cc.PhysicsCollider, otherCollider: cc.PhysicsCollider){
- if(otherCollider.node.group == 'A'){
- let sobject = otherCollider.node.getComponent(FObject);
- if(sobject){
- this.count --
- if(this.count <= 0){
- this.node.opacity = 255;
- }
- }
- }
- }
- }
|