'2014/01'에 해당되는 글 185건

  1. 2014.01.10 [좌표] 좌표에 대해서 알아봅시다(convertToWorldSpace) 절대좌표
  2. 2014.01.10 [블로그] 블로그에 코딩 색 입히는 방법.
  3. 2014.01.09 유니티 Vector3 를 상수 선언 하고 싶을때.
  4. 2014.01.09 [Transitions] Scene의 장면전환 효과
  5. 2014.01.09 [Effects] cocos2-dx 이펙트에 대해서 알아보자!
  6. 2014.01.09 [Basic Concepts] Director, Scene, Layer, Sprite 개념 정리
  7. 2014.01.09 [Coordinate System] cocos2d-x 좌표 시스템
  8. 2014.01.09 c++ 11 이란??
  9. 2014.01.09 cocos2d-x v3.0 Beta 출시 되었습니다.
  10. 2014.01.09 [유니티3d][에셋] 유니티 필수 에셋 iTween 에 대해서 알아보자(Action!)

[좌표] 좌표에 대해서 알아봅시다(convertToWorldSpace) 절대좌표

|

[convertToWorldSpace]


convertToWorldSpace 함수에 대해서 알아봅시다.

예를 들어 게임을 제작시 배경하면을 스크롤 하는 기능을 넣을 시 배경화면에 자식노드를 넣고 처리할때 자식노드의 좌표를 알고 싶을때가 있다.

convertToWorldSpace는 부모 노드의 좌표를 기준으로 자식노드의 좌표를 구합니다.


               CCSize size = CCDirector::sharedDirector()->getWinSize(); CCSprite * background = CCSprite::create("HelloWorld.png"); background->setPosition(ccp(0,0)); this->addChild(background); CCSprite *closeSprite = CCSprite::create("CloseNormal.png"); closeSprite->setPosition(ccp(10,10)); background->addChild(closeSprite); CCPoint convertPos = background->convertToWorldSpace(closeSprite->getPosition()); CCLog("%2.f %2.f",convertPos.x, convertPos.y); CCLog("%2.f %2.f",closeSprite->getPosition().x, closeSprite->getPosition().y);



출력결과

-230 -150 10 10


배경화면이 480*320인 스프라이트를 0,0 좌표에 add해줄시 화면의 중간에 위치하게 됩니다.





close 스프라이트는 배경화면 기준으로 10,10 에 위치하게 되며

배경화면은 -240,-160 에서 부터 그려지게 되므로

배경화면을 기준으로 한 절대 좌표는 -230, -150이 됩니다.


만약 배경화면의 좌표를 480,320 으로 수정하면 아래 그림처럼 보이며

로그 값은

250,170

10,10 이 됩니다.





여기서 알수 있듯이. convertToWorldSpace는 setposition으로 준 값과 관계없이

디바이스상에서 보여주는 좌표를 기준으로 좌표를 변형해줍니다.






Trackback 0 And Comment 0

[블로그] 블로그에 코딩 색 입히는 방법.

|

가장 쉬운 방벙은

visual studio 에서 작업한 내용을  ms word에 붙이고 그걸 다시 복사해서 블로그에 붙이면 소스 코드 색을 그대로 입힐수 있음


다른 방법은 사이트를 통한 방법

http://markup.su/highlighter/


여기에서 코드를 입력하고 highlight버튼을 클릭하면 변형이 됨.


Trackback 0 And Comment 0

유니티 Vector3 를 상수 선언 하고 싶을때.

|


유니티 상에서 상수를 취급할때는 앞에 const 키워드를 붙여서 처리할수있습니다.

하지만 Vector3 값이나 다른 값들을 상수 취급하고 싶을때가 있습니다.

그럴때는 c# 의 프로퍼티 기능을 사용해서 상수로 취급할 수 있습니다.(읽어올수만 있게 만들기)



//선언부

public Vector3 MAXSIZE { get { return new Vector3(0.9f0.9f0.9f); } }



//사용시

Vector3 size = transform.localScale;

           

            if(size.x < MAXSIZE.x)

              size.x += 0.05f;

            if (size.y < MAXSIZE.y)           

              size.y += 0.05f;

            if (size.z < MAXSIZE.z)           

              size.z += 0.05f;


//값 대입시 에러 발생

MAXSIZE.x = 10; 



이렇게 파일을 적용하면 읽어오는 기능만 정의되어 값을 대입할수 없습니다.


Trackback 0 And Comment 0

[Transitions] Scene의 장면전환 효과

|

Transitions

소개

cocos2d-x의 멋진 특징중 하나인 두개의 씬 사이에 장면을 전환하는 효과입니다. 예를들어서(wipe, fade, zoom, and split등)
Transition Sceneclass은 CocosNode와 Layer로 부터 파생되어 나왔습니다.
일반적으로 transition scene은 새로운 scene로 넘어가기 전에 장면 전환 효과를 수행하게 됩니다.

Create transition

첫번째 인자의 시간은 트랜지션를위한 시간 (초)입니다. 다음과 같은 장면 전환을 적용하려면 구문은 다음과 같습니다

1CCDirector::sharedDirector()->replaceScene(CCTransitionFade::create(0.5,newScene));


일부 트랜지션은 사용자 지정 매개 변수 (들)을 가지고 있습니다. 예를 들어, FadeTransition 매개 변수로 페이드 색깔이있다.
static CCTransitionFade* create(float duration,CCScene* scene, const ccColor3B& color);

