# Timer | oops-framework
Documentation for oops-framework

# Class Timer

定时跳动组件

### Example

    export class Test extends Component {
           // 创建一个定时跳动组件
           private timer: Timer = new Timer(1);

           update(dt: number) {
               if (this.timer.update(this.dt)) {
                   console.log(每一秒触发一次);
               }
           }
       }

#### Hierarchy

- Timer

- Defined in assets/core/common/manager/TimerManager.ts:262

#####
Index

### Constructors

constructor

### Properties

_elapsedTime
_step
callback

### Accessors

elapsedTime
progress
step

### Methods

reset
update

## Constructors

### constructor

- new Timer(step?: number): Timer

- 构造函数

  #### Parameters

  - ##### step: number = 0

    每跳动一次步长单位位

  #### Returns Timer

  - Defined in assets/core/common/manager/TimerManager.ts:293

## Properties

### `Private` _elapsedTime

_elapsedTime: number = 0

- Defined in assets/core/common/manager/TimerManager.ts:266

### `Private` _step

_step: number = 0

- Defined in assets/core/common/manager/TimerManager.ts:273

### callback

callback: null | Function = null

定时到了回调

- Defined in assets/core/common/manager/TimerManager.ts:264

## Accessors

### elapsedTime

- get elapsedTime(): number

- 逝去时间

  #### Returns number

  - Defined in assets/core/common/manager/TimerManager.ts:269

### progress

- get progress(): number

- 进度

  #### Returns number

  - Defined in assets/core/common/manager/TimerManager.ts:285

### step

- get step(): number

- 获取触发间隔时间单位秒

  #### Returns number

  - Defined in assets/core/common/manager/TimerManager.ts:275
- set step(step: number): void

- 设置触发间隔时间单位秒

  #### Parameters

  - ##### step: number

  #### Returns void

  - Defined in assets/core/common/manager/TimerManager.ts:279

## Methods

### reset

- reset(): void

- 重置

  #### Returns void

  - Defined in assets/core/common/manager/TimerManager.ts:310

### update

- update(dt: number): boolean

- 游戏引擎的cc.Component组件的update方法调用

  #### Parameters

  - ##### dt: number

  #### Returns boolean

  - Defined in assets/core/common/manager/TimerManager.ts:298

Generated using TypeDoc