'잡다한것들전부/팁'에 해당되는 글 38건
- 2014.07.30 공부하고 싶은 것들 정리.(구글킵)
- 2014.01.16 [디버깅] Cocos2dx 이클립에서 안드로이드 네이티브 디버깅
- 2014.01.14 cocos2d-x 멀티 터치 처리하기
- 2014.01.13 autoRelease 및 retain() , release(), retainCount()
- 2014.01.13 CCNode 및 CCArray 의 메모리 관리
- 2014.01.13 cocos2d-x multi-resolution
- 2014.01.13 cocos2d-x 스크롤 테이블뷰 예제 소스
- 2014.01.13 cocos2d-x CCString 분리후 CCArray 에 넣기( 문자열 분리하기)
- 2014.01.13 cocos2d-x 의 메모리 관리
- 2014.01.13 cocos2d-x 멀티해상도 지원
공부방향
이펙티브 시리즈나
혹은 해골,용책 정도 밖에 생각이 나질 않아서요
물리책도 보고, AI책도 보고 그러는거죠.
리펙토링도 해보고 설계도 해보세요.
공룡책 한번 보세요. OS 에 관한책입니다.
국어, 수학, 물리, 영어
디자인패턴이나 리팩토링 Code Complete 뭐 이런 류의 책
C++(1학년): try-catch,template,다형성
데이터구조론(2학년): tree, hash, sort
데이터베이스(3학년): 제2정규화, stored procedure
운영체제론(3학년): Operating System Concepts (이른바 공룡책)의 "프로세스" 챕터
컴퓨터네트워크(3학년): OSI 3-4 level, ARQ 알고리즘
컴파일러(4학년): BNF grammar
정보보호(4학년): RSA, AES, DES
http://www.hanmadiro.com/ -무료영어
http://www.ebsi.co.kr/ebs/pot/potg/retrieveCourseH3TeacherInfo.ebs?teacherId=@*ebsint_e68&targetCode=D200
영어
http://www.ebsi.co.kr/ebs/pot/potg/retrieveCourseH3TeacherInfo.ebs?teacherId=@*09st-m02&targetCode=D300
수학
1. Direct 3D 엔진 개발을 위한 루트로, 고 기술력이 요구되는 방향의 진로
2. 게임 브리오, 언리얼등 유명 게임 엔진 유경험을 쌓아 보편적인 3D 게임 개발자로의 진로
MS SQL은
뇌를 자극하는 SQL Server 2008 - 한빛미디어
c++ 서적
- c++ 기초 플러스
- effetive c++
c# 스프라이트 툴 만들기
http://cafe.naver.com/jzsdn/25183
게임샐러드 관련 강좌
http://diyga.me/
http://blog.naver.com/hellofskill
게임샐러드책은 국내에 한권뿐
'잡다한것들전부 > 팁' 카테고리의 다른 글
| 공부하고 싶은 것들 정리.(구글킵) (0) | 2014.07.30 |
|---|---|
| [디버깅] Cocos2dx 이클립에서 안드로이드 네이티브 디버깅 (0) | 2014.01.16 |
| cocos2d-x 멀티 터치 처리하기 (0) | 2014.01.14 |
| autoRelease 및 retain() , release(), retainCount() (0) | 2014.01.13 |
| CCNode 및 CCArray 의 메모리 관리 (0) | 2014.01.13 |
| cocos2d-x multi-resolution (0) | 2014.01.13 |
|
'잡다한것들전부 > 팁' 카테고리의 다른 글
| 공부하고 싶은 것들 정리.(구글킵) (0) | 2014.07.30 |
|---|---|
| [디버깅] Cocos2dx 이클립에서 안드로이드 네이티브 디버깅 (0) | 2014.01.16 |
| cocos2d-x 멀티 터치 처리하기 (0) | 2014.01.14 |
| autoRelease 및 retain() , release(), retainCount() (0) | 2014.01.13 |
| CCNode 및 CCArray 의 메모리 관리 (0) | 2014.01.13 |
| cocos2d-x multi-resolution (0) | 2014.01.13 |
void HelloWorld::ccTouchesEnded( CCSet * touches, CCEvent * event )
{
//멀티터치 처리
CCSetIterator it = touches->begin();
CCTouch* touch;
for( int iTouchCount = 0; iTouchCount < touches->count(); iTouchCount++ )
{
touch = (CCTouch*)(*it);
CCPoint location = touch->getLocationInView();
location = CCDirector::sharedDirector()->convertToGL(location);
it++;
}
}
'잡다한것들전부 > 팁' 카테고리의 다른 글
| 공부하고 싶은 것들 정리.(구글킵) (0) | 2014.07.30 |
|---|---|
| [디버깅] Cocos2dx 이클립에서 안드로이드 네이티브 디버깅 (0) | 2014.01.16 |
| cocos2d-x 멀티 터치 처리하기 (0) | 2014.01.14 |
| autoRelease 및 retain() , release(), retainCount() (0) | 2014.01.13 |
| CCNode 및 CCArray 의 메모리 관리 (0) | 2014.01.13 |
| cocos2d-x multi-resolution (0) | 2014.01.13 |
Cocos2d-x의 메모리 관리
Reference Count
레퍼런스카운터는 c와 c++의 메모리관리의 오래된 방법이다. ios에서는 8년전부터 이 메커니즘을 써왔다.
cocos2d-x에서도 ios ndk 의 NSAutoreleasePool와 거의 같은 CCAutoreleasePool이 존재한다 . 사용방법은 거의 동일하며 만약 너가 ios로 개발한 경험이 없으면 NSAutoreleasePool class Reference를 읽어봐라
CCAutoreleasePool
CCAutoreleasePool 은 NSAutoreleasePool거의 같지만 2개의 차이점이있?다.
- CCAutoreleasePool 은NESTED에서 사용할수없다. 오직 게임 인스턴스에서만 사용 가능하다.
- CCAutoreleasePool 은 멀티쓰레드에서 사용할수 없다.
CCAutoreleasePool의 로직은 간단하다 만약 너가l object->autorelease()을 실행하면 object는 autorelease pool 에 들어가게 된다.
autorelease pool은 루프가 끝날시 자동으로 release()이 되게 도와준다.
예를들어 layer->addChild(sprite), 이 sprite 는 레이어의 차일드이다, 이것은 레이어가 release될때까지 pool에서 유지된다
CCObject::release(), retain() and autorelease()
->release() 가 필요할때
1. "new" 연산자를 사용할때 CCSprite,CCLayer 등(CCObject를 상속받는 자식들)
2. "retain()"을 호출할때
release나 retain이 필요없는 예제:
위 예제는 autorelease()풀에 의해서 관리되기때문에 release나 retain이 필요없다.
An Error Sample
이 예제의 실수는 m_pBombsDisplayed 는 CCMutalbeArray<CCSprite*>::arrayWithObjects 에 의해 생성되는데, autoRelease()에의해 관리되기때문에
루프가 지나면 사라진다.
이문제를 해결하기 위해서는 m_pBombsDisplayed = CCMutableArray<CCSprite*]]>::arrayWithObjects(...); 뒤에 m_pBombsDisplayed->retain()를 추가하고, HelloWorld::~HelloWorld() 소멸자에서 m_pBombsDisplayed->release()한다.
'잡다한것들전부 > 팁' 카테고리의 다른 글
| [디버깅] Cocos2dx 이클립에서 안드로이드 네이티브 디버깅 (0) | 2014.01.16 |
|---|---|
| cocos2d-x 멀티 터치 처리하기 (0) | 2014.01.14 |
| autoRelease 및 retain() , release(), retainCount() (0) | 2014.01.13 |
| CCNode 및 CCArray 의 메모리 관리 (0) | 2014.01.13 |
| cocos2d-x multi-resolution (0) | 2014.01.13 |
| cocos2d-x 스크롤 테이블뷰 예제 소스 (0) | 2014.01.13 |
'잡다한것들전부 > 팁' 카테고리의 다른 글
| cocos2d-x 멀티 터치 처리하기 (0) | 2014.01.14 |
|---|---|
| autoRelease 및 retain() , release(), retainCount() (0) | 2014.01.13 |
| CCNode 및 CCArray 의 메모리 관리 (0) | 2014.01.13 |
| cocos2d-x multi-resolution (0) | 2014.01.13 |
| cocos2d-x 스크롤 테이블뷰 예제 소스 (0) | 2014.01.13 |
| cocos2d-x CCString 분리후 CCArray 에 넣기( 문자열 분리하기) (0) | 2014.01.13 |
http://www.cocos2d-x.org/projects/cocos2d-x/wiki/Multi_resolution_support#designResolutionSize Multi-resolution support(since cocos2d-2.0-x-2.0.4)안드로이드 기기에서 다양한 해상도를 적용 하기는 어렵다. Cocos2d-x는 두가지 메서드를 제공한다 The principle
예를들어, 이 메서드를 사용하면 아이폰 4s의 가로모드 사이즈는 '960x640'이다. 레티나 장치에 레티나가 아닌 것을 사용 하는 방법은 무엇일까? 너는 두가지 메서드만 알고 있으면 된다. 하나는 designResolutionSize 이고 다른 하나는 contentScaleFactor 이다. designResolutionSizeAll your game's coordinates rely on design resolution no matter what the size of your device screen. If the UI layout of your game is the same on all resolutions, you just need only a set of coordinates. 디자인 해상도는 설정할수 있다.
첫번째와 두번째 피라미터 값은 디자인 해상도의 높이와 넓이 이고 세번째 값은 디바이스에 뿌려주는 방식 이다.
세번째 값에 대해서는 맨 마지막에 설명하겠다.
You could also use more than one set of resources on different devices to make a better display by Here are some code snippets in HelloCpp project. contentScaleFactorContentScaleFactor는 designResolutionSize에 ResourcesSize에서 비율을 설명합니다 ContentScaleFactor describes the ratio from ResourcesSize to designResolutionSize. 일반적으로 'ResourceBackGround.height/DesignResolution.height' 혹은 'ResourceBackGround.width/DesignResolution.width'. 둘중 하나를 사용하며, 너의 게임에 맞는 방법을 선택하면 된다. When using NoBorder mode, there are some areas of the backgroud out of scope. If you use absolute coordinates based on design resolution size(480x320), You can get the origin point of 'visible rectange' by 'CCDirector::sharedDirector()->getVisibleOrign()'. Together with 'CCDirector::sharedDirector()->getVisibleSize()', 당신은 9개의 점을 화면위에서 확인할수 있다. 'Left','Right', 'Top','Bottom','Center','LeftTop','RightTop','LeftBottom' and 'RightBottom'.
When RH/DH isn't equal to RW/RH, You should decide to select Width or Height ratio of resource to design resolution. Policies지금 cocos2d-x는 세 가지 방식을 지원합니다. Exact fitThe entire application is visible in the specified area without trying to preserve the original aspect ratio. Distortion can occur, and the application may appear stretched or compressed. 전체 응용 프로그램은 원래 가로 세로 비율을 유지하기 위해 노력하지 않고 지정된 지역에서 볼 수 있습니다. 왜곡이 발생할 수 있으며, 응용 프로그램은 늘어나거나 압축 나타날 수 있습니다. No borderThe entire application fills the specified area, without distortion but possibly with some cropping, while maintaining the original aspect ratio of the application. 응용 프로그램의 원래 가로 세로 비율을 유지하면서 전체 응용 프로그램, 왜곡하지 않고 있지만, 아마도 몇 가지 자르기와 함께 지정된 영역을 채 웁니다. Show allThe entire application is visible in the specified area without distortion while maintaining the original aspect ratio of the application. Borders can appear on two sides of the application. 응용 프로그램의 원래 가로 세로 비율을 유지하면서 전체 응용 프로그램은 왜곡없이 지정된 영역에 표시됩니다. 국경은 응용 프로그램의 두면에 게재 될 수 있습니다.
Mark② and Mark③ are both black rectangle areas. But they are different, Mark③ is out of Opengl Viewport, so you can't put any game elements onto it.
|
'잡다한것들전부 > 팁' 카테고리의 다른 글
| autoRelease 및 retain() , release(), retainCount() (0) | 2014.01.13 |
|---|---|
| CCNode 및 CCArray 의 메모리 관리 (0) | 2014.01.13 |
| cocos2d-x multi-resolution (0) | 2014.01.13 |
| cocos2d-x 스크롤 테이블뷰 예제 소스 (0) | 2014.01.13 |
| cocos2d-x CCString 분리후 CCArray 에 넣기( 문자열 분리하기) (0) | 2014.01.13 |
| cocos2d-x 의 메모리 관리 (0) | 2014.01.13 |
cocos2d-x 스크롤 예제 소스
'잡다한것들전부 > 팁' 카테고리의 다른 글
| CCNode 및 CCArray 의 메모리 관리 (0) | 2014.01.13 |
|---|---|
| cocos2d-x multi-resolution (0) | 2014.01.13 |
| cocos2d-x 스크롤 테이블뷰 예제 소스 (0) | 2014.01.13 |
| cocos2d-x CCString 분리후 CCArray 에 넣기( 문자열 분리하기) (0) | 2014.01.13 |
| cocos2d-x 의 메모리 관리 (0) | 2014.01.13 |
| cocos2d-x 멀티해상도 지원 (0) | 2014.01.13 |
'잡다한것들전부 > 팁' 카테고리의 다른 글
| cocos2d-x multi-resolution (0) | 2014.01.13 |
|---|---|
| cocos2d-x 스크롤 테이블뷰 예제 소스 (0) | 2014.01.13 |
| cocos2d-x CCString 분리후 CCArray 에 넣기( 문자열 분리하기) (0) | 2014.01.13 |
| cocos2d-x 의 메모리 관리 (0) | 2014.01.13 |
| cocos2d-x 멀티해상도 지원 (0) | 2014.01.13 |
| 숫자에 세자리마다 콤마를 찍는 알고리즘 (0) | 2014.01.10 |
c++에서는 new를 해주면 delete를 해주듯이.
cocos2d-x는 new로 객체를 생성시 release()를 호출하여 메모리를 해제한다.
cocos2d-x의 모든 클래스는 CCObject클래스를 상속받는데 CCObject클래스는 생성자에서 m_uReference라는 값을 1로 만들어준다.
m_uReference 의 값을 확인하는 함수는 retainCount()이다.
CCNode * node = new CCNode(); //CCNode의 m_uReference = 1 이됨
this->addChild(node); //CCNode의 m_uReference = 2 가됨
this->removeChild(node,true); //CCNode의 m_uReference = 1 가됨
node->release(); //CCNode의 m_uReference = -17891602(쓰레기값) 메모리해제됨 메모리 할당한값 전부 해제
addChilde시 m_uReference가 1 증가하고 , removeChild시 m_uReference가 1 감소한다. this의 m_uReference는 그대로 이다.
(메모리가 초기화 된것은 visual stduio에서 디버그-창-메모리-메모리1을 누르고 디버깅 모드에서 해당 주소값 입력후 초기화 되는지 확인하면 된다. 초기화가 되면 fe ee fe ee 이런식으로 값이 들어간다)
안전한 코드는 release()후 node = NULL을 입력시 안전한 코드가 된다. C++에서 delete후 null을 입력하는것과 마찬가지이다.
#define SAFE_RELEASE(p) if ((p) != NULL) { delete (p); (p) = NULL; }
이런식으로 정의한후
SAFE_RELEASE(node);로 해도 된다
cocos2d-x에서도 자체 매크로를 제공한다
#define CC_SAFE_DELETE(p) do { if(p) { delete (p); (p) = 0; } } while(0)
#define CC_SAFE_DELETE_ARRAY(p) do { if(p) { delete[] (p); (p) = 0; } } while(0)
#define CC_SAFE_FREE(p) do { if(p) { free(p); (p) = 0; } } while(0)
#define CC_SAFE_RELEASE(p) do { if(p) { (p)->release(); } } while(0)
#define CC_SAFE_RELEASE_NULL(p) do { if(p) { (p)->release(); (p) = 0; } } while(0)
#define CC_SAFE_RETAIN(p) do { if(p) { (p)->retain(); } } while(0)
#define CC_BREAK_IF(cond) if(cond) break
알아서 입맛에 맞게 매크로를 사용하면 된다.
void CCObject::retain(void)
{
CCAssert(m_uReference > 0, "reference count should greater than 0");
++m_uReference;
}
void CCObject::release(void)
{
CCAssert(m_uReference > 0, "reference count should greater than 0");
--m_uReference;
if (m_uReference == 0)
{
delete this;
}
}
autoRelease란 사용자가 메모리 관리에 신경을 덜 써도 된다. ( m_uReference 가 1이면 자동으로 메모리에서 해제된다.)
싱글턴으로 선언된 CCPoolManager에서 관리되면 CCPoolManager가 메모리에서 해제될때 CCPoolManager의 객체들을 전부
release()해주므로 CCPoolManager의 객체중 m_uReference가 1인 것들은 0이되고 자동으로 delete가 된다.
autoRelease는 보통 create()메서드 (2.0이상부터는 전부 create로 변경되었다.) 로 호출되는건 전부 라고 생각하면 된다.
CCNode * node = CCNode::create(); 이런식으로 호출하면 된다.
CCNode * CCNode::create(void)
{
CCNode * pRet = new CCNode();
pRet->autorelease();
return pRet;
}
CCObject* CCObject::autorelease(void)
{
CCPoolManager::sharedPoolManager()->addObject(this);
return this;
}
'잡다한것들전부 > 팁' 카테고리의 다른 글
| cocos2d-x 스크롤 테이블뷰 예제 소스 (0) | 2014.01.13 |
|---|---|
| cocos2d-x CCString 분리후 CCArray 에 넣기( 문자열 분리하기) (0) | 2014.01.13 |
| cocos2d-x 의 메모리 관리 (0) | 2014.01.13 |
| cocos2d-x 멀티해상도 지원 (0) | 2014.01.13 |
| 숫자에 세자리마다 콤마를 찍는 알고리즘 (0) | 2014.01.10 |
| [좌표] 좌표에 대해서 알아봅시다(convertToWorldSpace) 절대좌표 (0) | 2014.01.10 |
그림파일 이미지 해상도 960*640 (그림은 480*320으로 되있지만 960*640 이미지이다.)
디자인 해상도 480*320 (실제 작업 해상도) 터치좌표 반영되는 해상도 이다
디바이스 해상도 800*480 (가장 보편적인 디바이스 해상도 갤s 기준)
kResolutionExactFit.png
kResolutionNoBorder.png
kResolutionShowAll.png
1. noborder - 2번째
화면은 가득차지만 일부영역은 보여주지 못한다. 가로 세로 증가하는(Scale) 비율은 같다.
2. showAll -3 번째
전체 그림을 화면 안에 다 보여준다. 레터박스가 보일수 있으며 , 가로 세로 증가하는 비율은 같다.
3. ExactFit - 1번째
전체 그림을 화면 안에 다 보여준다. 가로 세로 증가하는 비율이 다르다.
CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
visibleSize 실제 화면에 보이는 해상도
origin 짤린 해상도 기준으로 시작하는 x,y 좌표
일반적으로 개발자는 noborder(테두리없음) 을 많이사용한다고 한다.
터치좌표 기준
1.noborder은
visibleSize [480, 288]
origin [-0, 16]
짤린하면은 총 32픽셀
480*320 해상도 기준(DESIGN_RESOLUTION) 으로 17~304까지 터치가 먹히고
위아래 16포인트는 터치가 안먹힌다. (짤린화면은 총 32픽셀)
origin 시작지점 16부터
2.showAll은
visibleSize [480, 320]
origin [0, 0]
검은색 짤린 화면은 터치가 안먹히고 보여지는 해상도내에서 480*320내에는 다 터치가 먹힌다.
3.ExactFit은
visibleSize [480, 320]
origin [0, 0]
전부 터치가 먹힘
'잡다한것들전부 > 팁' 카테고리의 다른 글
| cocos2d-x CCString 분리후 CCArray 에 넣기( 문자열 분리하기) (0) | 2014.01.13 |
|---|---|
| cocos2d-x 의 메모리 관리 (0) | 2014.01.13 |
| cocos2d-x 멀티해상도 지원 (0) | 2014.01.13 |
| 숫자에 세자리마다 콤마를 찍는 알고리즘 (0) | 2014.01.10 |
| [좌표] 좌표에 대해서 알아봅시다(convertToWorldSpace) 절대좌표 (0) | 2014.01.10 |
| [디자인패턴] cocos2d-x 싱글톤 싱글턴 패턴 구현 (0) | 2014.01.08 |
TableViewTest.zip