장면 전환을 하는 것은 매우 쉽습니다.

 1CCScene *s = SecondPage::scene();
 2
 3//CCTransitionProgressRadialCW,CCTransitionProgressRadialCCW,CCTransitionCrossFade需要以下设置
 4//CCConfiguration::sharedconfiguration()->getGlesVersion<=GLES_VER_1_0
 5
 6//启动摄像机测试景深,只有CCTransitionPageTurn才需要
 7CCDirector::sharedDirector()->setDepthTest(true);
 8
 9//false为下一页,true为上一页
10CCTransitionScene *transition = CCTransitionPageTurn::create(3.0f, s, false);

“page turn” 효과를 사용하면 이것은 책을 넘기는 효과 처럼 보인다.

트랜잭션의 종류



class  CCTransitionEaseScene
 CCTransitionEaseScene can ease the actions of the scene protocol. More...
 
class  CCTransitionScene
 Base class for CCTransition scenes. More...
 
class  CCTransitionSceneOriented
 A CCTransition that supports orientation like. More...
 
class  CCTransitionRotoZoom
 CCTransitionRotoZoom: Rotate and zoom out the outgoing scene, and then rotate and zoom in the incoming.More...
 
class  CCTransitionJumpZoom
 CCTransitionJumpZoom: Zoom out and jump the outgoing scene, and then jump and zoom in the incoming.More...
 
class  CCTransitionMoveInL
 CCTransitionMoveInL: Move in from to the left the incoming scene. More...
 
class  CCTransitionMoveInR
 CCTransitionMoveInR: Move in from to the right the incoming scene. More...
 
class  CCTransitionMoveInT
 CCTransitionMoveInT: Move in from to the top the incoming scene. More...
 
class  CCTransitionMoveInB
 CCTransitionMoveInB: Move in from to the bottom the incoming scene. More...
 
class  CCTransitionSlideInL
 CCTransitionSlideInL: Slide in the incoming scene from the left border. More...
 
class  CCTransitionSlideInR
 CCTransitionSlideInR: Slide in the incoming scene from the right border. More...
 
class  CCTransitionSlideInB
 CCTransitionSlideInB: Slide in the incoming scene from the bottom border. More...
 
class  CCTransitionSlideInT
 CCTransitionSlideInT: Slide in the incoming scene from the top border. More...
 
class  CCTransitionShrinkGrow
 Shrink the outgoing scene while grow the incoming scene. More...
 
class  CCTransitionFlipX
 CCTransitionFlipX: Flips the screen horizontally. More...
 
class  CCTransitionFlipY
 CCTransitionFlipY: Flips the screen vertically. More...
 
class  CCTransitionFlipAngular
 CCTransitionFlipAngular: Flips the screen half horizontally and half vertically. More...
 
class  CCTransitionZoomFlipX
 CCTransitionZoomFlipX: Flips the screen horizontally doing a zoom out/in The front face is the outgoing scene and the back face is the incoming scene. More...
 
class  CCTransitionZoomFlipY
 CCTransitionZoomFlipY: Flips the screen vertically doing a little zooming out/in The front face is the outgoing scene and the back face is the incoming scene. More...
 
class  CCTransitionZoomFlipAngular
 CCTransitionZoomFlipAngular: Flips the screen half horizontally and half vertically doing a little zooming out/in. More...
 
class  CCTransitionFade
 CCTransitionFade: Fade out the outgoing scene and then fade in the incoming scene. More...
 
class  CCTransitionCrossFade
 CCTransitionCrossFade: Cross fades two scenes using the CCRenderTexture object. More...
 
class  CCTransitionTurnOffTiles
 CCTransitionTurnOffTiles: Turn off the tiles of the outgoing scene in random order. More...
 
class  CCTransitionSplitCols
 CCTransitionSplitCols: The odd columns goes upwards while the even columns goes downwards. More...
 
class  CCTransitionSplitRows
 CCTransitionSplitRows: The odd rows goes to the left while the even rows goes to the right. More...
 
class  CCTransitionFadeTR
 CCTransitionFadeTR: Fade the tiles of the outgoing scene from the left-bottom corner the to top-right corner.More...
 
class  CCTransitionFadeBL
 CCTransitionFadeBL: Fade the tiles of the outgoing scene from the top-right corner to the bottom-left corner.More...
 
class  CCTransitionFadeUp
 CCTransitionFadeUp: Fade the tiles of the outgoing scene from the bottom to the top. More...
 
class  CCTransitionFadeDown
 CCTransitionFadeDown: Fade the tiles of the outgoing scene from the top to the bottom. More...
 
class  CCTransitionPageTurn
 A transition which peels back the bottom right hand corner of a scene to transition to the scene beneath it simulating a page turn. More...
 
class  CCTransitionProgress
 
class  CCTransitionProgressRadialCCW
 CCTransitionRadialCCW transition. More...
 
class  CCTransitionProgressRadialCW
 CCTransitionRadialCW transition. More...
 
class  CCTransitionProgressHorizontal
 CCTransitionProgressHorizontal transition. More...
 
class  CCTransitionProgressVertical
 
class  CCTransitionProgressInOut
 
class  CCTransitionProgressOutIn
 




Trackback 0 And Comment 0

[Effects] cocos2-dx 이펙트에 대해서 알아보자!

|

Effects

소개.

Effects는 action의 한 종류이다.. 투명도를 조절하거나 회전 혹은 크기 변경 등 일반 속성을 수정할수있다, grid라는 속성을 수정합니다.

grid 속성은 matrix와 비슷한데, it is a network of lines that cross each other to form a series of squares or rectangles.

These special actions render any CocosNode object (Layer, Scene, Sprite, etc.) into the grid, and you can transform the grid by moving its vertices.

2가지 종류의 grid가 있는데 하나는 타일 그리드이고 나머지 하나는 non-tiled 그리드입니다. 

차이점은 타일 그리드는 각각의 타일이 정점으로 구성되는데 반해  non-titled그리드는 4개의 정점으로 구성됩니다.

(non-tiled) grid:
 

타일그리드
 

사용하는 방법

다른 Action과 마찬가지로 runAction에서 실행됩니다.

1// Create an sprite
2CCSprite* grossini = CCSprite::create("grossini.png");
3grossini->runAction(CCLiquid::create(4, 20, ccg(10,10), 5));


Liquid,다른 grid 와 마찬가지로 grid 피라메터를 받는다. 원하는 그리드의 크기를 증가시킴으로써 이펙트의 품질을 조정할 수있다. 그러나 FPS가 떨어질수있음..

당신이 다른 어떤 Action처럼 취급 할 수 있도록 효과 IntervalAction 작업입니다. 예를 들면 :

1// create a Lens3D action
2CCActionInterval* lens = CCLens3D::create(ccp(240,160),240,ccg(15,10),8);
3
4// create a Waved3D action
5CCActionInterval* waves = CCWaves3D::create(18,80,ccg(15,10),10);
6
7// create a sequence an repeat it forever
8grossini->runAction(CCRepeatForever::create((CCSequence*)CCSequence::create(waves, lens, NULL ) ) );


(non-tiled) 액션

Shaky3D  Waves3D  FlipX3D  FlipY3D  
Lens3D  Liquid  Waves  Twirl  
Ripple3D  


타일 그리드 액션

ShakyTiles3D  ShatteredTiles3D  ShuffleTiles  FadeOutTRTiles  
FadeOutBLTiles  FadeOutUpTiles  FadeOutDownTiles  TurnOffTiles  
WavesTiles3D Sort_descJumpTiles3D  SplitRows  SplitCols  

References


Trackback 0 And Comment 0

[Basic Concepts] Director, Scene, Layer, Sprite 개념 정리

|

Director Scene Layer and Sprite

Scenes

Cocos2d-x에서 씬은 하나의 게임을 그 기능과 성격에 따라 여러 부분으로 나눌 때 사용하는 개념이다. 어떤 개발자들은 씬을 스크린이나 스테이지라고도 부르는데 모두 같은 개념이다. 

씬은 게임의 흐름으로부터 매우 독립적이다. 보통 여러 개의 씬이 모여 하나의 게임을 이루는데 한순간에 하나의 씬만 활성화된다. 각각의 씬은 서로 연결될 수 있기는 하지만 독립된 프로그램으로 생각해도 무방하다.

예들 들어, 만들어진 하나의 게임은 인트로(Intro), 메뉴(Menu), 레벨(Level) 1, 컷씬(Cutscene) 1, 레벨(Level) 2, 승리 결과 화면(Winning cutscene), 패배 결과 화면(Losing cutscene), 랭킹(High score) 등의 씬을 갖게 된다. 

좀더 자세히 설명하면, 게임이 시작되고 인트로 씬이 끝나면 메뉴 씬으로 이동한다. 다음으로 레벨 1 씬으로 전환된 뒤 컷씬이 종료되면, 사용자의 승패 여부에 따라 승리 또는 패배 결과 화면으로 씬이 전환된다. 

cocos2d CCScene 은 하나이상의 CCNode로 구성되며 Scene의 자식으로 더해집니다.

CCLayer 및 CCSprite(CCNode를 상속받는)는 모양과 동작을 Scene에 더해준다. 

일반적으로, CCLayer와 CCScene의 빈 인스턴스로 너의 Scene은 구성됩니다.

CCNodes로 다른 그래픽과 게임 객체를 구현하고 사용자가 만든 CCLayer에 자식으로 추가합니다.

Scene는 CCNode의 하위 클래스이므로, 이들은 수동 또는 CCActions을 사용하여 변환 될 수있다. 자세한 내용은 작업을 참조하십시오.

CCTransitionScene 클래스로 구현 전환이라고 CCScene 클래스의 가족이 있습니다. 그래서, 예를 들어 퇴색 측면에서의 슬라이딩, 그리고 - 다른 하나의 장면에서 전환 할 때 이러한 특수 전환 효과를 만들 수 있습니다.


Director

CCDirector는 싱글톤 패턴이며 활성화된 Scene를 알고있으며 현재 Scene를 교체할수있으며, 스택방식으로 push 및 pop으로 Scene를 관리할수있습니다.
그럴 경우 CCDirector은 이전 Scene를 일시중지하지만 메모리에 유지시킵니다. 만약 나중에 너가 맨위 Scene를 pop하면 일시중지된 Scene로 다시 시작합니다.

CCDirector는 OpenGL을 ES를 초기화 할 책임이 있습니다.


Layers

CCLayer가 터치 이벤트를 처리할수있는 CCNode입니다. CCLayer 자체를 그리는 방법을 아는 플레이어가 그들 뒤에 다른 레이어를 볼 수 있도록 반투명 수 있습니다. CCLayers은 게임의 모양과 동작을 정의하는 데 매우 유용합니다, 그래서 당신은 당신이 필요로 할 CCLayer의 서브 클래스를 코딩 프로그래밍 많은 시간을 소비 할 것으로 예상해야한다.

