I´m starting using cocos2D. In the init function of the helloworld class, I,m trying to create a CCMoveTo object but I can not, it does not find it.
Thanks for the help.
I assume you are either using the latest version of cocos2d and created your project via SpriteBuilder or you are using an older version of cocos2d and created your project via an Xcode template. If so...
If you are using the latest version of cocos2d, but are using learning materials that are older, then things have changed a little. For move actions try using:
CCActionMoveTo
CCActionMoveBy
Related
Hello friends is it possible to create a game using cocos2dx 3.x , Swift.If this is possible than how can i integrate my game inside my native IOS application using swift3.Please Guide me.
Sure, that's quite possible since cocos2d-x will work on a OpenGLES view. And also xCode understands C++.
But it will be a bit tricky to add ; you need to handle all of build configurations with large cocos2d-x library etc.
I got an existing Objective-C project. Now I decided to rewrite some code and add Cocos2d to it. I know this framework for a long time and I recently discovered that they stopped the support for Cocos2d and created a new version called Cocos2d-x. There I found the Swift library and I asked me how to use the Cocos2d-Swift framework in my existing Objective-C project ? A step by step tutorial would be great. I searched a bit in the internet and found this:
Stackoverflow Link
But since the post is from 2011 it does not cover how to add the swift library, since Swift wasn't introduced at this moment.
Cocos2d-swift is a bit of a misnomer : it is currently written in objective-c. The software is now distributed with SpriteBuilder, that is why there is no 'install.sh' as there used to be. So integrating it into your project should not be too difficult. Use SpriteBuilder (from the AppStore) to create a 'blank' SB project, and see how cocos2d is integrated in there. Then, what you see is what you integrate !
caveat : Cocos2d is now ARC, so it is best your project defaults ARC. Otherwise you will have to do a lot of Xcode click-click-click to make the reference count strategy file specific.
I'm a beginner of iOS and Cocos2d. I've just integrated Cocos2d 2.1 with xcode 4.2 and using mac os 10.7.3. Just created my first sample application for Cocos2d and I've not written any single line of code but showing error. The errors are like..
Please help me to solve this.
So that's Cocos2D code that's not compiling?
It looks like they forgot to #import <CoreText/CoreText.h> or one of their own header files.
Is this a release version of the code?
I'm fairly new to developing with apple and everything and I just recently got into spritebuilder (or formerly known cocosbuilder) There is this problem that is just boggling my mind.
From this line in XCode:
[_bird runAction:[CCSequence actions:bird_floatAnimation,nil];
when I type CCSequence just about anywhere I get unknown reciever ccsequence, did you mean ccbsequence? same thing with CCRepeatForever. Funny thing is that I can use CCActionMoveTo and CCActionMoveBy and run it and it works fine.
So what happened? This is driving me insane. I am using SpriteBuilder 1.0 with Cocos2d v3.
The solution is so simple! Found the answer here on the spritebuilder forum
To my misunderstanding and ignorance, since cocos2d v3, some of the classes and methods have been renamed so instead of CCSequence its CCActionSeqence..
amazing..
I might sound lazy but I am slightly confused on how to proceed on this subject. I have followed this guide which is very well done.
My goal is to convert the Cocos2d v1.x game project to Cocos2d v2.x and then refactor the project code to ARC.
To get started I created an empty HelloWorld Cocos2d v2.x project and created the v2.x static library (as from Steffen's guide). I then rafactored the code to ARC and the HelloWorld worked smoothly.
The issue is when I try to add to the same project the classes I had already written that don't complain to ARC (assuming that there will be not many Cocos2d v2.x vs v1.x problems - e.g. use of deprecated methods and classes like TouchJSON - my project doesn't at least as far I can see). So, I added a couple of Game classes that don't depend from the rest of the game (to reduce the number of potential Cocos2d v2. Vs v1 issues) to the project to see if the ARC covnersion worked for those as a proof of concept. After adding them I choosed: EDIT->Refactor option from XCode.
But now the compiler gives me some ARC warning messages like "ARC forbids explicit message send of autorelease" in the following method:
return [[[self alloc] init] autorelease];
Or similar problems with the dealloc method already written.
I was assuming that EDIT->Refactor would have changed the added code but it appears to work only once. Any hint on this? should I add all my code to the new project template before refactoring the code?
EDIT:To verify whether it was an XCode bug I created an empty iOS project with no Cocos2d libraries and then converted it to ARC. Then created a new empty sublcass of NSObject and added a dealloc method and run the conversion again, it did work! So I might have not followed correctly some of the steps to create and link to the static library..
In addition to this there are some other small issues (not XCode related, but Cocos2d v2.x related), like the fact that the CDXPropertyModifierAction is not automatically included to the CocosDenshion folder and I had to add it to the project after creating the static library (when I noticed the issue).. but I guess this is more template creation related.
Thanks for reading!
so, yeah, I can confirm that the solution in the comment did work. As usual with some IT things is was just about playing around a bit with the various options and see if it works changing the prospective (its not a bug but is me being stupid or lazy).
What worked for me was to use the EDIT->Refactor from the XCode menu and de-select the files created in the first instance by the Cocos2d 2.x template that I had converted after creating the static library (e.g. main.m and AppDelegate.m) (ask if this is unclear).
This converted smoothly all my newly converted Cocos2d 2.x classes into ARC complaint classes and yeah, I have my project fully supporting both Cocos2d 2.x and ARC :).
Please find below the screenshot of the files I deselected to get it working: