Post

반응형

cocos2d github에서 cpp-tests 폴더 안에 있는 샘플들은 공부하는데 꽤나 유용해보였다.

그래서 이 샘플 가지고 공부를 하기로 결정!

cocos2d github cpp-tests 프로젝트 빌드 파일 실행하기

cocos2d-x-4\cocos2d-x-4\tests

다운받은 코코스 파일 안에 테스트 파일 있는 거 확인(tests폴더)

그래서 해당 프젝을 옮겨서 cmake로 빌드 파일 만들려고 하니까 에러가 난다.

H:\CocosProject\cpp-tests\build>cmake . -G "Visual Studio 17 2022" -A Win32
-- Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.19045.
CMake Error at CMakeLists.txt:17 (include):
  include could not find requested file:

    CocosBuildSet


CMake Error at CMakeLists.txt:18 (add_subdirectory):
  add_subdirectory given source "H:/CocosProject/cpp-tests/../../cocos" which
  is not an existing directory.


CMake Error at CMakeLists.txt:403 (setup_cocos_app_config):
  Unknown CMake command "setup_cocos_app_config".


-- Configuring incomplete, errors occurred!

H:\CocosProject\cpp-tests\build>

관련해서 검색해보니까 같은 이슈 발견

https://github.com/cocos2d/cocos2d-x/issues/18696

 

Missing Cmake references · Issue #18696 · cocos2d/cocos2d-x

Hi! I'm trying to build a cocos2d-x3.17 project on Ubuntu 16.04. What I did: > git clone --recursive https://github.com/cocos2d/cocos2d-x. > cd cocos2d- > python download-deps. > git submodule upda...

github.com

반응형

Modules 에 있는 CocosBuildSet.cmake를 복사하라고 한다.

일단 기본프로젝트는 실행이 잘되어서 기본프젝에서 cocosBuildSet 위치를 검색해봤더니

test(프젝)\cocos2d\cmake\Modules에 존재한다.

\test\cocos2d 폴더를 통째로 cpp-tests 폴더에 복사했다.

근데 안된다. 그래서 빌드되는 프로젝트 CMakeLists.txt 와 안되는 프로젝트 CMakeLists.txt의 차이점을 비교함.

cocosBuildSet를 못찾는 거 보니 둘의 기본 경로가 다른 거 같음.

그리고 역시나 경로가 달랐음.

test프로젝트: set(COCOS2DX_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cocos2d)

cpp test 프로젝트: set(COCOS2DX_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../..)

그래서 CMakeLists 복사본 만들고 위치를 test프로젝트처럼 수정.

그러니까 sln 프로젝트 파일 만들어짐!!!! 성공 ㅠㅠㅠㅠㅠㅠ

근데 빌드하니까 에러 발생...

그런데 에러들을 보니까...함수 인자 갯수가 맞지 않는다고 하는 걸 보니

이거 설마 최근 함수 적용이 안된건가 싶다;;;끄으응;;;;

이 프로젝트는 그래도 simple sample이 많은 거 같아서 꼭 돌려보고 싶었는데...;;;;

전부 최신화 시켜줘야 돌아가는건가 싶다;; 일단 보니까 빌드 실패해서 exe파일도 bin 폴더에 안만들어져있음.

(수정중)

일단 에러 하나하나 뜯어보기로 했음

에러 목록

1. 'spine/Debug.h'


오류 C1083 포함 파일을 열 수 없습니다. 'spine/Debug.h': No such file or directory

 일단 쓰는 곳이 없어서 주석 처리.

Label::createWithBMFont("fonts/geneva-32.fnt", "And this is Geneva", TextHAlignment::LEFT, 0, Rect(0, 128, 0, 0));

일단 createWithBMFont 함수 레퍼런스 찾아봄.

https://docs.cocos2d-x.org/api-ref/cplusplus/v4x/db/de4/classcocos2d_1_1_label.html#ab9d3a60682e0d77312e2f154a2840647

 

Cocos2d-x: Label Class Reference

Label is a subclass of Node that knows how to render text labels. More... Inherits Node, LabelProtocol, and BlendProtocol. Inherited by TextFieldTTF. virtual void setString (const std::string &text) override  Sets the text that this Label is to display.

docs.cocos2d-x.org

static Label* createWithBMFont ( const std::string &  bmfontPath,
    const std::string &  text,
    const TextHAlignment  hAlignment = TextHAlignment::LEFT,
    int  maxLineWidth = 0,
    const Vec2  imageOffset = Vec2::ZERO 
  )

Allocates and initializes a Label, with a bitmap font file.

Parameters

bmfontPath A bitmap font file, it's a FNT format.
text The initial text.
hAlignment Text horizontal alignment.
maxLineWidth The max line width.
imageOffset  

ReturnsAn automatically released Label object.See alsosetBMFontFilePath setMaxLineWidth

 

Cocos2d-x: Label Class Reference

Label is a subclass of Node that knows how to render text labels. More... Inherits Node, LabelProtocol, and BlendProtocol. Inherited by TextFieldTTF. virtual void setString (const std::string &text) override  Sets the text that this Label is to display.

docs.cocos2d-x.org

5개 인자라서 false 빼주고 rect 대신 vector 해줌. 어차피 밑에서 벡터 set해주길래 그냥 0, 0으로 넣음. 그리고 어차피 실행이 목적이라 아무 값이나 넣거나 주석 처리 ㄱㄱ