TCCLayer는 터치 이벤트 핸들러를 정의하는 곳이다.터치 이벤트 (ccTouchBegan, ccTouchMoved, ccTouchEnded 또는 ccTouchCancelled) 중 하나를 처리하는 방법을 구현함으로써 CCLayer는 플레이어의 상호 작용에 반응 할 수있다. 일부 Layer은 이벤트를 포착하고 그것을 받아 들일 때까지 이러한 터치 이벤트는, 앞에서 뒤로, 장면 내의 모든 계층에 전파됩니다.

복잡한 응용 프로그램을 사용자 정의 CCLayer 서브 클래스를 정의 할 필요가 동안,적인 Cocos2D는 미리 정의 된 여러 레이어를 제공합니다. 몇 가지 예는 CCMenu (간단한 메뉴 Layer), CCColorLayer (색깔을 그릴수 있는 Layer), 그리고 CCLayerMultiplex (CCLayer를 하나만 쓰고 싶을때) 등이 있습니다.

레이어 CCSprites, CCLabels, 심지어 다른 CCLayer 개체를 포함하여, 아이로 어떤 CCNode를 포함 할 수 있습니다. 층 CCNode의 하위 클래스이므로, 이들은 수동 또는 CCActions을 사용하여 변환 될 수있다. 자세한 내용은 작업을 참조하십시오.

Multiple Layers Example:

 1    CCLayerGradient* layer1 = CCLayerGradient::create(ccc4(255, 0, 0, 255), ccc4(255, 0, 255, 255));
 2    layer1->setContentSize(CCSizeMake(80, 80));
 3    layer1->setPosition(ccp(50,50));
 4    addChild(layer1);
 5
 6    CCLayerGradient* layer2 = CCLayerGradient::create(ccc4(0, 0, 0, 127), ccc4(255, 255, 255, 127));
 7    layer2->setContentSize(CCSizeMake(80, 80));
 8    layer2->setPosition(ccp(100,90));
 9    addChild(layer2);
10
11    CCLayerGradient* layer3 = CCLayerGradient::create();
12    layer3->setContentSize(CCSizeMake(80, 80));
13    layer3->setPosition(ccp(150,140));
14    layer3->setStartColor(ccc3(255, 0, 0));
15    layer3->setEndColor(ccc3(255, 0, 255));
16    layer3->setStartOpacity(255);
17    layer3->setEndOpacity(255);
18    ccBlendFunc blend;
19    blend.src = GL_SRC_ALPHA;
20    blend.dst = GL_ONE_MINUS_SRC_ALPHA;
21    layer3->setBlendFunc(blend);
22    addChild(layer3);

Sprites

Cocos2D의 CCSprite는 다른 게임 엔진에서 찾을 스프라이트 유사합니다. 그것은, 회전, 이동 조정, 애니메이션 및 기타 변환을받을 수있는 2D 이미지입니다. (CCSprite 클래스를 사용하여 구현) 스프라이트는 어린이와 같은 다른 스프라이트를 할 수 있습니다. 부모가 변형 될 때, 모든 아이들은 물론 변환됩니다. 스프라이트 CCNode의 하위 클래스이므로, 이들은 수동 또는 CCActions을 사용하여 변환 될 수있다. 자세한 내용은 작업을 참조하십시오.

Trackback 0 And Comment 0

[Coordinate System] cocos2d-x 좌표 시스템

|

좌표 시스템

기존과 다른 좌표 시스템을 도입.Introduction of Different Coordinate Systems


직교 좌표 시스템(데카르트 좌표)

너는 아마 기하학 수업에 사용되는 좌표를 알고 있을 것이다.

모바일에서는 보통 3가지 정도의 좌표 시스템이 있다.

UI 좌표 시스템

안드로이드나 아이폰에서의 좌표 시스템

  • 좌측 상단이 (0,0) 이다.
  • X 축은 왼쪽에서부터 오른쪽으로 갈수록 증가한다.
  • Y 축은 화면 상단에서 부터 아래로 내려 갈수록 증가한다.

looks like this

Direct3D 좌표 시스템

DirectX 에서는 왼손좌표계를 사용한다.


OpenGL 그리고 Cocos2d 의 좌표시스템

openGL과 cocos2d는 오른손 좌표계를 사용한다.


우리는 2d게임에서 오직 x,y축만 사용합니다. 

  • 좌측 하단이 (0,0) 좌표이고 오른손 좌표계를 사용합니다.
  • X 축은 왼쪽에서부터 오른쪽으로 갈수록 증가합니다.;
  • Y 축은 아래부터 시작하며 위로 갈수록 증가합니다.

좌표 시스템을 좀더 이해하기 쉽도록 아래 사진이 준비되어있음

다이렉트x나 일반적 ui시스템과 다른 좌표시스템이다.


Parent and Childrens

CCNode를 상속받는 모든 클래스는 anchorPoint 속성을 가지고 있습니다.

CCNode를 상속받는 객체를 그릴때(sprite, layer, 기타등등) , cocos2d-x는 anchorpoint와 position를 결합합니다. 또한 물체를 회전할때 Anchorpoint를 기준으로 회전하게됩니다.

