I have developed two different games (two different projects), I have been assigned to combine/ merge them to one app. So I am confused about the way that I should follow, should I just add Game2 to Game1 as a third party library or is there a way to change the target at the runtime?
Simply
Click Button 1 -----> run Game1's MainScene
Click Button 2 -----> run Game2's MainScene
Followed this Xcode 4.2 how include one project into another one? question and added Game 2 to Game 1 like a static library.
The thing is two game has lots of mutual headers ,like MainScene,GameHud,Objects,Points
......
Game 1 runs with [director runWithScene:[MainMenu scene]];
How can I call Game2's MainScene on click button?
or
Is it possible to change target at run time? On click button1 run game1's target on click button2 run game2's target.
It's basically just grunt work. A static library won't help you much because it doesn't resolve the conflicts - class names must be unique in an executable.
Basically what you need to do is to add all the source code and assets to the same Xcode project. Then initially just load one of the two games in order to try to get the other to compile. You'll have to rename classes and files to accomplish that.
When that's done add some (temporary) selection menu of some kind so you can choose between the two games. This might trigger additional compile errors. Resolve them.
If you have assets of the same name but with different content you need to rename them and change the code.
Then test and find the 1000 little details that'll make you pull your hair out. Well, at least some of them will be a challenge for sure. But for those challenges Stackoverflow was made. :)