Skip to content

t-sprite

Sprite 序列帧动画

组件介绍

t-sprite 是基�?Canvas 绘制的序列帧动画组件,支持播放、暂停、停止等控制功能,实现动画交互展示�?

平台兼容

HarmonyH5AndroidiOS小程�?UTS
�?�?�?�?�?�?

基础用法

基础用法参�?demo/animationins/animationins.uvue,通过 frames 属性传入序列帧图片数组�?

vue
<template>
  <t-sprite 
    ref="spriteRef"
    :frames="frameImages"
    :speed="20"
    :loop="true"
    :autoplay="true">
  </t-sprite>
</template>

<script setup>
const spriteRef = ref(null)

const frameImages = ref([
  '/static/frame1.png',
  '/static/frame2.png',
  '/static/frame3.png',
  '/static/frame4.png'
])

function play() {
  spriteRef.value?.play()
}

function pause() {
  spriteRef.value?.pause()
}

function stop() {
  spriteRef.value?.stop()
}
</script>

Props

属性名说明类型默认�?
frames序列帧图片数�?string[][]
interval间隔时间(毫秒)number3000
speed播放速度number20
loop是否循环播放booleanfalse
autoplay是否自动播放booleanfalse
path点击组件后跳转的页面路径string''
hover是否启用点击效果booleanfalse
type组件主题类型string''
disabled是否禁用booleanfalse
effect组件显示主题string''
size组件尺寸string''

Events

事件�?说明回调参数
play播放时触�?-
pause暂停时触�?-
resume继续播放时触�?-
stop停止时触�?-

Methods

方法�?说明参数
play开始播�?-
pause暂停播放-
resume继续播放-
stop停止播放-