<DAY> 2016.05.22 |
|||||||||
< WORK LIST > | |||||||||
<Class> Object_Hero.cpp & Box_Manager.cpp |
|||||||||
- Scroll Map Box |
|||||||||
- Player Resource Work |
|||||||||
- Player Resource Animation Apply |
1 |
Scroll Map Box |
2 |
Player Resource Work |
IDLE
WALK
ATTACK
DASH
JUMP
DROP
Work |
New IDLE |
New WALK |
New ATTACK |
New DASH |
New JUMP |
New DROP |
3 | Player Resource Animation Apply |
Update에서 플레이어 상태에 따른 애니메이션을 setDisplayFrame으로 바꿔준다.
1 2 3 4 5 6 7 8 9 | void Object_Hero::update(float dt) { KeyInput(dt); StateChange(dt); AnimationSpeed(dt); this->setDisplayFrame( ChangeAni( m_iState ),(int)m_fFrame % FrameCount( m_iState ) ); if( m_iState != JUMP && m_iState != DROP && m_iState != START && m_iState != ATTACK ) m_iState = IDLE; } | cs |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | char * Object_Hero::ChangeAni( int _State ) { switch( _State ) { case START: return "START"; case IDLE: return "IDLE"; case WALK: return "WALK"; case JUMP: return "JUMP"; case DROP: return "DROP"; case DASH: return "DASH"; case ATTACK: return "ATTACK"; } return "x"; } | cs |
1 2 3 4 5 6 7 8 9 10 11 12 13 | void Object_Hero::AnimationSpeed( float dt ) { switch( m_iState ) { case START: m_fFrame += dt * 10; break; case IDLE: m_fFrame += dt * 5; break; case WALK: m_fFrame += dt * 20; break; case JUMP: m_fFrame += dt * 5; break; case DROP: m_fFrame += dt * 5; break; case DASH: m_fFrame += dt * 15; break; case ATTACK: m_fFrame += dt * 10; break; } } | cs |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | int Object_Hero::FrameCount( int _State ) { switch( _State ) { case START: return MAXSTART; case IDLE: return MAXIDLE; case WALK: return MAXWALK; case JUMP: return MAXJUMP; case DROP: return MAXDROP; case DASH: return MAXDASH; case ATTACK: return MAXATTACK; } return -1; } | cs |
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 | if( m_iState != START ) { if(GetAsyncKeyState(VK_RIGHT)) { vec.x = 1; if( m_bMoveSpeedIncrease ) { m_iState == ATTACK && m_iPrevState == WALK || m_iPrevState == ATTACK ? pos.x += 0 : pos.x += MoveSpeed + 2; } else { m_iState == ATTACK && m_iPrevState == WALK || m_iPrevState == ATTACK ? pos.x += 0 : pos.x += MoveSpeed; } if( m_iState != JUMP && m_iState != DROP && m_iState != ATTACK ) m_iState = WALK; } if(GetAsyncKeyState(VK_LEFT)) { vec.x = -1; if( m_bMoveSpeedIncrease ) { m_iState == ATTACK && m_iPrevState == WALK || m_iPrevState == ATTACK ? pos.x -= 0 : pos.x -= MoveSpeed + 2; } else { m_iState == ATTACK && m_iPrevState == WALK || m_iPrevState == ATTACK ? pos.x -= 0 : pos.x -= MoveSpeed; } if( m_iState != JUMP && m_iState != DROP && m_iState != ATTACK ) m_iState = WALK; } } | cs |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | // 점프 static bool JumpKeyPress = false; if(GetAsyncKeyState('C') && JumpKeyPress == false ) { if( m_iState != DROP && m_iState != JUMP ) { m_iState = JUMP; JumpKeyPress = true; if( m_iPrevState == DASH ) { m_fAccelerator = JUMPPOWER + DASH_JUMP_POWER; m_bMoveSpeedIncrease = TRUE; } else m_fAccelerator = JUMPPOWER; } } else if(!GetAsyncKeyState('C')) JumpKeyPress = false; | cs |
1 2 3 4 5 6 7 | // 대시 if(GetAsyncKeyState('V') && m_bOneDash == FALSE ) { if( m_iState != DROP && m_iState != JUMP && m_iState != DASH ) m_iState = DASH; } else if(!GetAsyncKeyState('V')) m_bOneDash = FALSE; | cs |
1 2 3 4 5 6 7 8 9 | // 공격 static bool AttackPress = FALSE; if(GetAsyncKeyState('X') && !AttackPress ) { if( m_iState != JUMP && m_iState != DROP ) m_iState = ATTACK; AttackPress = TRUE; } if(!GetAsyncKeyState('X')) AttackPress = FALSE; | cs |
JUMP & DROP
State Apply |
New IDLE |
New WALK |
New ATTACK |
New DASH |
New JUMP |
New DROP |
평 가 |
.난이도 : 쉬움 별 점 : ★☆☆☆☆ 한 마디: 어려운 점은 없었다. 다만, 작업량이 매우 많았기 때문에 번거로운 점은 있었다. 또, 상태가 하나씩 추가 될때마다 새로 추가된 상태에 대한 전에 작업 한 상태에따른 제어를 다시 고쳐야 했던 부분이 매우 번거로웠다. |
<Progress List> |
- Key Control |
- Box CollisionCheck |
- Camera Scroll |
- New Player Resource Work |
- New Scroll Map Box - <complete> |
- New Player OutPut & Animation - <complete> |
<Complete List> |
- Gravity Jump |
- MouseDrag Box Create |
- RayCast |
- File Input And Output |
- BackGround Output |
- New Scroll Map Box |
- New Player OutPut & Animation |
'cocos2D > 2D Project' 카테고리의 다른 글
[Cocos2d-x] Day 7 - Slope Move (0) | 2016.06.13 |
---|---|
[Cocos2d-x] Day 6 - Resource Work & Bullet Class, Manager Create (0) | 2016.06.12 |
[Cocos2d-x] Day 4 - BackGround & CameraScroll & File Input And Output (0) | 2016.06.09 |
[Cocos2d-x] Day 3 - MouseDrag Box Create & RayCast Collision (0) | 2016.06.08 |
[Cocos2d-x] Day 2 - Create Box / Box CollisionCheck (0) | 2016.06.08 |