Quantcast
Channel: Cocos中文社区 - 最新主题
Viewing all articles
Browse latest Browse all 88737

怎么把Prefab 加载到Scene上面?

$
0
0

@jumpchess1 写道:

cc.Class({
    extends: cc.Component,
    properties: {
    },
    // use this for initialization
    onLoad: function () {
        var self = this;
        cc.loader.loadRes("prefab/Player", function (err, prefab) {
            let myself = cc.instantiate(prefab);
            myself.parent = self;
            // or self.addChild(myself);
        });
    },
});

场景上面并没有显示出来?
无论是设置parent还是 addChild
parent is undefine
self.addChild is not a function

帖子: 3

参与者: 1

阅读整个主题


Viewing all articles
Browse latest Browse all 88737

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>