I have a question about adding a custom variable to a cocos2d struct...in this case the 'Particle' struct. I've added to the struct, but I'm not sure what needs to be done for my app to use the new code. After building the main cocos project I can use the variable in that project, but it still doesn't show up in the app I'm making that uses cocos.
How to add custom variable to built-in struct?
(5 posts) (3 voices)-
Posted 2 years ago #
-
I'd love to help you, but I really have no idea what you're talking about based on what you described. More (clear) details please?
Posted 2 years ago # -
I guess I made a mistake regarding the location of the cocos2d source files. I originally made a change in the CCParticleSystem.h class that was in the 'cocos2d-iphone' project directory created when I installed cocos2d, assuming that all projects used the same source files. When I opened the Xcode project for the app I'm making I got an error that the member I added didn't exist.
I see now that there is another copy of the cocos2d files in my app's folder structure. I made the change to the CCParticleSystem.h class in that version of the file, and things work as expected now. Basically I'm still pretty unclear as to how things are linked or referenced or whatever when using a library in Xcode (I'm just starting out with cocos2d, objective c and xcode so lots of stuff is still a bit of a mystery to me). Does each project end up with it's own copy of all the cocos2d files, so any change made to that code is project-specific?
Posted 2 years ago # -
That entirely depends on how you set up your projects, you can do it either way..
Posted 2 years ago # -
It is not a very good idea to make changes to Cocos2d files directly. Instead you should just extend the object and add whatever functionality you want. This will prevent you from having to go back and re-add any changes you made to Cocos2d files if you ever decide to update to a new Cocos2d version.
I would highly recommend finding a Cocos2d-iPhone tutorial and going through it. It would probably help you out a lot.
Posted 2 years ago #
Reply
You must log in to post.