Creator v2.3.0 Animation Issue

Hello fellows,

Sins v2.3.0 I have a strange animation bug which does not occur on previous versions…
I am attaching a video that will show exactly what is going on there.

Description:

  1. I created a splash sprite prefab which contains also an animation component.
  2. The animation component has only one clip which changes the spriteFrames in a loop sequence (as shown int the attached video).
  3. I created a test component (GTest.ts file) which does a super simple task: every 3 seconds (in secdule) I am instanciating the prefab and play the animation.

At first it looks fine, but when the second prefab comes into play, it looks like the animation is out of sync for some reason.

here is the component code:

const {ccclass, property, executeInEditMode, playOnFocus, requireComponent} = cc._decorator;

@ccclass
@executeInEditMode
@playOnFocus
export default class GTest extends cc.Component {

    @property({ type: cc.Prefab })
    public prefab: cc.Prefab = null;


    onFocusInEditor() {
        this.node.removeAllChildren();

        if (!this.prefab) {
            return;
        }

        this.create(0, 0, 0);
        this.create(200, 200, 3);
        this.create(-200, -200, 6);
        this.create(-200, 200, 9);
        this.create(200, -200, 12);
        this.create(-200, 0, 15);
        this.create(200, 0, 18);
        this.create(0, -200, 21);
        this.create(0, 200, 24);
    }

    create(x: number, y: number, delay: number) {
        this.scheduleOnce(() => {
            const obj = cc.instantiate(this.prefab);
            this.node.addChild(obj);
            obj.setPosition(cc.v2(x, y))

            const anim = obj.getComponent(cc.Animation);
            const time = this.randBetween(0, anim.defaultClip.duration)
            cc.log(time)
            anim.play(anim.defaultClip.name, 0);
        }, delay)

        
    }

    randBetween(min, max) {
        return Math.random() * (max - min) + min;
      }

    onLoad () {

    }

    start () {

    }

    update (dt: number) {
         
    }
}

Some times it is working fine however, if you try to move the node or excecute the component again on focus, the bug will occur again.

Please note: The bug happens only inside the editor.

Please, any help will be appriciated @slackmoehrle

@hananht I don’t see a solution off the top of me head.

We can ask @jare to help us with this.

@jare please… any advice about this issue?