Post

반응형

cocos2d 설치 과정

1. python 설치

cocos-2d는 파이썬2를 지원한다고 한다.

그러므로 먼저 자신의 컴퓨터에 깔린 파이썬 버전을 체크해야한다.

cmd를 켜고 python 이라고 명령어를 치면 현재 파이썬 버전을 알 수 있다.

나 같은 경우는 파이썬3이여서 다시 설치를 해야했다.

https://www.python.org/downloads/release/

 

Python Release Python 2.7.18

The official home of the Python Programming Language

www.python.org

release 버전을 확인해보니 Python 2.7.18 버전이 파이썬2 버전대에서 최신이었다. 그래서 Python 2.7.18을 설치했다.

그리고 환경변수에서 파이썬2를 사용하도록 바꿔줘야한다.

환경변수로 들어가 시스템변수와 user에 대한 사용자 변수 전부 수정해야한다.

맨 아래에 Python2위치(C:\Python27)를 추가한다.

그리고 컴퓨터 재부팅 후 python을 치면 버전이 바뀐 것을 확인할 수 있다.

(그런데 cocos setup.py 를 실행하니 아래와 같은 메시지가 떴다;;; 왜죠;;;

The python version is 3.12. But python 2.x is required. (Version 2.7 is well tested)

일단 환경변수 Path에서 3의 Path를 지워줬다ㅠㅠ

C:\Users\user\AppData\Local\Programs\Python\Python312\Scripts\

C:\Users\user\AppData\Local\Programs\Python\Python312\

환경설정에서 위 경로를 아래로, 2버전을 맨 위로 해줬는데도 안됨;;;

결국 앞으로 py -2.7(현재버전)을 붙이기로 ㅠㅠ)

설치가 완료되었다면 cocos를 설치한 폴더에서 cocos라는 명령어를 친다.

Xiamen Yaji Software Ltd. collects anonymous data when the command-line tools are used for development. This data is examined in the aggregate only and is used to continually innovate and improve Cocos products. This data is anonymous and includes, but is not limited to, a unique hardware identifier, version number our software and information on which tools and/or services in Cocos products are being used and how they are being used. We take your privacy seriously and we do not share or sell any of this data. You can opt-out from sharing this data with us, but by sharing you help contribute to growth of Cocos.

Our entire policy can be viewed at: http://www.cocos2d-x.org/licenses.

For questions please e-mail privacy@cocos2d-x.org.

Do you agree to sent the data? [Y]es, [N]o

라고 뜬다. 선택은

반응형

N으로 해도 무방하다. 그대로 넘어가진다. 그러면 아래와 같은 화면이 뜬다. 끝.

C:\cocos2d-x-4.0\tools\cocos2d-console\bin\/cocos.py 2.3 - cocos console: A command line tool for Cocos2d-x.

Available commands:
        run              Compiles, deploy and run project on the target.
        luacompile       Encrypt and/or compile lua files.
        deploy           Compile and deploy a project to a device/simulator.
        compile          Compile projects to binary.
        gen-simulator    Generate Cocos Simulator.
        new              Creates a new project.
        jscompile        Compile and/or compress js files.

Available arguments:
        -h, --help                      Show this help information.
        -v, --version                   Show the version of this command tool.
        --ol ['en', 'zh', 'zh_tr']      Specify the language of output messages.
        --agreement ['y', 'n']          Skip the agreement with specified value.

Example:
        cocos new --help
        cocos run --help
C:\cocos2d-x-4.0>

 

2. Android, SDK, NDK, ANT 설치

NDK란 C++같은 네이티브 언어를 안드로이드에서 사용할 수 있도록 해주는 도구이다.

Tools - SDK Manager 에서 SDK Tool 탭에서 NDK를 찾아 설치하면 된다.

SDK는 안드로이드 설치할 때 깔리는 듯

환경변수에

변수이름: ANDROID_SDK_ROOT

변수값: C:\Users\user\AppData\Local\Android\Sdk

추가.

Path에 C:\Users\user\AppData\Local\Android\Sdk\tools, C:\Users\user\AppData\Local\Android\Sdk\platform-tools 추가

