cocos2d iphone - several layers using the same sprite sheet -


pardon me if sounds bit trivial. in game several of layer classes use same sprite sheet. want avoid declaring same batch nodes in every layer class. how can achieve this?

you can't. node can have 1 parent. if create batch node , add 1 layer, can't add another. if pass reference batch node around work makes having layers pretty pointless because sprites children of layer batch node added to.

you instead use single batch node , group sprites adding "layer sprites" empty texture rect batch node, , adding actual sprites layer sprites.

to create sprite empty texture use initwithtexture:rect: method , use cgrectzero. alternatively in case no longer works can use small rect , set sprite's opacity 0. setting visible no may work, depending on whether visibility propagated in sprite batched sprites or not.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -

php - Accessing static methods using newly created $obj or using class Name -