Refactoring The Framework

Topics: Maintenance
Coordinator
Mar 5, 2013 at 4:40 PM
We have begun refactoring the framework to make it more .NET stylized. You will find that the use of camel notation (aCallBack) has been replaced with .NET style (ACallBack). Where necessary, the use of "setX" and "getX" is being replaced with attributes.

Furthermore, we will be renaming the selector protocol delegates to be more meaningful and .NET stylized.

We apologize for the code changes you will need to make in your games. This is part of a modernization effort to bring this framework to full compatibility on multiple platforms. It is currently working on iOS, Android, and Windows Phone, and recently WinRT. We've also gotten it working with Ouya and XBox 360 as well as Windows Desktop.
Coordinator
Mar 25, 2013 at 4:09 PM
The next set of changes will break compatibility with existing source bases. To remedy this transition, I've created the Legacy branch on github. If you are using the source from github, then you will need to use the legacy branch until you are ready to migrate to the leaner code base.

We are going to remove CCNS, CCObject, and then remove the self factory pattern (FOO.create()) and the initWithXX() methods. The new way of creating objects in cocos2d-xna will be to use the constructors, e.g. new CCMenu(item1, item2, item3, ...).

If you have any questions about the migration that we are doing, please post your comments!
Coordinator
Mar 31, 2013 at 4:41 PM
We've removed CCNS and CCObject from the framework and tested it thoroughly. So far it has performed well and the class designs are much simpler.

The next phase is the removal of the self factory pattern in lieu of parameter constructors. Then finally we will be removing the initWithXX methods where appropriate. That final change is much more complicated and so will take longer than the other refactoring changes.
Coordinator
Apr 1, 2013 at 5:25 PM
Now that CCObject is gone, all of the content files that are loaded by the cocos2d pipeline extension classes have to be rebuilt. The "type" of these builders and readers has changed and that type reference is embedded in the XNB content files. We just pushed the iOS content builder project to github for you to use. Use this for your own projects and to build the test content if it ever gets out of sync.

Android and PSM continue to use the x86 content xnb files, but they too had to be regenerated.
Coordinator
May 22, 2013 at 3:53 PM
Edited May 22, 2013 at 3:54 PM
Today we will be renaming the namespace for cocos2d to be Cocos2D and eliminating some erroneous sub-namespaces. This work is the precursor to the version 1 release that will be coming soon.

The list of changes can be found here:

https://github.com/totallyevil/cocos2d-xna/pull/153
Coordinator
May 23, 2013 at 4:51 PM
Renaming did cause some problems with existing content files for MonoGame platforms, so we had to add proxy classes in the old cocos2d namespace to support existing XNB files. The Plist classes will continue to live in the old cocos2d namespace until we can create the proxy classes for all of those plist classes.

We tested this by using the same content in the github repo but rebuilt the test application and ran it on android and ios devices. They worked without any errors.
Coordinator
Jun 3, 2013 at 4:34 PM
We've pushed a branch that will serve as the legacy for the pre-1.0 release of Cocos2D-XNA.

The last round of refactoring will be a break from compatibility both in terms of API calls and in your content. The "cocos2d.X" namespace will be removed and replaced with "Cocos2D.X," which means you will need to rebuild all of your XNB files for both non-iOS and iOS platforms.

You will also notice that the "SEL_x" nomenclature is going away in lieu of Action<T> usage. We will continue to use the modern features of C# instead of the C++ way of doing event callbacks. This makes for better optimizations in the code.

We will try to keep the pre-1.0 release branch updated with bug fixes that are critical, but we will not add new features into this branch.

Thank you for using Cocos2D-XNA! We hope that you are enjoying the Box2D C# implementation.
Coordinator
Jun 3, 2013 at 8:27 PM
Edited Jun 3, 2013 at 8:33 PM
Some notes about the name changes:

SelectorProtocol -> CCSelectorProtocol
SEL_MenuHandler -> Action<object>(your_method_handler)
SEL_SCHEDULE -> Action<float>(your callback)
SEL_CallFunc -> Action
SEL_CallFuncN -> Action<CCNode>,
SEL_CallFuncND -> Action<CCNode, object>
SEL_CallFuncO -> Action<object>
ResolutionPolicy -> CCResolutionPolicy
Coordinator
Jun 6, 2013 at 3:37 PM
Edited Jun 6, 2013 at 3:42 PM
More name changes:

CCIFocusable -> ICCFocusable
CCSelectorProtocol -> ICCSelectorProtocol
CCDirectorDelegate -> ICCDirectorDelegate
CCActionTweenDelegate -> ICCActionTweenDelegate
CCScrollViewDelegate -> ICCScrollViewDelegate
CCSortableObject -> ICCSortableObject
CCSortedObject -> ICCSortedObject
CCTableViewDelegate -> ICCTableViewDelegate
ccColor3BWapper -> CCColor3BWapper
CCNodeLoaderListener -> ICCNodeLoaderListener
CCBScriptOwnerProtocol -> ICCBScriptOwnerProtocol

See more: https://github.com/totallyevil/cocos2d-xna/commit/809d6c56b13295deece3c9d4e99ffef1dfa82a8f
Coordinator
Jun 27, 2013 at 3:58 PM
The use of SEL_MenuHandler and other handlers like that has been retired.

We are you sing Action instances and lambdas to implement action callbacks.

new MenuItemLabel(label, new Action<object>(delegate (object o) {

// My menu handling code as a lambda or anonymous method

}));

You can also define a lambda without parameters, as in:

new Action(delegate {
// My delegate code here
});

Every selector has been replaced with Action handlers.
Coordinator
Aug 15, 2013 at 8:22 PM
The API is now frozen for version 1. Do not expect any more API changes to occur in this release.