第一帖 问题请教

设计一个在UI上动态显示多个图片;
属性设置:
properties: {

    playerPrefab:{
        default:],
        type:
    },
    player: {
        default:],
        type: 
        
    },
  ...

在onload的代码如下:

   for(ind=0;ind<5;ind++){
       
        this.player = cc.instantiate(this.playerPrefab);
        this.node.addChild( this.player);
        
         //  console.log(this.player);
       
        realUrl = cc.url.raw("img/img"+ind+".png");
        texture= cc.textureCache.addImage(realUrl);
  
        console.log(this.player);
      if(ind!==0)//***错误说明见下面:
        {
            this.player.getComponent(cc.Sprite).spriteFrame.setTexture(texture);
        }
        this.player.getComponent(Player).initTest(this,ind); 
        
    }
     错误说明:
   这里( if(ind!==0))如果去掉,会出错。出错的信息就是spriteFrame 下面的rect  null,通过log obj 也能看出来。但是偶尔也正常。
  playerPrefab 已经初始界面操作配置了10 个。 感觉有时总是第一个 this.player不正确。怀疑和playerPrefab的初始配置有关,反复操作过几次。
  偶尔好像也有成功的时候。已经晕了。
  请大侠看看。