Importing Another Cocos2d Project's Classes, Code, and SRC - xcode

The project I was toying around with for some reason was a dated version of cocos2d, and the classes and methods I was trying to introduce were too recent. So, I have successfully installed the new cocos2d, and have created a cocos2d template in Xcode. My issue is that this project is brand new, and I want to bring all my other project's code into this.
I have searched this across other stackoverflow threads, and just dragged the files/folder into the new project. When the files wouldn't transfer, I adjusted their path, and then dragged them in, or in one unique case, when dealing with the class main.m, I just changed its internal code so that it would sync up with the rest of the code.
However, because this is a template file, there are some extra baggage classes that I am not sure how to handle. These classes are the classes that come standard in the 'Classes' folder when the cocos2d template is first created:
GameConfig.h
HelloWorldLayer.h
HelloWorldLayer.m
RootViewController.h
RootViewController.m
MyGameAppDelegate.h
MyGameAppDelegate.m
And then in the 'Other Sources' folder:
MyGame_Prefix.pch
These classes or their likeness does not appear to be used in the original project from which I copied the other classes, is there any special use for them that would be dangerously stupid for me to delete them?

You can delete HelloWorldLayer. It's just the example scene/layer.
You would do well to leave the other files in. Any modifications you may have made to your old project's app delegate (such as which scene is passed to CCDirector's runWithScene method) should be re-done in the MyGameAppDelegate rather than replacing that with your old project's app delegate.
The reason is that the startup sequence for cocos2d has changed to support Retina devices, autorotation, changes in the iOS SDK, etc. The RootViewController handles autorotation, should you need that. Whether autorotation is enabled or not can be changed via GameConfig.h.

Related

Duplicated Xcode project issue

I've duplicated my Xcode project - basically I'm creating an app with similar functionality but with different content. I duplicated the main folder and updated the names in the new project for the new app following a guide on Youtube that was on another thread, but when I updated the background of the storyboard for the new app, I've now seen it has changed the storyboard of the original app, so it must be using the same story file, or be linked somehow.
Please can someone suggest what I might have done wrong, or what I need to do when duplicating the project to avoid the same story file being used.
Please check the "Full path" of your file like shown below. Make also sure, that all your other files are linked correctly.

How to add new UI to cocos2d-x library

I have a question about adding new UI widget (in my case its an EditBox but with UIEditView instead of UIEditBox). I make some changes to UIEditBox, named it UIEditView and put into UI folder. Add all the files to the new created group
Included it in CocosGUI.h, but still can not use it.
Here the default list
Both Classes in my UIEditView have unique names
Names of classes
So what wong? ;(
Thanks in advice
I can't see the entire class, but from what I can see if you just try to access ui::UIEditBox without cocos2d in front of it, it might work. If that's not the case make sure you have NS_CC_BEGIN or using namepace cocos2d in your header and cpp file.
Also you don't have to add your custom ui into the cocos ui folders, unless you want to push it back to to project. Otherwise I have a folder for CustomUI that I host on GitHub as a opensource project so others can use it. Just makes it easier to manage.
If this did not help can you please post more of your files, if you don't mind sharing, will make it easier to help you.

Why does Xcode 5 assistant editor defaults to .m file

I realized that when launching assistance editor while working on a XIB file no longer opens the header file by default, instead it shows the implementation file. Is there a new workflow going on I am not aware of? While in the implementation file I can only seem to be able to add IBActions. What is the "new" way to create IBOutlets? Switching to header file each time??
My 2 Cents:
When you create a new class using the Xcode templates, it usually provides a class extension in the implementation file for private properties. It makes a lot of sense to actually link the IBOutlets and IBActions there, because in most cases they are only ever used within the class itself.
The only exception to this that crosses my mind right now is UIView subclasses, and especially UITableViewCell. A lot of developers access the IBOutlets directly in cellForRowAtIndexPath:.
Apple engineers' message:
Encapsulate your IBOutlets & IBActions whenever possible!

How to create an iPhone application starting from an empty project and then adding one resource at a time?

Instead of using the standard Xcode provided templates (view based, window based etc), is it possible to create a full fledged iPhone application by starting with an empty project ?
I mean can one first create an empty project first, and then one at a time, add the main.m file, then import the Frameworks, then add an xib, add UIApplication delegate class, make necessary connections etc...
Has anyone tried this? It would certainly help one understand the basic anatomy of an iPhone application.
Yes. At least in Xcode 4.2, there is the "Empty" project template with no files, targets or build configurations.

How are objects defined in an XIB file and how are they created at runtime?

I've just purchased a Mac and am beginning to explore software development using Cocoa and Objective-C using XCode in Snow Leaped having come from a strong Microsoft and C# backgrund
All of the documentation and tutorials I have read use Interface Builder and XCode to create applications with user interfaces. My current understanding is that objects created by Interface Builder are in some way defined in an .xib file and created at runtime.
A bundle contains code and resources that accompany it. Is it right to say that an .xib file is in fact a bundle that contains UI resources and that this bundle is loaded (is that the correct verb?) at runtime and object instances are created?
If the abive is true is there any way I can see the code generated by Interface Builder and the point in code where these objects are created, without seeing this at least once I feel like there is a lot of "magic" happening and that isn't helping me at this stage of my learning.
Is there anything I should be reading to grasp the apparent paradigm-shift between C# / WinForms and Objective-C / Mac OS / Cocoa?
Is it right to say that an .xib file is in fact a bundle that contains UI resources and that this bundle is loaded (is that the correct verb?) at runtime and object instances are created?
No. A bundle is one of several specific directory structures, and a xib file is a regular file, not a directory.
A xib file contains descriptions of objects. When you compile the nib (usually as part of building your app), the nib compiler reads in the xib, creates the objects as described therein, and archives them into a nib, which isn't a bundle either.
When you load the nib in your application, the nib loader unarchives the objects and ensures all outlets are connected as they were in IB between its objects and to and from the File's Owner.
Don't worry about implementation details. Nibs Just Work. All you have to do is:
Create xib files. If you use version control, these are what you tell it to track.
Make sure they're in .lproj folders (so that localizers can create localized versions of them).
Let Xcode handle the rest.
The key thing to realize is that there isn't any code in the normal sense...at least, nib/xib UI resources are not simply contruscts of objective-c code that are merely generated by the Inteface Builder.
These are objects that are sort of "frozen" in the nibs and "unfrozen" when needed by the apps (or awakened, I guess, as the awakeFromNib would suggest). They are archived in xml/plist/etc form, rather than being a framework for generating objective-c source code.
Consider them objects that have been serialized as xml or other data.

Resources