<DAY> 2016.05.24 |
|||||||||
< WORK LIST > | |||||||||
<Class> Object_Hero.cpp |
|||||||||
- Ladder |
|||||||||
- Resource Work |
|||||||||
- State Apply |
1 |
Ladder |
주인공이 사다리를 타기 위해서
물리적으로 충돌하지 않는 박스를 만들어
주인공이 그 박스에 다으면 사다리가 근처에 있는것으로 간주해
↑↓버튼을 누를수 있게 하였다.
물리적인 충돌을 Collision이라고 한다면
그 반대는 Trigger라고 보면 된다.
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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | if(GetAsyncKeyState(VK_UP) ) { if( m_bLadder ) { m_iState = LADDER_UP; pos.y += MoveSpeed; vec.y = 1; if( ST::call()->BM.LadderRaycast( pos, CGPoint( 0, 1 ), &Hit, 100 ) ) pos.x = Hit.ObTarget->rc.origin.x + ( Hit.ObTarget->rc.size.width / 2 ); m_fLaderUpTime += dt; static bool LaderPressUp = FALSE; if( !LaderPressUp && m_fLaderUpTime > 0.1f ) { LaderPressUp = TRUE; m_fLaderUpTime = 0; m_iLadderUpFrame++; if( m_iLadderUpFrame > 4 ) m_iLadderUpFrame = 1; } LaderPressUp = FALSE; } } if(GetAsyncKeyState(VK_DOWN) ) { if( ST::call()->BM.CollisionCheck( CGPoint( pos.x, pos.y - 2.f ), LADDER ) != NULL && !m_bLadder ) { this->setDisplayFrame( ChangeAni( LADDER_DOWN ),(int)m_fFrame % 5 ); pos.y = pos.y - 5.f; } if( m_bLadder ) { m_iState = LADDER_DOWN; pos.y -= MoveSpeed; vec.y = -1; if( ST::call()->BM.LadderRaycast( pos, CGPoint( 0, -1 ), &Hit, 100 ) ) pos.x = Hit.ObTarget->rc.origin.x + ( Hit.ObTarget->rc.size.width / 2 ); m_fLaderDownTime += dt; static bool LaderPressDown = FALSE; if( m_fLaderDownTime > 0.1f && !LaderPressDown ) { LaderPressDown = TRUE; m_fLaderDownTime = 0; m_iLadderDownFrame++; if( m_iLadderDownFrame > 4 ) m_iLadderDownFrame = 1; } LaderPressDown = FALSE; } } | 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 | case LADDER_UP: { if( ST::call()->BM.LadderRaycast( pos, CGPoint( 0, 1 ), &Hit, 100 ) ) { this->setDisplayFrame( ChangeAni( m_iState ),(int)m_fFrame % m_iLadderUpFrame ); if( ST::call()->BM.CollisionCheck( pos, LADDER ) != NULL && ST::call()->BM.CollisionCheck( CGPoint( pos.x, pos.y + 40.f ), LADDER ) == NULL ) { pos.y = pos.y + 40.f; m_iState = IDLE; } else if( ST::call()->BM.CollisionCheck( CGPoint( pos.x, pos.y + 20.f ), LADDER ) == NULL ) { this->setDisplayFrame( ChangeAni( m_iState ),(int)m_fFrame % 5 ); this->setDisplayFrame( ChangeAni( m_iState ),(int)m_fFrame % 6 ); } } break; } case LADDER_DOWN: { ST::call()->BM.LadderRaycast( CGPoint( pos.x, pos.y + 30 ), CGPoint( 0, -1 ), &Hit, 100 ); this->setDisplayFrame( ChangeAni( m_iState ),(int)m_fFrame % m_iLadderDownFrame ); if( ST::call()->BM.CollisionCheck( CGPoint( pos.x, pos.y + 30 ), LADDER ) == NULL ) { m_iState = DROP; } break; } | cs |
2 | Resource Work |
LADDER_UP
LADDER_DOWN
WORK |
IDLE |
WALK |
ATTACK |
DASH |
JUMP |
DROP |
START |
JUMP_ATTACK |
DROP_ATTACK |
SHOT |
MIDDLES_SHOT |
FULL_SHOT |
WALK_ATTACK |
CHAGE_IDLE |
CHAGE_WALK |
CHAGE_DASH |
CHAGE_JUMP |
CHAGE_DROP |
CHAGE2_IDLE |
CHAGE2_WALK |
CHAGE2_DASH |
CHAGE2_JUMP |
CHAGE2_DROP |
New LADDER_UP |
New LADDER_DOWN |
3 | State Apply |
LADDER_UP & LADDER_DOWN
STATE APPLY |
IDLE |
WALK |
ATTACK |
DASH |
JUMP |
DROP |
START |
JUMP_ATTACK |
DROP_ATTACK |
SHOT |
MIDDLES_SHOT |
FULL_SHOT |
WALK_ATTACK |
CHAGE_IDLE |
CHAGE_WALK |
CHAGE_DASH |
CHAGE_JUMP |
CHAGE_DROP |
CHAGE2_IDLE |
CHAGE2_WALK |
CHAGE2_DASH |
CHAGE2_JUMP |
CHAGE2_DROP |
New LADDER_UP |
New LADDER_DOWN |
평 가 |
.난이도 : 보통 별 점 : ★★☆☆☆ 한 마디: 의외로 사다리는 쉬웠다. |
<Progress List> |
- Key Control |
- Box CollisionCheck |
- Camera Scroll |
- Player Resource Work |
- Player OutPut & Animation |
- New Ladder - <Complete> |
<Complete List> |
- Gravity Jump |
- MouseDrag Box Create |
- RayCast |
- File Input And Output |
- BackGround Output |
- Player Output |
- Bullet Output |
- Scroll Map Box |
- Player OutPut & Animation |
- Slope Move |
'cocos2D > 2D Project' 카테고리의 다른 글
[Cocos2d-x] Day 10 - Enemy & Enemy_Effect (0) | 2016.06.14 |
---|---|
[Cocos2d-x] Day 9 - WALL_DROP (0) | 2016.06.14 |
[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 5 - Scroll Map Box & Player Resource Work (0) | 2016.06.12 |