I found that in the cocos2d Best Practices there is a suggestion to use initWithTexture to initialize sprite subclasses, instead in several books and tutorials I found that you can also use initWithSpriteFrameName. Why is that?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
All of the initialization methods in
CCSpriteuseinitWithTexture:rectto create the sprite. For example,Other functions (
initWithFile,initWithSpriteFrame,initWithSpriteFrameName, et cetera) also callinitWithTexture:recteither directly or indirectly. If yourCCSpritesubclass has any special initialization that needs to take place (as it ostensibly will, since you’re subclassing another class), doing it ininitWithTexture:rectguarantees that it will be run.