| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- import { _decorator, Component, Node, Vec3, animation, Animation, SpriteFrame, Sprite, UITransform } from 'cc';
- import { ResourcesUtils } from '../core/resourceManager/ResourcesUtils';
- const { ccclass, property } = _decorator;
- @ccclass('RotatingLightAnim')
- export class RotatingLightAnim extends Component {
- public tempAnimation: Animation;
- public start() {
- }
- /**
- * @zh 旋转光效参数设置
- * @param width 宽度
- * @param height 高度
- * @param speed 动画播放速度
- * @param isZoom 是否需要播放缩放动画,true为需要
- * @param image 旋转光效图片名称(必须是"Resources/Images/rotatingLight"文件夹下面的图片资源),使用默认资源可不填写
- */
- public async set_Data(width: number, height: number, speed: number, isZoom: boolean, image?: string) {
- this.tempAnimation = this.node.getComponent(Animation);
- // this.node.setScale(scaleX, scaleY);
- this.node.getComponent(UITransform).width = width;
- this.node.getComponent(UITransform).height = height;
- this.tempAnimation.getState("rotatingLightEffect").speed = speed;
- this.tempAnimation.getState("rotatingLightEffect0").speed = speed;
- if (image) {
- let img: SpriteFrame = await ResourcesUtils.load("Images/rotatingLight/" + image + "/spriteFrame", SpriteFrame, this.node);
- this.node.getComponent(Sprite).spriteFrame = img;
- }
- if (isZoom) {
- this.tempAnimation.play("rotatingLightEffect");
- } else {
- this.test();
- }
- }
- public test() {
- this.tempAnimation.play("rotatingLightEffect0");
- }
- }
|