달력

4

« 2024/4 »

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30

1) 이클립스에서 import할때

3.2버전은 프로젝트만 import하면 에러가 떠있다. 이 에러를 없애주기 위해서 libcocos2dx 를 추가로 import해줘야 한다. 

3.3버전은 기본적으로 프로젝트에 저 라이브러리가 추가되어있기 때문에 따로 추가할 필요가 없다.



2) 프로젝트 생성 폴더

3.3버전에는 3.2버전에 없는 win8,1 폴더가 존재한다.



3) Android 포팅 시

3.2버전에서는 Android.mk파일에서 라이브러리, 소스파일들을 모두 따로 추가해줘야했다.

3.3버전에서는 소스파일만 추가해주면 된다.

:
Posted by 웽웽

- 참고 글

http://discuss.cocos2d-x.org/t/cocos3-0-tutorial-integrate-admob-google-play-services-with-cocos2d-x-v3-0-final/12798



- admob 사이트

https://apps.admob.com/#home



1) 프로젝트 폴더 내에서 python build_native.py 실행



2) eclipse에서 프로젝트 import

- 3.2 / 3.3 버전에서 프로젝트 import 차이점 확인


3) ADT 폴더 \sdk\extras\google\google_play_services\libproject 내에 있는

google-play-services_lib 폴더를 프로젝트 폴더 \proj.android 폴더에 복사



4) eclipse에서 복사한 google-play-services_lib을 import시킴



5) properties 에서 android -> add를 눌러 추가한 라이브러리를 더해줌



6) 프로젝트의 android manifest에 내용 추가



7) 프로젝트의 src->org.cocos2dx.cpp -> AppActivity.java 수정(전면 교체)

 본 내용 중 파란색으로 블럭표시된 곳에 광고 id를 삽입하면 된다.



8) 프로젝트 폴더의 win32 솔루션 실행 후, AdmobHelper.h와 AdmobHelper.cpp 추가 후, 아래 내용 붙여넣기



9) HelloWorldScene.cpp의 init부분 마지막에 코드 추가



10) eclipse에서, 프로젝트 폴더 내의 jni->Android.mk에 추가한 cpp파일을 등록해줌


:
Posted by 웽웽

1. cocos 3.2 에서 3.3rc 프로젝트 버전 변경하기

 - cocos 3.3rc 다운로드 (http://www.cocos2d-x.org/filedown/cocos2d-x-3.3rc2.zip)

 1) 3.3rc에서 프로젝트를 새로 생성한다.

 2) Classes 와 Resource 폴더를 복사한다.

 3) Classes 는 덮어씌우면 에러를 뿜어내므로, AppDelegate.cpp와 AppDelegate.h는 내용을 복붙한다.

     * 주의점!! AppDelegate 파일들의 추가된 내용이 있으니, 빠지면 에러를 뿜어낸다.

 4) 컴파일하여 확인하면 끝

- AppDelegate.h

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#ifndef  _APP_DELEGATE_H_
#define  _APP_DELEGATE_H_
 
#include "cocos2d.h"
class  AppDelegate : private cocos2d::Application
{
public:
    AppDelegate();
    virtual ~AppDelegate();
    virtual void initGLContextAttrs();        //3.3 에서 추가된 매소드
    virtual bool applicationDidFinishLaunching();
    virtual void applicationDidEnterBackground();
    virtual void applicationWillEnterForeground();
};
 
#endif // _APP_DELEGATE_H


- AppDelegate.cpp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "AppDelegate.h"
#include "MenuScene.h"
#include "GameScene.h"
 
USING_NS_CC;
 
AppDelegate::AppDelegate() 
{
}
 
AppDelegate::~AppDelegate()
{
}
 
void AppDelegate::initGLContextAttrs()        //3.3 추가된 부분
{
    GLContextAttrs glContextAttrs = { 8, 8, 8, 8, 24, 8 };
    GLView::setGLContextAttrs(glContextAttrs);
}
 
 
bool AppDelegate::applicationDidFinishLaunching() {
    auto director = Director::getInstance();
    auto glview = director->getOpenGLView();
    if (!glview) {
        glview = GLViewImpl::createWithRect("My Game", Rect(0, 0, 320, 480));    //3.3 변경된 부분
        director->setOpenGLView(glview);
    }
    director->setDisplayStats(false);
    director->setAnimationInterval(1.0 / 60);
    auto scene = GameScene::createScene();
    director->runWithScene(scene);
    return true;
}
 
void AppDelegate::applicationDidEnterBackground() {
    Director::getInstance()->stopAnimation();
}
 
void AppDelegate::applicationWillEnterForeground() {
    Director::getInstance()->startAnimation();
}


2. 포팅 확인하기

 1) Android.mk 파일 복붙 필요 (관련 포스팅 http://genieker.tistory.com/61)

 2) cocos 3.2버전은 NDK r9d버전을 사용하지만, 3.3버전은 NDK r10c 이상의 버전이 필요하다. 

    (http://developer.android.com/tools/sdk/ndk/index.html)

 3) 적당한 곳에 압축해제

 4) 환경변수 변경

- 윈도우키 + pausebreak키 = 시스템->고급시스템설정-> 환경변수-> 사용자변수 -> NDK_ROOT를 아래 그림과 같이 수정

 5) cmd에서 cocos2d-x-3.3rc2 폴더로 이동하여 python setup.py 로 제대로 고쳐졌는지 확인

 6) 컴파일 실행하여 확인


3. 이클립스 디버깅

 1) 3.3에서는 해당 프로젝트만 import하고, 폰이라면 스마트폰 연결하고 실행하면된다. (관련 포스팅 http://genieker.tistory.com/61)



:
Posted by 웽웽