# 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/timer/Timer.ts:22

#####
Index

### Constructors

constructor

### Properties

_elapsedTime
_step
callback

### Accessors

elapsedTime
progress
step

### Methods

reset
stop
update

## Constructors

### constructor

- new Timer(step?: number): Timer

- 定时触发组件

  #### Parameters

  - ##### step: number = 0

    触发间隔时间（秒）

  #### Returns Timer

  - Defined in assets/core/common/timer/Timer.ts:49

## Properties

### `Private` _elapsedTime

_elapsedTime: number = 0

- Defined in assets/core/common/timer/Timer.ts:25

### `Private` _step

_step: number = -1

- Defined in assets/core/common/timer/Timer.ts:31

### callback

callback: null | Function = null

- Defined in assets/core/common/timer/Timer.ts:23

## Accessors

### elapsedTime

- get elapsedTime(): number

- #### Returns number

  - Defined in assets/core/common/timer/Timer.ts:27

### progress

- get progress(): number

- #### Returns number

  - Defined in assets/core/common/timer/Timer.ts:41

### step

- get step(): number

- 触发间隔时间（秒）

  #### Returns number

  - Defined in assets/core/common/timer/Timer.ts:33
- set step(step: number): void

- #### Parameters

  - ##### step: number

  #### Returns void

  - Defined in assets/core/common/timer/Timer.ts:36

## Methods

### reset

- reset(): void

- #### Returns void

  - Defined in assets/core/common/timer/Timer.ts:66

### stop

- stop(): void

- #### Returns void

  - Defined in assets/core/common/timer/Timer.ts:70

### update

- update(dt: number): boolean

- #### Parameters

  - ##### dt: number

  #### Returns boolean

  - Defined in assets/core/common/timer/Timer.ts:53

Generated using TypeDoc