import { _decorator, Component, Node, Animation, v3, SpriteFrame, Sprite } from 'cc'; import { ResourcesUtils } from '../core/resourceManager/ResourcesUtils'; const { ccclass, property } = _decorator; @ccclass('StarAnim') export class StarAnim extends Component { @property({ tooltip: '星星', type: Node }) public star: Node; start() { } /** * 特效数据重置 * @param wrapMode 播放模式,两种模式正循环和反循环(2:正循环,38:反循环) * @param setTime 设置播放时间(0~3) * @param x 特效坐标点x * @param y 特效坐标点y * @param scale 特效缩放 * @param image 星星特效图片名称(必须是"Resources/star"文件夹下面的图片资源),使用默认资源可不填写 */ public async setData(wrapMode: number, setTime: number, x: number, y: number, scale: number, image?: string) { if (image) { let img: SpriteFrame = await ResourcesUtils.load("Images/star/" + image + "/spriteFrame", SpriteFrame, this.node); this.star.getComponent(Sprite).spriteFrame = img; } let tempAnimation = this.node.getComponent(Animation); tempAnimation.play('starTurn'); let tempAnimation0 = this.star.getComponent(Animation); tempAnimation0.play('starScale'); tempAnimation0.getState("starScale").setTime(setTime); tempAnimation.getState("starTurn").wrapMode = wrapMode; this.node.position = v3(x, y); this.node.setScale(v3(scale, scale)); } public destroyNode() { this.node.destroy(); } }