우리는 회색배경의 부모 클래스를 만들었고 파란색 배경의 자식클래스를 만들었습니다. 부모의 좌표는((100,100)이고 자식의  anchor point는 중앙입니다.

 1    CCSprite* parent = CCSprite::create("parent.png");
 2    parent->setAnchorPoint(ccp(0, 0));// Anchor Point
 3    parent->setPosition(ccp(100, 100));
 4    parent->setAnchorPoint(ccp(0, 0));
 5    addChild(parent);
 6
 7    //create child 
 8    CCSprite* child = CCSprite::create("child.png");
 9    child->setAnchorPoint(ccp(0.5, 0.5));
10    child->setPosition(ccp(0, 0));
11    parent->addChild(child);//add child sprite into parent sprite.


자식의 위치가 (0,0) 이고 부모의 위치가 (100,100)일때 아래 그림과 같다.

Anchor Point

앵커 포인트의 위치와 개체를 회전 모두에 사용됩니다.앵커 포인트의 좌표는 일반적으로 개체 내 지점에 해당하는 상대 좌표입니다. 예를 들어, 앵커 포인트 CCP (0.5, 0.5)는 객체의 중심에 대응한다.물체의 위치를 설정할 때, 객체는 앵커 포인트로 setPosition () 호출에 지정된 좌표에있을 것이다되도록 위치된다.객체를 회전시킬 때 마찬가지로, 그 기준점에 대해 회전된다.

예를 들어 sprite가 앵커포인트 와 위치가 0,0일때

그 결과 sprite는 하단 왼쪽 모서리에 배치됩니다.

1// create sprite
2CCSprite* sprite = CCSprite::create("bottomleft.png");
3sprite->setAnchorPoint(ccp(0, 0));// Anchor Point
4sprite->setPosition(ccp(0,0));
5addChild(sprite);


예를 들어 sprite가 앵커포인트는 (0.5,0.5) 이고 위치가 0,0일때

1// create sprite
2CCSprite* sprite = CCSprite::create("center.png");
3sprite->setAnchorPoint(ccp(0.5, 0.5));// Anchor Point
4sprite->setPosition(ccp(0,0));
5addChild(sprite);


위와 같이 sprite의 중심이 좌표 0,0에 위치합니다. 앵커포인트는 화소값이 아닌 노드에 상대적인 크기입니다. 0~1 까지 존재함.

getVisibleSize, getVisibleOrigin vs getWinSize

VisibleSize 은 OpenGL상에서 보여지는 크기를 리턴합니다.이 값은  CCEGLView::setDesignResolutionSize()이 함수를 호출하지 않으면 getWinSize와 같습니다.

getVisibleOrigin은 OpenGL상에서 보이는 x,y의 좌표를 반환합니다.


How to convert co-ordinates

convertToNodeSpace:

convertToNodeSpace will be used in, 예를 들어 타일 기반 게임에서, 너가 큰 맵을 가지고 있을때. convertToNodeSpace는 너의 OpenGL 터치 좌표를 큰맵에 있는 좌표계를 기준으로 변형해줍니다.

Example:

다음그림은 보여줍니다. node1의 앵커포인트(0,0)이고 node2의 앵커포인트(1,1)입니다.

우리가  호출하면CCPoint point = node1->convertToNodeSpace(node2->getPosition()); convert node2의 스크린 좌표계는 node1의 좌표계를 기준으로 구해지게 되며 그 결과 node2 의 좌표는 (-25,-60) 이 됩니다.

convertToWorldSpace:

convertToWorldSpace(const CCPoint& nodePoint) coordinates.convertToWorldSpace 항상 우리의 스프라이트의 화면 위치를 반환합니다 당신은 당신의 스프라이트에 탭을 캡처 할하지만 레이어를 확장 / 이동해야하는 경우 매우 유용 할 수 있습니다 화면에 노드 좌표입니다 변환합니다.


일반적으로, 자식 노드의 위치와 부모 노드 호출이 방법은 결과로 아이의 세계의받은 위치를 반환합니다. 호출자가 부모가 아닌 경우이 메서드를 호출 아무 의미도하지 않습니다 것 같다 ...

Example:

1CCPoint point = node1->convertToWorldSpace(node2->getPosition()); 

위의 코드는 화면의 좌표로 노드 2의 좌표를 변환합니다.

예를 들어, 노드 1의 앵커 위치 (0, 0)이 화면에 필요없는 노드 1의 왼쪽 하단 모서리, 그러나되는 경우. 이 화면에 점의 (-5, -20) 좌표 노드 1에 대해 (이 경우)가 (15, 20입니다) (-20, -5)는 노드 2의 위치를 ​​변환합니다.결과는 다음 그림에서 보여줍니다

convertToWorldSpaceAR,

convertToWorldSpaceAR 지점을 고정하는 relatevely 위치를 반환합니다, 그래서 우리의 장면 경우 - 루트 층은 CCP의 앵커 포인트 (0.5F, 0.5F)이 - 기본, convertToWorldSpaceAR은 상대적으로 화면 중앙에 위치를 반환해야합니다.

convertToNodeSpaceAR -. convertToWorldSpaceAR와 동일한 논리

Sample code:

 1
 2CCSprite *sprite1 = CCSprite::create("CloseNormal.png");
 3
 4sprite1->setPosition(ccp(20,40));
 5
 6sprite1->setAnchorPoint(ccp(0,0));
 7
 8this->addChild(sprite1);
 9
10CCSprite *sprite2 = CCSprite::create("CloseNormal.png");
11
12sprite2->setPosition(ccp(-5,-20));
13
14sprite2->setAnchorPoint(ccp(1,1));
15
16this->addChild(sprite2);
17
18CCPoint point1 = sprite1->convertToNodeSpace(sprite2->getPosition());
19
20CCPoint point2 = sprite1->convertToWorldSpace(sprite2->getPosition());
21
22CCPoint point3 = sprite1->convertToNodeSpaceAR(sprite2->getPosition());
23
24CCPoint point4 = sprite1->convertToWorldSpaceAR(sprite2->getPosition());
25
26CCLog("position = (%f,%f)",point1.x,point1.y);
27
28CCLog("position = (%f,%f)",point2.x,point2.y);
29
30CCLog("position = (%f,%f)",point3.x,point3.y);
31
32CCLog("position = (%f,%f)",point4.x,point4.y);
33

Result:

 1
 2position = (-25.000000,-60.000000)
 3
 4position = (15.000000,20.000000)
 5
 6position = (-25.000000,-60.000000)
 7
 8position = (15.000000,20.000000)
 9



Trackback 0 And Comment 0

c++ 11 이란??

|

C++11

위키백과, 우리 모두의 백과사전.

C++ 11(C++0x라고도 알려짐)은 [1] ISO가 2011년 8월 12일에 승인한 C++ 프로그래밍 언어의 최신판이다. [2] 이름은 사양이 출판되는 날짜를 언어 버전 이름으로 삼는 전통에서 유래되었다.

C++11은 핵심 언어에 여러가지를 추가하고 C++ 표준 라이브러리를 확장하고, C++ 기술 보고서 1(TR1)의 라이브러리의 수학적 특수 함수의 라이브러리 예외를 통합했다.[3] C++11은 ISO/IEC 14882:2011라고 출판되었다.

이전 표준에서의 변화[편집]

C++ 의 수정은 핵심 언어와 표준 라이브러리 모두를 포함한다. 2011 표준안의 모든 활용에 대한 개발에서, 표준 위원회에서는 몇 가지 지침을 적용했다.

  • 안정성 및 C++98(가능하면 C언어와도)과의 호환성 유지
  • 핵심 언어의 확장보다는 표준 라이브러리를 이용하려 새로운 기능 추가
  • 프로그래밍 기술을 발전시킬 변화 선호
  • 특정 애플리케이션에서만 유용한 새로운 기술보다는 시스템이나 라이브러리 디자인에 유용하게 C++을 개선
  • 이전의 안전하지 않은 기술에 대해 좀 더 안전한 대안을 제공하여 type 안전성 증가
  • 성능 향상과 하드웨어 직접 조작 능력 강화
  • 실 세계의 문제를 해결할 수 있는 해법 제시
  • "부담 최소화"의 원칙 (어떤 유틸리티가 필요로 하는 추가적인 지원은 그 유틸리티를 사용할 때만 필요해야 함)
  • 전문 프로그래머가 필요로 하는 어떤 유틸리티도 제거하지 않고도, 쉽게 가르치거나 배울 수 있어야 함

프로그래머 중 초심자가 대다수이며, 많은 초심자들은 C++에 대한 지식을 늘리기 보다는 그들에게 특화된 언어 측면에만 매진하는 경향이 있기 때문에 그들에 대해 주의를 기울이는 것이 중요하다.

C++ 언어의 문법 확장[편집]

C++ 위원회의 주된 관심은 언어 문법을 개발하는 것이다. C++0x의 프리젠테이션 일정은 표준안에서 이 부분의 진행에 영향을 받는다.

언어의 문법적 범위는 멀티태스킹 지원, 제네릭 프로그래밍 지원, 초기화 방법 통합, 성능 향상 등으로 매우 증가하였다.

이 문서의 목적에 맞게, 문법적 기능과 변화는 "런타임 성능 향상", "컴파일 성능 향상", "편의성 향상", "새로운 기능"등의 4부분으로 그룹화하였다. 일부 기능은 여러 부분에서 언급될 수 있지만, 주된 기능에 대해서 한번씩만 설명할 것이다.

핵심 언어 - 런타임 성능 향상[편집]

아래 나열된 기능은 주로 메모리나 계산 속도에 대한 성능 향상을 제공한다.

문법 기능의 편의성 향상[편집]

문법의 새로운 기능[편집]

  • 템플릿에서의 가변 인자
  • 새로운 문자열 리터럴
  • 사용자 정의 리터럴
  • 멀티태스킹 메모리 모델
  • TLS
  • 특수 멤버함수에 대해 기본값 사용및 삭제에 대한 명시적 표시
  • long long int 자료형
  • 정적 assertion
  • 멤버에 대한 sizeof 허용

C++ 표준 라이브러리의 변화[편집]

새로운 기능의 상당수는 C++0x 표준 라이브러리에서 소개된다. 이들중 상당수는 현재의 표준안에서도 구현될 수 있다. 하지만 일부는 C++0x의 새로운 문법에 의존한다.

새로운 라이브러리의 대부분은 C++ 표준 위원회의 TR1이라고 불리는 기술 보고서에서 정의되고 있으며 이는 2005년에 발표되었다. TR1의 대부분은 std::tr1 네임스페이스에서 현재 이용가능하다. C++0x에 맞게 그 네임스페이스를 std로 이동할 것이다. 하지만 C++0x 표준 라이브러리에서 TR1 기능이 제공됨에 따라, 초기 TR1에서 제공되지 않았던 기능들과 함께 적당한 위치로 업그레이드될 것이다. 또한 C++03에서 구현 가능했던 기능들을 C++0x에 맞게 향상되겠지만 오리지날 TR1 규정의 부분은 아니다.

위원회는 C++0x 표준안이 완료된 이후에 TR2를 계획하고 있다. C++0x를 만들면서 준비되지 못한 라이브러리 제안사항은 TR2나 그 뒤의 기술 보고서에서 다룰 것이다.

다음 제안 사항들은 C++0x에서 진행되고 있다.

  • 표준 라이브러리의 업그레이드
  • 스레드
  • 튜플 자료형
  • 해시 테이블
  • 정규 표현식
  • 범용 스마트 포인터
  • 확장가능한 난수 생성기
  • wrapper 레퍼런스
  • 함수객체에 대한 다형성이 있는 wrapper
  • 메타 프로그래밍을 위한 type traits
  • 함수객체의 리턴형에 대한 방법

적용[편집]

C++11은 GCC 4.3부터[4] 4.7에서[5] 시험적용되고 있고, Visual Studio 10[6]부터 Visual Studio 12[7]까지 부분적으로 적용되고 있다.

인용[편집]

  1. 이동 http://video.google.com/videoplay?docid=5262479012306588324#
  2. 이동 We have an international standard: C++0x is unanimously approved. 12 August 2011에 확인.
  3. 이동 Bjarne Stroustrup: A C++0x overview. 30 June 2011에 확인.
  4. 이동 http://gcc.gnu.org/projects/cxx0x.html
  5. 이동 http://gcc.gnu.org/gcc-4.7/cxx0x_status.html
  6. 이동 http://blogs.msdn.com/b/vcblog/archive/2010/04/06/c-0x-core-language-features-in-vc10-the-table.aspx
  7. 이동 http://blogs.msdn.com/b/vcblog/archive/2011/09/12/10209291.aspx

바깥 고리[편집]






'잡다한것들전부 > C, C++, C#' 카테고리의 다른 글

추상 클래스 (C++)  (0) 2014.01.10
Duff's Device  (0) 2014.01.10
c++ 11 이란??  (0) 2014.01.09
strncpy 로 메모리 복사  (0) 2014.01.07
C언어 배열 초기화 방법  (0) 2014.01.07
c++ stl 관련 자료  (0) 2014.01.06
Trackback 0 And Comment 0

cocos2d-x v3.0 Beta 출시 되었습니다.

|

cocos2d-x v3.0 Beta


Highlights

  • New renderer. Renderer has being decoupled from the Scene Graph. It supports auto-batching and auto-culling.
  • Added template containers. cocos2d::Map<>cocos2d::Vector<>
  • Label supports: shadow, glow and outline (beta)
  • Added Joint support in the physics subsystem
  • Added Console: A simple TCP console that lets you debug and inspect your game remotely
  • tools/project_creator/project_creator.py includes a GUI to simplify the game creation process. It also allows you to create the game in any given directory.
  • Added support to build Android's APK files in the android-build.py script
  • Added Scheduler::performFunctionInCocosThread(). It supports executing a function in the cocos2d thread
  • Director emits the following events using the EventDispatcherAFTER_UPDATEAFTER_DRAW,AFTER_VISIT and PROJECTION_CHANGED
  • Added Cocos2dxActivity.java which inherits from native activity. Ingetrating 3rd Android SDK would be much easilier on v3.0.

Read more about all the new features at cocos2d-x v3.0 release notes


알파에서 베타버전으로 출시되이써습니다.

정식버전이 기대됩니다.

'잡다한것들전부 > 소식' 카테고리의 다른 글

cocos2d-x v3.0 Beta 출시 되었습니다.  (0) 2014.01.09
Trackback 0 And Comment 0

[유니티3d][에셋] 유니티 필수 에셋 iTween 에 대해서 알아보자(Action!)

|


유니티 필수 에셋 중에 하나인 아이트윈

유니티에서 물체의 움직임을 보다 쉽게 설정 할 수 있습니다.

유니티를 켜시고 에셋 스토어로 갑시다 ctrl + 9 를 누르면 Asset Store에 들어가집니다.
iTween 으로 검색하시면 아래와 같이 화면이 나오고 다운로드 버튼을 누르고 유니티 상에 import 시켜줍니다. 





파일을 여시면 sample 소스가 존재합니다. sample 소스를 보시면 iTween 이라는게 뭐구나 하고 싶게 이해 할수있으실겁니다.




간단하게 샘플 소스에 대해 알아보겠습니다.




using UnityEngine;

using System.Collections;

 

public class MoveSample : MonoBehaviour

{               

                  void Start(){

                                   iTween.MoveBy(gameObject, iTween.Hash("x", 2, "easeType", "easeInOutExpo", "loopType", "pingPong", "delay", .1));

                  }

}


moveSample 입니다.


  • MoveBy(GameObject target, Vector3 amount, float time)
  • MoveBy(GameObject target, Hashtable args)

  • moveBy를 호출하는 방법은 위와 같이 두가지 방법이 있습니다.

    첫번째는 호출 방법은 위치와 시간을 집어넣어주는 함수이고

    두번째는 호출 방법은 해쉬테이블을 집어넣는 방식입니다.


    위함수에서는

    x = 2;

    easeType = "easeInOutExpo"

    loopType = "pingPong"

    delay = .1;

    해쉬테이블의 name 에 각 값들을 집어넣은 것과 같습니다.

    해쉬테이블을 미리 선언하고 아래와 같이 집어넣을 수 도 있습니다.


    Hashtable ht = new Hashtable();
    	
    void Awake(){
    	ht.Add("x",3);
    	ht.Add("time",4);
    	ht.Add("delay",1);
    	ht.Add("onupdate","myUpdateFunction");
    	ht.Add("looptype",iTween.LoopType.pingPong);
    }
    
    void Start(){
    	iTween.MoveTo(gameObject,ht);
    }



    함수의 종류는 아래와 같습니다.


    MoveBy BACK TO TOP

    Adds the supplied coordinates to a GameObject's position.

    • MoveBy(GameObject target, Vector3 amount, float time)
    • MoveBy(GameObject target, Hashtable args)
    Property NameTypePurpose
    namestringan individual name useful for stopping iTweens by name
    amountVector3for a point in space the GameObject will animate to.
    xfloat or doublefor the individual setting of the x axis
    yfloat or doublefor the individual setting of the y axis
    zfloat or doublefor the individual setting of the z axis
    orienttopathbooleanfor whether or not the GameObject will orient to its direction of travel. False by default
    looktargetTransform or Vector3for a target the GameObject will look at
    looktimefloat or doublefor the time in seconds the object will take to look at either the "looktarget" or "orienttopath"
    axisstringrestricts rotation to the supplied axis only
    spaceSpacefor applying the transformation in either the world coordinate or local cordinate system. Defaults to local space
    timefloat or doublefor the time in seconds the animation will take to complete
    speedfloat or doublecan be used instead of time to allow animation based on speed
    delayfloat or doublefor the time in seconds the animation will wait before beginning
    easetypeEaseType or stringfor the shape of the easing curve applied to the animation
    looptypeLoopType or stringfor the type of loop to apply once the animation has completed
    onstartstringfor the name of a function to launch at the beginning of the animation
    onstarttargetGameObjectfor a reference to the GameObject that holds the "onstart" method
    onstartparamsObjectfor arguments to be sent to the "onstart" method
    onupdatestringfor the name of a function to launch on every step of the animation
    onupdatetargetGameObjectfor a reference to the GameObject that holds the "onupdate" method
    onupdateparamsObjectfor arguments to be sent to the "onupdate" method
    oncompletestringfor the name of a function to launch at the end of the animation
    oncompletetargetGameObjectfor a reference to the GameObject that holds the "oncomplete" method
    oncompleteparamsObjectfor arguments to be sent to the "oncomplete" method
    ignoretimescalebooleansetting this to true will allow the animation to continue independent of the current time which is helpful for animating menus after a game has been paused by setting Time.timeScale=0




     

    using UnityEngine;

    using System.Collections;

     

    public class RotateSample : MonoBehaviour

    {               

                      void Start(){

                                       iTween.RotateBy(gameObject, iTween.Hash("x", .25, "easeType", "easeInOutBack", "loopType", "pingPong", "delay", .4));

                      }

    }

     

     

    RotateSample 입니다.


    RotateBy BACK TO TOP

    Multiplies supplied values by 360 and rotates a GameObject by calculated amount over time.

    • RotateBy(GameObject target, Vector3 amount, float time)
    • RotateBy(GameObject target, Hashtable args)

    Property NameTypePurpose
    namestringan individual name useful for stopping iTweens by name
    amountVector3for the amount to be multiplied by 360 to rotate the GameObject.
    xfloat or doublefor the individual setting of the x axis
    yfloat or doublefor the individual setting of the y axis
    zfloat or doublefor the individual setting of the z axis
    spaceSpace or stringfor applying the transformation in either the world coordinate or local cordinate system. Defaults to local space.
    timefloat or doublefor the time in seconds the animation will take to complete
    speedfloat or doublecan be used instead of time to allow animation based on speed
    delayfloat or doublefor the time in seconds the animation will wait before beginning
    easetypeEaseType or stringfor the shape of the easing curve applied to the animation
    looptypeLoopType or stringfor the type of loop to apply once the animation has completed
    onstartstringfor the name of a function to launch at the beginning of the animation
    onstarttargetGameObjectfor a reference to the GameObject that holds the "onstart" method
    onstartparamsObjectfor arguments to be sent to the "onstart" method
    onupdatestringfor the name of a function to launch on every step of the animation
    onupdatetargetGameObjectfor a reference to the GameObject that holds the "onupdate" method
    onupdateparamsObjectfor arguments to be sent to the "onupdate" method
    oncompletestringfor the name of a function to launch at the end of the animation
    oncompletetargetGameObjectfor a reference to the GameObject that holds the "oncomplete" method
    oncompleteparamsObjectfor arguments to be sent to the "oncomplete" method
    ignoretimescalebooleansetting this to true will allow the animation to continue independent of the current time which is helpful for animating menus after a game has been paused by setting Time.timeScale=0











    보다 많은 정보는 iTwwen 홈페이지에서 찾아볼수있습니다.

    ITwen 홈페이지 :http://itween.pixelplacement.com/index.php


    관련 동영상 강좌 입니다.


    https://www.youtube.com/watch?v=qRafXt26a_E

    https://www.youtube.com/watch?v=qE5hpp4YaH4


    https://www.youtube.com/watch?v=hbSxwoWjBgQ -> 한글





    Trackback 0 And Comment 0
    prev | 1 | ··· | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | next