import gameScene from "../gameScene"; import player from "../player"; import BaseProp from "./BaseProp"; const { ccclass, property } = cc._decorator; @ccclass export default class smallProp extends BaseProp { onLoad(): void { this.RunAction(); } /** * 播放默认动画 */ private RunAction(): void { let offsetY = 15; let times = 0.5; let startScale = 0.5; let endScale = 0.6; let actions = cc.sequence(cc.spawn(cc.scaleTo(times, endScale), cc.moveBy(times, cc.v2(0, offsetY))), cc.spawn(cc.scaleTo(times, startScale), cc.moveBy(times, cc.v2(0, -offsetY)))) actions.repeatForever(); this.node.runAction(actions); } // 只在两个触发器开始触发时被调用一次 private onCollisionEnter(other: any, self: any): void { if (other.node.group != 'player') return; player.getInstance().SetSmall(); this.node.destroy(); // console.log('触发器:', other.node.group, other.node.name); } }