cocos creator 资源加载函数 resources.load 注意该函数为异步

kekit-rei / 2023-07-24 / 原文

            const  animationComponent = i.addComponent(Animation);
            if(animationComponent){
                const component = animationComponent.getComponent(Animation);
                if(component){
                    resources.load("Animation/toRight", AnimationClip, (err, clip) => {
                        component.addClip(clip, "toRight");
                        component.play("toRight");

                    });

                }

            }

注意调用

文章后续修改