Maxxx
#1
I’m in the middle of a game jam and have a Creator problem ('cause I don’t know Creator!)
I have a Prefab comprising 5 sprites (let’s call 'em roof, BuildingW, BuildingS, BuildingE and BuildingN)
When instantiated I want the associated script to control the visibility of each of the BuildingX sprites
simple.
But I don’t see how to ‘access’ the sprites from script?
A simlpe example would help immensely - I’m sure I can figure it out eventually but V V tired at present after a late night jammin’
you need add new properties to script then drag it to node in creator then drag which sprite you want to access to right pannel like this
cc.Class({
extends: cc.Component,
properties: {
icon: {
default: null,
type: cc.Sprite,
},
},
onLoad: function () {
this.icon.spriteFrame = 'abc.png';
},
})
Maxxx
#3
Thanks.
I think i was struggling because I was trying to do it in code rather than in the designer!
you can do like this in code let logo = cc.find(‘Canvas/sprLogo’) ;