creator 生命周期函数回调顺序

情景一

    let node: cc.Node = cc.instantiatet(cc.loader.getRes(""));
    let xx: Xxx = node.getComponent(Xxx);
    xx.setData();

这种情况下类Xxx的生命周期函数的调用顺序是,直接调用Xxx的公共方法,setData()。

情景二

//      parentNode
      let node: cc.Node = cc.instantiatet(cc.loader.getRes(""));
      let xx: Xxx = node.getComponent(Xxx);
      xx.setData();
      parentNode.addChild(node);

这种情况下类Xxx的生命周期函数的调用顺序是,
先调用onLoad() -->
然后public 方法 -->
最后start()

转载于:https://www.jianshu.com/p/9b56a17f1028

猜你喜欢

转载自blog.csdn.net/weixin_34092455/article/details/91292395
今日推荐