Skip to content
On this page

Class: Animation

动画组件
插值,可插值属性才能进行插值[todo]

Hierarchy

Table of contents

Constructors

Properties

Accessors

Methods

Constructors

constructor

new Animation()

组件不能单独实例化,必须通过Transform.addComponent创建

ts
const node = new Transform();
const componet = node.addComponent(Component);

Inherited from

Component.constructor

Defined in

src/core/component/Component.ts:37

Properties

animation

animation: string = 'default'

Defined in

src/core/component/Animation.ts:107


animations

animations: Record<string, Timeline<{}>[]> = {}

动画配置

Defined in

src/core/component/Animation.ts:46


emitter

emitter: EventEmitter<string | symbol, any>

事件处理器

Inherited from

Component.emitter

Defined in

src/core/component/Component.ts:27


id

id: number

用于表示组件的唯一标识

Inherited from

Component.id

Defined in

src/core/component/Component.ts:12


loop

loop: number = 0

循环次数,0:不循环,-1:一直循环

Defined in

src/core/component/Animation.ts:112


name

name: string = ''

组件名

Inherited from

Component.name

Defined in

src/core/component/Component.ts:17


node

node: Transform<Container>

组件挂载节点

Inherited from

Component.node

Defined in

src/core/component/Component.ts:22


paused

paused: boolean = true

指示是否被暂停

Defined in

src/core/component/Animation.ts:125


playCount

playCount: number = 0

已经播放次数

Defined in

src/core/component/Animation.ts:116


speed

speed: number = 1

播放速度100%

Defined in

src/core/component/Animation.ts:120


time

time: number = 0

当前时间线

Defined in

src/core/component/Animation.ts:32


timeMax

timeMax: number = 0

动画总长

Defined in

src/core/component/Animation.ts:24


timeline

timeline: EventEmitter<string | symbol, any>

用于记录回调的时间线,在target时间线后执行

Defined in

src/core/component/Animation.ts:19


total

total: number = 0

最大帧数

Defined in

src/core/component/Animation.ts:28


Event

Static Event: Object

Type declaration

NameTypeDescription
ENDED"ended"动画播放完成

Defined in

src/core/component/Animation.ts:10

Accessors

targets

get targets(): Timeline<{}>[]

时间线
每一个对象一个时间线
还有一个总时间线,可以用于记录一些信息

Returns

Timeline<{}>[]

Defined in

src/core/component/Animation.ts:39

Methods

addFrameAction

addFrameAction(time, callback, target): void

添加事件

Parameters

NameType
timenumber
callback() => void
targetany

Returns

void

Defined in

src/core/component/Animation.ts:198


addTimeline

addTimeline(timeline): void

添加一个熟悉变更时间线

Parameters

NameType
timelineTimeline<{}>

Returns

void

Defined in

src/core/component/Animation.ts:84


destroy

destroy(): void

消毁

Returns

void

Inherited from

Component.destroy

Defined in

src/core/component/Component.ts:55


next

next(): void

播放下一帧

Returns

void

Defined in

src/core/component/Animation.ts:53


nextAction

Protected nextAction(val): void

当有新的属性需要更新时调用

Parameters

NameType
valTimeline<{}>

Returns

void

Defined in

src/core/component/Animation.ts:73


onDestroy

Optional onDestroy(): void

组件被销毁时触发

Returns

void

Inherited from

Component.onDestroy

Defined in

src/core/component/Component.ts:62


play

play(): void

播放

Returns

void

Defined in

src/core/component/Animation.ts:127

play(name): void

播放

Parameters

NameTypeDescription
namestring要播放的动画

Returns

void

Defined in

src/core/component/Animation.ts:128

play(loop): void

播放

Parameters

NameTypeDescription
loopnumber要循环的次数

Returns

void

Defined in

src/core/component/Animation.ts:129

play(name, loop): void

播放

Parameters

NameTypeDescription
namestring要播放的动画
loopnumber要循环的次数

Returns

void

Defined in

src/core/component/Animation.ts:130


prev

prev(): void

播放上一帧

Returns

void

Defined in

src/core/component/Animation.ts:103


puase

puase(): void

暂停

Returns

void

Defined in

src/core/component/Animation.ts:168


removeFrameAction

removeFrameAction(time, callback, target): void

移除事件

Parameters

NameType
timenumber
callback() => void
targetany

Returns

void

Defined in

src/core/component/Animation.ts:205


setTimeline

setTimeline(timelines, name?): void

设置一个属性变更时间线

Parameters

NameType
timelinesTimeline<{}>[]
name?string

Returns

void

Defined in

src/core/component/Animation.ts:93


start

Optional start(): void

组件被挂载到节点时触发

Returns

void

Inherited from

Component.start

Defined in

src/core/component/Component.ts:44


stop

stop(): void

停止

Returns

void

Defined in

src/core/component/Animation.ts:160


update

update(time): void

每帧调用

Parameters

NameTypeDescription
timenumber和上一帧的间隔时间 ms

Returns

void

Overrides

Component.update

Defined in

src/core/component/Animation.ts:172