import {GameEventEnum} from "../enum/GameEventEnum"; export default class RhythmTick { private rhythmTime: number = 0; private rhythmIndex: number = 0; private beatInterval: number = 0; constructor(beatInterval: number) { this.beatInterval = beatInterval } reset() { this.rhythmTime = 0 this.rhythmIndex = 0 } rhythmTick(dt: number) { this.rhythmTime += dt * 1000 if (this.rhythmTime >= this.rhythmIndex * this.beatInterval) { cc.director.emit(GameEventEnum.RHYTHM_TICK) this.rhythmIndex++ } } }