Where is the sprite frames initialized?


#1

I am studying Creator through the official demo Black Jack Game and met a problem in RankItem.js which is binding with rankItem Prehab.

Here is the codes:
36%20AM

I am curious at this.spRankBG.spriteFrame = this.texRankBG[rank];. Where is the sprite frame initialized?
I dont’t find any initialize in Prehab or scripts.
28%20PM

I got the correct result when it runs in browser (rankinglist_1,rankinglist_2,rankinglist_3 images showed correctly)

Who can help me? Thank you very much


#2

Hi, looks like there is a typo in this sample project - texRankBG is declared as a cc.SpriteFrame but it is used in code and stored in .prefab file as an array of spriteframes. Thus property inspector gets confused and displays property as empty in editor, while it is not.
Try changing texRankBG: cc.SpriteFrame to texRankBG: [cc.SpriteFrame] and reload editor


#3

Awesome! You save my life ^o^