Skip to Content
Welcome to Vyno! 🍷
文档API参考FigurecreateImageFigure()

createImageFigure()

创建图片角色,支持 PixiJS 渲染和动画效果。

函数签名

createImageFigure(id: string, props: { name: string; path: string; avatar?: string; }): ImageFigure

参数

参数类型描述
idstring角色唯一标识
namestring角色名称
pathstring图片资源路径
avatarstring?头像路径(可选)

基础用法

const qing = createImageFigure("qing", { name: "秦", path: "/figures/qing/qing.png", avatar: "/avatars/qing.png", });

显示角色

// 定义常用的位置属性 const position = { x: 849.56, y: 5.66, scaleX: 0.42, scaleY: 0.42, rotation: 0, alpha: 1, anchorX: 0, anchorY: 0, }; // 显示角色 qing.show(position);

使用示例

// 显示并对话 qing.show(position); qing.speak`你好!`; // 动画效果 qing.bounce().speak`我会弹跳`; qing.fadeOut().speak`我要消失了`; qing.fadeIn(); // 切换图片 qing.switch("/figures/qing/qing_happy.png"); // 隐藏角色 qing.hide();

可用方法

方法描述
.speak()显示对话
.show(props?)显示角色
.hide()隐藏角色
.set(props)设置属性(无动画)
.to(props, options?)补间动画
.switch(path)切换图片资源
.fadeIn()淡入
.fadeOut()淡出
.bounce()弹跳
.shake()抖动

PixiProperty 属性

属性类型描述
xnumberX 坐标
ynumberY 坐标
scaleXnumberX 缩放
scaleYnumberY 缩放
rotationnumber旋转角度
alphanumber透明度 (0-1)
anchorXnumber锚点 X
anchorYnumber锚点 Y
Last updated on