Disabling Autorotation for Game Center - cocos2d-iphone

I'm trying to implement the Game Center Achievements in my first game. The orientation of my game is landscape left only.
What I have done so far is to change GameConfig.h as below:
#if defined(__ARM_NEON__) || TARGET_IPHONE_SIMULATOR
#define GAME_AUTOROTATION kGameAutorotationNone
#elif __arm__
#define GAME_AUTOROTATION kGameAutorotationNone
My game is then fixed in the Landscape Left orientation at all times. However, when I enter the Game Center Achievement screen from my game, the autorotation is still happening. I am a bit confused with the concept here. Could you guys please tell me why this is happening? And How can I fix this?
Thanks very much in advance. I would really appreciate for your help.

Look into your gameview controller or equivalent version of it in your code. Search for the following function:
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation ;
Comment out the code inside it and only return NO.
I hope this will fix your problem... let me know if it's not working.

Put this in AppDelegate.m before #implementation
#interface UINavigationController (Private)
- (NSUInteger)supportedInterfaceOrientations;
- (BOOL)shouldAutorotate;
#end
#implementation UINavigationController (Private)
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscape;
}
- (BOOL)shouldAutorotate
{
return YES;
}
#end

Related

CCAction blocks does not works in cocos2d v3?

CCActionCallBlock *call=[CCActionCallBlock actionWithBlock:^
{
NSLog(#"***********done");
}];
[self runAction:call];
Is not working if i put it in another node, and add this node to my main scene .
It only works in my main scene, and not in any other layer added to that scene .
why ?
I just tried it and it works for me, have you called [super onEnter] on your scene?
If that does not work please a bit more code please.

Dealing with screen resolutions in cocos2d

I’m sure this question has probably been asked before…
Right now i am porting my game over from Android. right now i have cocos2d fully integrated and i am ready to go. But i want to make sure i understand how the scaling works..
In Android you just provide a width and height for the scene and the graphics are scaled up or down based on the device.
From reading, it doesnt seem to work that way on IOS. So how do you design for screen resolutions such as the 3g, 4,5 and ipad devices?
I was reading, and i know its a best practice to not hard code screen coordinates. With this being said, it seems like the only thing that would need to be scaled would be the background image of the game?
Maybe im wrong, Im kinda of confused about how it works.
If someone could explain that would be great!
Thanks.
In Cocos2D, images are selected automatically based on their associated prefix: name.png for non-retina deivces, name-hd.png for retina, name-ipad.png for ipad 1 and mini, and name-ipadhd.png for ipad retina.
For scaling, I have some useful defines that will allow you to alter things based on the particular platform:
#define MIDSCREEN ccp([CCDirector sharedDirector].winSize.width/2, [CCDirector sharedDirector].winSize.height/2)
#define WINSIZE [[CCDirector sharedDirector] winSize]
#define WINHEIGHT [[CCDirector sharedDirector] winSize].height
#define WINWIDTH [[CCDirector sharedDirector] winSize].width
#define IS_IPAD() (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define IS_RETINA() (CC_CONTENT_SCALE_FACTOR() == 2)
#define REAL_CONTENT_SCALE_FACTOR() (CC_CONTENT_SCALE_FACTOR() * (IS_IPAD() + 1))
#define CONTENT_SCALE_FACTOR() (IS_IPAD() ? 2.0 : CC_CONTENT_SCALE_FACTOR())
#define IPAD_SCALE() (IS_IPAD() ? 2.0 : 1.0)
#define CCP_IPAD(___X___, ___Y___) (IS_IPAD() ? ccp((___X___ + 16.0f) * CONTENT_SCALE_FACTOR(), (___Y___ + 32.0f) * CONTENT_SCALE_FACTOR()) : ccp(___X___, ___Y___))
#define CCP_IPHONE(___X___, ___Y___) (IS_IPAD() ? ccp(___X___, ___Y___) : ccp((___X___ / 2.0) - 16.0f, (___Y___ / 2.0) - 32.0f))
#define IS_IPHONE5() ([[CCDirector sharedDirector] winSize].width == 568 || [[CCDirector sharedDirector] winSize].height == 568)

CCFollow does not stopping following

Hi this is my first question in cocos2d!
I am using this code to follow the ball :
[self runAction:[CCFollow actionWithTarget:ball]];
i need a code the action will be stopped before we can see a black background...
Sorry for the bad english!!
You need to set the world boundary of the follow, which will constrain the follow to the defined rect:
[self runAction:[CCFollow actionWithTarget:ball worldBoundary:CGRectMake(0,0,WINWIDTH,WINHEIGHT)]];

Coloring application using Cocos2D

I trying to make an empty CCSprite then I want to hand drawing on it using touch controls.
But, I don't have an idea how make it and don't know it's possible.
So, PLS help me or give me some advice.
Thanks
I wrote a demo program for CCRenderTexture which shows you how to draw sprites (or whatever you want) with touches:
Hi You can use CCRenderTexture example from Cocos2d for drawing..
Check out this link http://www.cocos2d-iphone.org/forum/topic/8474

Is it possible to use the camera while inside Cocas2D?

I was thinking of using Cocas2D to do some interesting animation stuff and wanted to have that drawn on top of a live preview View from the camera. Is this even possible?
It's quite easy, actually. It is a simple matter of turning the option on in your GamePlayLayer:
GamePlayLayer* gamePlayLayer = [GamePlayLayer node];
controller = [[CCNodeController controller] retain];
controller.isOverlayingDeviceCamera = YES;
[controller runSceneOnNode: gamePlayLayer];
Source: Cocos2d and UIViewControllers