블로그 이미지
게임같은 인생 인생같은 게임 쿡지

카테고리

분류 전체보기 (12)
준&빈 (1)
나만의 개념 챙기기 (2)
My Story (0)
cocos2d-x (7)
My Games (0)
My_Work (0)
Etc (2)
Total
Today
Yesterday



CCLabelBMFont *M_MakeLabel(float x, float y, const char *str, int align, float fontSize)

{

    float size = fontSize*mg.factor/52.0f;

    

    CCLabelBMFont *label = CCLabelBMFont::create(str, "BDFont.fnt");

    label->retain();    // 이 부분을 빼 놓으면 실행시 에러 발생!!

    

    label->setAnchorPoint(CCPointMake(0, 1));

    label->setPosition(CCPointMake(x, y));

    

    switch (align) {

        case 1:

            label->setAnchorPoint(CCPointMake(0.5, 0.5));

            label->setAlignment(kCCTextAlignmentCenter);

            break;

            

        case 2:

            label->setAnchorPoint(CCPointMake(1, 1));

            label->setAlignment(kCCTextAlignmentRight);

            break;

            

        default:

            label->setAnchorPoint(CCPointMake(0, 1));

            label->setAlignment(kCCTextAlignmentLeft);

            break;

    }

    

    label->setScale(size);

    label->setString(str);

    

    return label;

}


cocos2d-x 클래스는 retain()과 release()로 메모리를 관리한다.

특히 클래스를 메소드 내에서 선언하여 전역적으로 사용할 경우 반드시 retain()를 해줘야만 한다.

아니라면 release()이후 메모리 상에 문제가 생길 수 있다.

Posted by 알 수 없는 사용자
, |

iOS 6 Tips and Tricks Upgrading Your Apps

Here is what I have learned so far upgrading our apps to iOS 6. Figure this will help some people out. Orientation support is instantly broken the minute I built my apps against iOS 6. 

Root View Controller warning?

 Warning:

Application windows are expected to have a root view controller at the end of application launch

 Change in app delegate didFinishLaunchingWithOptions:

[window addSubview:navigationController.view];

 To:

[window setRootViewController:navigationController];

iOS 6 New Orientation Methods

Set orientation in Info.plist or Summary screen. Then add following code to root view controller class only. Note that if you add a navigation controller to your window, in your app delegate’s didFinishLaunchingWithOptions, you need to create a class that has a subclass of UINavigationController and change your class to this type.

- (BOOL)shouldAutorotate {

return YES;

}

\\replaces – (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

- (NSUInteger)supportedInterfaceOrientations {

return UIInterfaceOrientationMaskLandscape;

}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {

return UIInterfaceOrientationLandscapeRight;

}

The preferredInterfaceOrientationForPresentation method will rotate your view to whatever you set it to when a view is loaded. Be careful as when you come back to your view it may be upside down. Do not include this method if you don’t want it to override the current orientation when you dismiss say a UIImagePickerController.

UIImagePickerController crash

 Crash:

Terminating app due to uncaught exception ‘UIApplicationInvalidInterfaceOrientation’, reason: ‘Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES’

 Add to app delegate:

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)w {

return (NSUInteger)[application supportedInterfaceOrientationsForWindow:w] | (1<<UIInterfaceOrientationPortrait);

}

Test for iOS Version

Here is the best way to test for iOS Version:

NSString *reqSysVer = @”6.0″;

NSString *currSysVer = [[UIDevice currentDevice] systemVersion];

BOOL versionHigher = [currSysVer compare:reqSysVer options:NSNumericSearch] != NSOrderedAscending;

New iPhone 5 screen dimensions

 Warning:

Missing “Default-568h@2x.png” launch image

Once you create this file, the letter boxing will disappear. XCode will even ask you if you want it to create the file.

Depending on your screens layouts, you may just have to make sure your MainWindow.xib is set to Full Screen at Launch. Otherwise you may have to do specific layouts for just the iPhone 5.


