action.md

2018-11-22 17:56 更新

ngui/action

create(json[,parent])

  • 通过json数据创建动作,如果传入的jsonAction跳过创建过程

    如果传入父动作,创建完成追加新创建的动作到parent结尾

  • 如果传入的数据里有spawn属性创建SpawnAction

对像的内部属性frame如果为Array,那么用这个Array创建Frame

Example:

var act1 = action.create([
    { time:0, x:0 },
    { time:1000, x:100 },
]);
var act1 = action.create({
    delay: 1000,
    frame: [
        { time:0, x:0, curve: 'linear', },
        { time:1000, x:100 },
    ]
});
// 创建SequenceAction并有两子KeyframeAction
var act2 = action.create({
    loop: -1,
    seq: [
        {
            frame: [
                { time:0, x: 0 },
                { time:1000, x: 100 },
            ]
        },
        [
            { time:0, x: 100 },
            { time:1000, x: 0 },
        ]
    ]
})

transition(view,style[,delay[,cb]])

transition(view,style[,cb])

  • 通过样式创建视图样式过渡动作并播放这个动作,完成后回调

Callback: cb()

Example:

// 1秒后过渡完成并回调
action.transition(view, {
    time: 1000,
    y: 100, 
    x: 100,
}, ()={
    console.log('view transition end');
})
// 延时1秒后开始播放,并使用线性过渡
action.transition(view2, {
    time: 1000,
    curve: 'linear',
    y: 100, 
    x: 100,
}, 1000)

Class: Action

  • abstract class

  • 动作基础类型,这是个抽象类型没有构造函数

Action.play()

  • 播放动作

Action.stop()

  • 停止动作

Action.seek(time)

  • 跳转到目标time时间,调用后会重置loopd

  • 不包含延时时间,如果想在延时之前,可传入负数time

  • @arg time {int} ms

Action.seekPlay(time)

  • 跳转到目标time时间,并开始播放,调用后会重置loopd

  • @arg time {int} ms

Action.seekStop(time)

  • 跳转到目标time时间,并停止播放,调用后会重置loopd

  • @arg time {int} ms

Action.clear()

  • 清空动作,清空动作后会立即停止动作

Action.loop

  • 动作循环播放的次数,-1表示无限循环

Get: Action.loopd

  • 当前动作已经循环播放的次数

Action.delay

  • 延时播放

Get: Action.delayd

  • 延时过去的时间

Action.speed

  • 播放速率,默认为1.0,可设置的范围在0.110.0之间

Action.playing

  • 是否播放中,设置action.playing = true相当调用action.play()

Get: Action.duration

  • 当前动作的时长不包括延时,对于SpawnAction取最长的子动作

Get: Action.parent

  • 父动作,如果没有父动作返回null

Class: GroupAction

  • abstract class
  • extends Action

  • 动作集合,这是个抽象类型没有构造函数

Get: GroupAction.length

  • {uint}

    GroupAction.append(child)

  • 追加子动作到结尾

  • @arg child {Action}

    GroupAction.insert(index, child)

  • 插入子动作到index的位置

  • @arg index {uint}
  • @arg child {Action}

    GroupAction.removeChild(index)

  • 通过index删除子动作

  • @arg index {uint}

    GroupAction.children(index)

  • 获取子动作

Class: SpawnAction

  • 并行子动作实现,所有的动作并行一起播放

SpawnAction.spawn(index)

  • 返回子动作children(index)的别名函数

  • @arg index {uint}
  • @ret {Action}

Class: SequenceAction

  • 串行子动作实现,子动作一个接一个串行播放

SequenceAction.seq(index)

  • 返回子动作children(index)的别名函数

  • @arg index {uint}
  • @ret {Action}

Class: KeyframeAction

  • 关键帧动作, 不能包含子动作

KeyframeAction.hasProperty(name)

  • 测试当前是否添加了属性名name

KeyframeAction.matchProperty(name)

  • 测试属性名称是否与当前绑定的视图匹配

KeyframeAction.frame(index)

  • 通过索引获取关键帧

KeyframeAction.add([time[,curve]])

  • 通过time时间与曲线curve添加关键帧,并返回关键帧

'linear''ease''easeIn''easeOut''easeInOut' 做为参数。

KeyframeAction.add([style])

  • 通过style对像属性添加关键帧,并返回关键帧

Get: KeyframeAction.first

  • 第一个关键帧

Get: KeyframeAction.last

  • 最后一个关键帧

Get: KeyframeAction.length

  • 关键帧数量

Get: KeyframeAction.position

  • 当前关键帧的播放位置,-1表示还未开始播放

Get: KeyframeAction.time

  • 当前播放时间time

Class: Frame

  • 关键帧

Frame.fetch([view])

  • 通过视图抓取样式属性填充到当前frame

    如果不传入视图抓取当前绑定的视图样式属性

  • @arg [view] {View}

Frame.flush()

  • 恢复当前关键帧样式属性为默认值

Get: Frame.index

  • 关键帧所在的动作中的索引位置

Frame.time

  • 关键帧的所在动作中的时间time

Get: Frame.host

Frame.curve

  • 当前关键帧到下一个关键帧的过渡曲线

可使用 LINEAREASEEASE_INEASE_OUTEASE_IN_OUT

'linear''ease''easeIn''easeOut''easeInOut' 做为值设置。

Frame.translate

Frame.scale

Frame.skew

Frame.origin

Frame.margin

Frame.border

Frame.borderWidth

Frame.borderColor

Frame.borderWadius

Frame.minWidth

Frame.minHeight

Frame.start

Frame.ratio

Frame.width

Frame.height

Frame.x

Frame.y

Frame.scaleX

Frame.scaleY

Frame.skewX

Frame.skewY

Frame.originX

Frame.originY

Frame.rotateZ

Frame.opacity

Frame.visible

Frame.marginLeft

Frame.marginTop

Frame.marginRight

Frame.marginBottom

Frame.borderLeft

Frame.borderTop

Frame.borderRight

Frame.borderBottom

Frame.borderLeftWidth

Frame.borderTopWidth

Frame.borderRightWidth

Frame.borderBottomWidth

Frame.borderLeftColor

Frame.borderTopColor

Frame.borderRightColor

Frame.borderBottomColor

Frame.borderRadiusLeftTop

Frame.borderRadiusRightTop

Frame.borderRadiusRightBottom

Frame.borderRadiusLeftBottom

Frame.backgroundColor

Frame.newline

Frame.contentAlign

Frame.textAlign

Frame.maxWidth

Frame.maxHeight

Frame.startX

Frame.startY

Frame.ratioX

Frame.ratioY

Frame.repeat

Frame.textBackgroundColor

Frame.textColor

Frame.textSize

Frame.textStyle

Frame.textFamily

Frame.textLineHeight

Frame.textShadow

Frame.textDecoration

Frame.textOverflow

Frame.textWhiteSpace

Frame.alignX

Frame.alignY

Frame.shadow

Frame.src

Frame.backgroundImage

LINEAR

EASE

EASE_IN

EASE_OUT

EASE_IN_OUT

以上内容是否对您有帮助:
在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号