cmd 창에서 android 라고 치면 andorid 버전이 나온다.

ANT는 안드로이드 없이 앱 빌드 결과물을 만들게 해준다.

https://ant.apache.org/bindownload.cgi

 

Apache Ant - Binary Distributions

Binary Distributions Apache Ant™ Apache Ant is a Java library and command-line tool that help building software. Downloading Apache Ant Use the links below to download a binary distribution of Ant from one of our mirrors. It is good practice to verify th

ant.apache.org

다운로드받은 후 환경변수에 추가

변수 이름 : ANT_ROOT
변수 값 : C:\apache-ant-1.9.16\bin
path에 추가 : C:\apache-ant-1.9.16\bin

ant가 깔렸는지 확인하려면 cmd에서 ant -version  명령어 확인.

 

3. cocos-2d 4버전 설치

https://cocos2d-x.org/download

코코스 다운로드 링크

 

Download Cocos2d-x, Cocos Creator and Cocos | Cocos2d-x

 

cocos2d-x.org

최신버전인 cocos4도 나온지 오래 되어서 4버전을 쓰기로 했다.

전버전과 달라진 부분이 많다고 한다(오픈소스라서 어쩔 수 없는 듯....)

cocos2d-x-4.0 다운로드

이후 원하는 위치에 놓는다.(난 C:\cocos2d-x-4.0)

cmd를 켜서 코코스위치(C:\cocos2d-x-4.0)로 이동한 후 setup.py를 실행시킨다.

C:\cocos2d-x-4.0>py -2.7 setup.py

중간에 경로를 넣어줘야 한다.

Please enter the path of NDK_ROOT

Adroid Setting으로 들어가서 System Setting-Android SDK-SDK Tools에서 Android SDK Location을 확인해서 알아냈다.

나 같은 경우 ndk가 아래에 있었다.

C:\Users\user\AppData\Local\Android\Sdk\ndk\26.2.11394342

SDK 경로도 마찬가지.

C:\Users\user\AppData\Local\Android\Sdk

4. CMake 설치

CMake란 다양한 환경을 구축할 수 있도록 빌드 파일을 만들어주는 시스템이다.

CMake 다운로드. 나는 편하게 msi를 다운로드 받았다.

https://cmake.org/download/

 

Download CMake

You can either download binaries or source code archives for the latest stable or previous release or access the current development (aka nightly) distribution through Git. This software may not be exported in violation of any U.S. export laws or regulatio

cmake.org

설치 옵션에서 Add CMake to the system PATH for all users 선택.

 

5. 코코스 프로젝트 생성

"cocos new (프로젝트명) -p (패키지명) -l (사용언어) -d (저장할 프로젝트 경로)" 

C:\cocos2d-x-4.0>cocos new test -p com.cocos3d.ptest -l cpp -d H:\CocosProject
> Copy template into H:\CocosProject\test
> Copying Cocos2d-x files...
> Rename project name from 'HelloCpp' to 'test'
> Replace the project name from 'HelloCpp' to 'test'
> Replace the project package name from 'org.cocos2dx.hellocpp' to 'cohttp://m.cocos3d.ptest'
> Replace the Mac bundle id from 'org.cocos2dx.hellocpp' to 'cohttp://m.cocos3d.ptest'
> Replace the iOS bundle id from 'org.cocos2dx.hellocpp' to 'cohttp://m.cocos3d.ptest'

해당 프로젝트로 가면 프로젝트가 생성된 것 확인가능.

그런데 vs에서 프로젝트를 열려고 했는데 sin 확장자가 없다.

build 폴더를 만들고 프로젝트 만들기.

그러면 ..으로 상위폴더의 상위폴더가 기준점이 되고

CMakeLists.txt 파일을 찾고 그 파일을 실행하여 빌드 실행 파일을 생성한다.

cmake .. -G"Visual Studio 17 2022" -A Win32

이러니까 build폴더에 sln이 생겼다.

cmake 명령어 좀 찾아봐야...

 

반응형
▲ top