auto label2 = Label::createWithBMFont("fonts/geneva-32.fnt", "And this is Geneva", TextHAlignment::LEFT, 0, Vec2(0, 0));

그랬더니 오류 133개가 튀어나왔다 아...........

으앙...더해보고 안되면 뭐 레퍼런스나 다른 프로젝트 참고를 해야겠어ㅠㅠ

근데 일단 에러나는 파일을 보면

SpineTest.h

SpineTest.cpp

CCConsole.h

ccUTF8.h

이 4개라서 이걸 제외하기로 결정. 일단 CCConsole.h, ccUTF8.h는 하나씩만 에러가 나고

몇백개 대부분 에러는 SpineTest.h, SpineTest.cpp에서 발생.

그래서 SpineTest.h, SpineTest.cpp 사용하는 부분 싹 다 주석처리.

갹!!!성공!!!!

다양한 예제가 있었다.

그리고 이제 또 분석하면 된다...

버그해결>분석>버그해결>분석>버그해결>분석

ㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋ

반응형

Post

반응형

cocos-2d 4.0 visual studio 실행

지난번 이야기.

https://dramadramingdays.tistory.com/370

 

cocos-2d 4.0 설치 방법

cocos2d 설치 과정 1. python 설치 cocos-2d는 파이썬2를 지원한다고 한다. 그러므로 먼저 자신의 컴퓨터에 깔린 파이썬 버전을 체크해야한다. cmd를 켜고 python 이라고 명령어를 치면 현재 파이썬 버전을

dramadramingdays.tistory.com

cmake로 빌드 프로젝트 생성하고 visualstudio2022에서 빌드를 했는데...

과연 결과는?

에러입니다!

빌드 실패는 없었는데 왜죠?

근데 test.exe는 잘 만들어졌고 실행도 잘된다......

뭐가 문제죠?

확인해보니 시작프로젝트를 ALL_BUILD가 아니라 현재 프로젝트(나같은 경우는 test)로 바꾸어주어야한다고 한다.

그리고 드디어 성공

(잘못하면 프로젝트 디버그 path, 링커까지 볼 번 했는데 다행이다 ㄷㄷㄷ)

cocos2d 왤케 무섭게 생김 ㄷㄷㄷ

아무튼 cocos2d 오랜만에 봤는데 다들 유니티 써서 커뮤니티 거의 공멸수준ㅠㅠ

c++ 너모 싫고 포인터 너모 싫은데 일단해보고

안되면 flutter해보던가...(하지만 flutter의 그 생소한 문법이 싫어 dart는 그럭저럭이겠지만

자꾸 return 하고 감싸주고??? 그거 너무 이해가 어려움 ㅠㅠ)

아무튼 일단 해보자...하하하ㅏ아항하아하

 

반응형

컴파일 속도 단축에 대해서도 찾았다.

게임엔진은 이미 완성되어있기에 오른쪽 창에 최상위 프로젝트 선택후 속성에 들어가서 라이브러리들을 빌드 해제해주면 빌드 속도가 빨라진다고 한다.

https://blog.naver.com/PostView.naver?blogId=soulumsword_kim&logNo=221729691455&parentCategoryNo=184&categoryNo=&viewDate=&isShowPopularPosts=true&from=search

 

[cocos2d-x 3.17.2] 설치 및 신규 프로젝트 생성하기

본 포스팅에서는 cocos2d-x를 본격적으로 사용하기에 앞서서 개발환경을 구축하는 순서에 대해 설명하고자 ...

blog.naver.com

 

 

cocos2d 참조하면 좋은 문서들

cocos2d 문서

https://docs.cocos.com/cocos2d-x/manual/en/about/getting_started.html

 

About Cocos2d-x · GitBook

Where to get Cocos2d-x and what do I get? You can clone the GitHub Repo and follow the steps in the README. You can also download as part of the Cocos package on our download page. No matter if you choose to develop in C++, JavaScript or Lua, everything yo

docs.cocos.com

cocos2d 레퍼런스

https://docs.cocos2d-x.org/api-ref/cplusplus/v4x/

 

Cocos2d-x: cocos2d-x

About cocos2d-x cocos2d-x open source project is designed to be a cross-platform 2D game engine for building 2D games, demos and other graphical/interactive mobile applications. It runs on top of OpenGL 2.0 and OpenGL ES 2.0 and is written in C++. This pro

docs.cocos2d-x.org

cocos2d github

https://github.com/cocos2d/cocos2d-x

cocos2d 튜토리얼

https://gamefromscratch.com/cocos2d-x-c-game-programming-tutorial-series/

cocos2d 샘플 프로젝트

https://docs.cocos2d-x.org/cocos2d-x/v4/en/installation/Windows.html

 

Windows · GitBook

No results matching ""

docs.cocos2d-x.org

Cocos2d-x 4에서 바뀐 함수 이름 등등... 변경점 적혀있음

https://docs.cocos2d-x.org/cocos2d-x/v4/en/apichange/api_change_v4.html

cocos2d-x 포럼

https://discuss.cocos2d-x.org/

 

Cocos Forums

Cocos Official Forums

discuss.cocos2d-x.org

 

반응형
▲ top