출처 : http://grembe.wordpress.com/2012/09/19/here-is-what-i/


Posted by 알 수 없는 사용자
, |

make: Entering directory `/Users/jochulwoo/Dropbox/Library/cocos2d-1.0.1-x-0.12.0/swatvszombies/android'

obj/local/armeabi/objs-debug/game_logic_static/AppDelegate.o:1: warning: NUL character seen; rest of line ignored

obj/local/armeabi/objs-debug/game_logic_static/AppDelegate.o:1: *** missing separator.  Stop.

make: Leaving directory `/Users/jochulwoo/Dropbox/Library/cocos2d-1.0.1-x-0.12.0/swatvszombies/android'


./build_native.sh 

실행시에 위와 같은 에러가 날경우

/android/obj 폴더를 모두 삭제하고 다시 실행하면 원활하게 make가 된다.

'cocos2d-x' 카테고리의 다른 글

CCLabelBMFont 사용시 주의 점.  (3) 2013.04.24
iOS 6 업그레이드 할때 주의점!  (1) 2013.01.18
[cocos2dx] SDK 설치 설정  (0) 2012.07.08
[cocos2dx] 터치 & 멀티 터치  (0) 2012.07.06
[cocos2dx] 화면 해상도 고정시키기  (2) 2012.07.05
Posted by 알 수 없는 사용자
, |

툴을 설치한 후에 다음과 같은 파일이 필요하다.

$cd

$vi ./bash_profile

i

export ANDROID_SDK_ROOT="/Users/jochulwoo/Dropbox/library/android-sdk-macosx"

export ANDROID_NDK_ROOT="/Users/jochulwoo/Dropbox/library/android-ndk-r8/"

export COCOS2DX_ROOT="/Users/jochulwoo/Dropbox/library/cocos2d-1.0.1-x-0.12.0/"

export NDK_ROOT="/Users/jochulwoo/Dropbox/library/android-ndk-r8/"

export PATH="$PATH;$ANDROID_SDK_ROOT/tools;$ANDROID_NDK_ROOT"

:wq

source .bash_profile

* 실행 후 혹 패스가 잘못 잡혀서 ls, vi와 같은 명령이 안 먹힐 경우 Mucommander를 이용하여 .bash_profile파일을 
다시 편집해주면 된다. 잘못된 path를 지워줄것.

Posted by 알 수 없는 사용자
, |

iOS 개발중 멀티 터치 설정

iOS/Appcontroller.mm

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {


...

    [__glView setMultipleTouchEnabled:YES];     // 멀티 터치를 가능하게 한다.


HellowWoldScene.h


private:

    

    void ccTouchesBegan(cocos2d::CCSet *touches, cocos2d::CCEvent *event);

    void ccTouchesMoved(cocos2d::CCSet *touches, cocos2d::CCEvent *event);

    void ccTouchesEnded(cocos2d::CCSet *touches, cocos2d::CCEvent *event);



선언 (이걸 안해서 계속 "out-of-line"에러가 떴다.)



HellowWoldScene.cpp


void HelloWorld::ccTouchesBegan(CCSet *touches, CCEvent *event); 

void HelloWorld::ccTouchesMoved(CCSet *touches, CCEvent *event)

void HelloWorld::ccTouchesEnded(CCSet *touches, CCEvent *event)


정의해서 사용.



void HelloWorld::ccTouchesMoved(CCSet *touches, CCEvent *event)

{

    CCSetIterator it = touches->begin();

    

    CCPoint pt;

    CCTouch* touch;

    for( int iTouchCount = 0; iTouchCount < touches->count(); iTouchCount++ )

    {

        touch = (CCTouch*)(*it);

        pt = touch->locationInView( touch->view() );

        it++;

        

        printf( "Touch %i x:%i y:%i", iTouchCount, (int)pt.x, (int)pt.y );

    }

    printf( "\n" );

}




Posted by 알 수 없는 사용자
, |

최근에 달린 댓글

글 보관함