에니메이션 효과
1. MoveSprite를 이동시키는 Action으로 MoveTo와 MoveBy가 있음
2. Rotate
Sprite에서 회전을 시키는 Action으로는 RotateTo와 RotateBy가 있임
3. Scale
Sprite 의 크기를 변경하는 Action으로는 ScaleTo와 ScaleBy가 있음
4. Jump
Cocos2d 에서는 애니메이션에서 특이하게 Jump도 설정할 수 있는데, JumpTo와 JumpBy로 가 있음
5 Bezier(곡선)
Sprite 가 이동할 경로를 곡선을 하고 싶을 때에는 BezierBy actionWithDuration:bezier:를 사용한다.
6 Blink
Blink는 Sprite를 깜박이게 만든다. Blink actionWithDuration:blinks: 메소드를 사용하는데 여기서 blinks로 actionWithDuration에 설정한 시간만큰 깜박일 횟수를 설정
7. Fade
Sprite 를 점점 나타나게도 점점 사라지게도 할 수 있는데 이렇게 할 수 있도록 하는 Action이 FadeIn과 FadeOut이 있음
8. Tint
Sprite 의 농도를 마음대로 변경도 할 수 있다. 이는 TintTo actionWithDuration:red:green:blue: 와 TintBy actionWithDuration:red:green:blue:를 사용해서 수정
9. Animate
위의 여러가지 효과를 통합적으로 사용할때 사용

Title 인 이미지 Sprite 는 FadeIn 효과로 액션을 줘서 처음 완전 투명한 상태에서 점점 나타는 효과로 구현
// 처음 title의 투명도를 0으로 하여 안보이게 함
title.opacity = 0;
// FadeIn 액션 생성 (1초동안 선명해짐)
id action = [FadeIn actionWithDuration:1.0f];
// title에 액션 추가
[title runAction: action];
title.opacity = 0;
// FadeIn 액션 생성 (1초동안 선명해짐)
id action = [FadeIn actionWithDuration:1.0f];
// title에 액션 추가
[title runAction: action];
touch Me 인 이미지 Sprite 는 Blink 효과로 계속 깜빡이게 하여 구현
// Blink 액션 추가 ( 999초동안 999번 깜빡임)
id action1 = [Blink actionWithDuration:999 blinks:999];
// touchme 에 액션 추가
[touchme runAction: action1];
id action1 = [Blink actionWithDuration:999 blinks:999];
// touchme 에 액션 추가
[touchme runAction: action1];

화면전환
위의 touchme 클릭시 화면전환을 실행
화면전환시 scene 를 새로 생성하여
Director 의 sharedDirector 에 replaceScene 으로 새로 생성한 scene으로 화면을 전환
touchme 클릭시 callback 함수
// 새로운 Scene 생성
Scene *s = [Scene node];
// 생성한 Scene에 mainMenu를 add
[s addChild: [mainMenu node]];
// 메뉴가 삽입된 Scene로 화면을 replace
[[Director sharedDirector] replaceScene: s];
Scene *s = [Scene node];
// 생성한 Scene에 mainMenu를 add
[s addChild: [mainMenu node]];
// 메뉴가 삽입된 Scene로 화면을 replace
[[Director sharedDirector] replaceScene: s];
'공부 > 0x06 MOBLIE' 카테고리의 다른 글
| 안드로이드 개발환경 구축 (0) | 2010/05/16 |
|---|---|
| [MOAi] cocos2d 음악재생하기 (0) | 2009/10/16 |
| [MOAi] cocos2d 에니메이션 효과 (0) | 2009/10/16 |
| [MOAi] cocos2d 이미지 메뉴 만들기 (0) | 2009/10/16 |
| [MOAi] cocos2d 메뉴만들기 (0) | 2009/10/16 |