-(void) updateText WithInt: (int) val {
numValue += val;
NSString *numString = [NSString stringWithFormat:@"%i", numValue];
[textFieldName numString];
}
-(void) updateText WithInt: (int) val {
numValue += val;
NSString *numString = [NSString stringWithFormat:@"%i", numValue];
[textFieldName numString];
}
GameBGiPad1.png - For iPhone
GameBGiPad1-hd.png - For iPhone HD
GameBGiPad1-ipad.png - For iPad
GameBGiPad1-ipadhd.png - For iPad HD
Want a nice, easy to read and implement description of blend modes in Cocos2D? Well you won’t get it here on Tokeru, but you will on Nial Giacomelli’s site. Check it out. http://nial.me/2012/06/porting-photoshop-blendmodes-to-cocos2d/
Right had to do a bit of research for this one, here is the fix I found that works from Natalie London
In your APP DELEGATE.m
NSString *reqSysVer = @"6.0";
NSString *currSysVer = [[UIDevice currentDevice] systemVersion];
if ([currSysVer compare:reqSysVer options:NSNumericSearch] != NSOrderedAscending){
[window setRootViewController:viewController]; // This is for IOS6.....
}else{
[window addSubview: viewController.view]; //This is for < IOS6....... (the old way)
}
In your ROOTVIEWCONTROLLER.m //will only be compiled for IOS6
FOR LANDSCAPE USE THIS
- (NSUInteger) supportedInterfaceOrientations {
return UIInterfaceOrientationMaskLandscape;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{
return UIInterfaceOrientationLandscapeRight;
}
- (BOOL) shouldAutorotate {
return YES;
}
FOR PORTRAIT USE THIS
- (NSUInteger) supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{
return UIInterfaceOrientationPortrait;
}
- (BOOL) shouldAutorotate {
return YES;
}
The page I got this from is
https://devforums.apple.com/message/734618#734618
Easy Peasy, check out this link for how to and al available types.
Step 1
In your Target Info set the Targeted Device Family to “iPhone/iPad”
Step 2
In your appDelegate.m put this bit of code
- (BOOL) isIpad {
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 30200
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
return YES;
} else {
return NO;
}
#else
return NO;
#endif
}
To reference it in your other classes do this
in class.h
@interface YourLayerClass : CCLayer {
YourAppDelegate *theDelegate;
Boolean *isIpad;
}
in class.m in your init method
-(id) init
{
if( (self=[super init] )) {
//DEFINE iPad or iPhone
theDelegate = (YourAppDelegate*)[[UIApplication sharedApplication] delegate];
isIpad = [theDelegate isIpad];
}
}
And you can use it in your class thusly
if(isIpad == NO){
bg = [CCSprite spriteWithFile:@"xx_iphone.png"];
}else {
bg = [CCSprite spriteWithFile:@"xx_ipad.png"];
}
Right, so I do a lot of animation in my apps, so here is the most simple creation of it
yourfile.h
@private CCSprite *youranimref;
@private CCAnimation *animation;
yourfile.m
-(id) init
{
if( (self=[super init] )) {
self.isTouchEnabled = YES;
size = [[CCDirector sharedDirector] winSize];
// DECLARE ANIMATION
animation = [[CCAnimation alloc] initWithName:@"youranimref" delay:1/24.0];
youranimref = [CCSprite spriteWithFile:@"yourFirstAnimGrfx.png"];
[animation addFrameWithFilename: @"yourSecondAnimGrfx.png"];
[animation addFrameWithFilename: @"yourThirdAnimGrfx.png"];
[animation addFrameWithFilename: @"yourFourthAnimGrfx.png"];
// ADD ANIMATION
youranimref.position = ccp( 512, 435 );
[self addChild:youranimref z:5];
}
return self;
}
- (void) dealloc
{
// !!!!! VERY IMPORTANT - REMOVE TEXTURES AND RELEASE REFERENCE TO THE ANIMATION
[[CCTextureCache sharedTextureCache] removeUnusedTextures];
[[CCSpriteFrameCache sharedSpriteFrameCache] removeUnusedSpriteFrames];
// RELEASE RETAINED OBJECTS
[animation release];
[super dealloc];
}
- (void) runAnimation
{
// RUN THE ANIMATION
CCAnimate* action = [CCAnimate actionWithAnimation:animation];
[youranimref runAction:action];
}
In my latest app Loopy Tunes, I needed to add multitouch functionality to a keyboard. I use Cocos2D, so if you’re like me, then just do the following.
In your delegate.m class, add this line
[glView setMultipleTouchEnabled:YES];
right after this one.
[director setOpenGLView:glView];
Then in your class.m where you are testing for multitouch, up in your init method, add the following line
self.isTouchEnabled = YES;
And then add your touch method somewhere down under the init method, just update the values of the areaToCheck
- (void)ccTouchesBegan:(NSSet*)touches withEvent:(UIEvent*)event
{
NSSet *allTouches = [event allTouches];
for (UITouch* touch in allTouches) {
CGPoint location = [touch locationInView:[touch view]];
location = [[CCDirector sharedDirector] convertToGL:location];
CGRect areaToCheck = CGRectMake(100,100,100,100);
if(CGRectContainsPoint(areaToCheck, location)) {
// whatever you want to happen here
}
}
}
When preparing my universal app for iTunes I was having trouble with getting the icon.png file the right size. When I saved a 57×57 pixel icon iTunes complained about needing a 72×72 pixel icon for the iPad an vice versa for the iPhone. So I googled and found there are a couple of things you need to do.
STEP 1
Create all the icons listed in here under Table 3: Universal apps icon requirements. Then add them to your project in xcode. (you know, drag em into your resources folder)
http://developer.apple.com/library/ios/#qa/qa1686/_index.html
STEP 2
On that same page down the bottom are the instructions for how to enter these to your info.plist. Follow them, or just add this to your info.plist if it isn’t in there already. (I prefer to edit the info.plist myself in textEdit) If you are using a cocos project, especially 0.99.5 or newer, it should already be in there.
STEP 3
If you have the following in your info.plist,
replace it with
A good way to get people to review your app easily is to put a link to the review page in your app. Easy to do, just add this
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://itunes.apple.com/us/app/a-fine-musician/id406573790?mt=8"]];
and replace “a-fine-musician” with your app name, and “406573790” with your app id.