본문 바로가기

Cocos2d

Cocos2d Android : 4장 . Cocos2d 액션 정리

반응형

1. CCMoveTo actionTo = CCMoveTo.action(1  , CGPoint.ccp(80,80)); // Moveto 액션 (설정한 절대 좌표까지 이동)
CCMoveBy actionBy = CCMoveBy.action(2 , CGPoint.ccp(80,80));  //MoveBy 액션 (설정한 좌표값 만큼 이동)
2. CCJumpTo actionJumpTo  = CCJumpTo.action(3 , CGPoint.ccp(x,y), jump_height , jump_count);  //JumpTo 액션 (설정한 절대좌표까지  점프)
CCJumpBy actionJumpBy  = CCJumpBy.action(4 , CGPoint.ccp(x,y), jump_height , jump_count);   //JumpBy 액션(설정한 값만큼 점프)
3. CCBezierConfig bezier = new CCBezierConfig();  //BezierConfig(포인트 값에 따라 이동)
bezier.controlPoint_1 = CGPoint.ccp(200, 150);
bezier.controlPoint_2 = CGPoint.ccp(300, 150);
bezier.endPosition = CGPoint.ccp(400,100);

4. CCPlace actionPlace = CCPlace.action(5,  CGPoint.ccp(x,y));   //Place 액션 (설정한 좌표에 배치?)
5. CCScaleBy actionScaleBy = CCScaleBy.action(2, x); //ScaleBy ( x 비율까지 커진다 ,1보다 작은 값을 입력하면 작아짐)
CCScaleBy actionScaleBy2 = actionScaleBy.action(2, 0.25f, 4.5f);  //타원 ScaleBy 액션 
CCScaleBy actionByBack = actionScaleBy.reverse();   // 작아지는 ScaleBy 액션
bubble.setScale(2);
CCScaleBy actionScaleBy = CCScaleBy.action(2, 2);  //ScaleBy (현재 크기를 기준으로 커지거나 작아짐)
CCScaleTo actionScaleTo  = CCScaleTo.action(2, 2);  //ScaleTo( 절대적인 크기많큼 커지거나 작아짐)  
6. CCRotateTo actionsRotateTo = CCRotateTo.action(2,x);  //RotateTo(x 각도 까지만 회전 , 가장 회전거리가 짧은 방향으로 회전)
      CCRotateBy actionsRotateBy = CCRotateBy.action(2,-y);  //RotateBy(y 각도만큼씩 더해서 회전  , 양수값은 시계방향 음수값은 시계반대방향으로 회전)
7. CCShow actionShow = CCShow.action();   //Show(액션을 보여준다)
CCHide actionsHide = CCHide.action();  //Hide(액션을 숨겨준다)
CCBlink actionBlink = CCBlink.action(2, x); //Blink (x번 만큼 깜빡여준다)
CCToggleVisibility actionToggle = CCToggleVisibility.action(); //ToggleVisibility(이벤트 마다 액션을 보여주고 숨겨주는것을 반복한다) 
8. CCFadeIn actionFadeIn = CCFadeIn.action(x); //FadeIn(x는 시간 x초 동안 서서히 나타나게 해준다)
CCFadeOut actionFadeOut = CCFadeOut.action(10); //FadeOut()
CCFadeTo actionFadeTo = CCFadeTo.action(x,10); //FadeTo( x  초 동안 서서히 사라지게 해주는 효과)
9. CCTintTo actionTintTo = CCTintTo.action(2, ccColor3B.ccc3(255, 0, 255)); // actionTintTo(절대적으로 rgb 맞는 값으로 농도변경)
CCTintBy actionTintBy = CCTintBy.action(2, ccColor3B.ccc3(255, 0, 255)); // actionTintBy(현재값에서 rgb 추가되어 농도변경)
10. CCTexture2D t2d = CCTextureCache.sharedTextureCache().addImage("atlas.png");  //CCAnimation (프레임을 만들어 애니매이션 프레임에 넣어준 후 스프라이트에 애드시켜준다)
CCSpriteFrame frame1 = CCSpriteFrame.frame(t2d,CGRect.make(0,0,120,118),CGPoint.ccp(0,0));
CCSpriteFrame frame2 = CCSpriteFrame.frame(t2d,CGRect.make(120,0,118,118),CGPoint.ccp(0,0));
CCSpriteFrame frame3 = CCSpriteFrame.frame(t2d,CGRect.make(0,118,116,118),CGPoint.ccp(0,0));
CCSprite temp = CCSprite.sprite(frame1);
temp.setPosition(500, 100);
this.addChild(temp,4);
ArrayList<CCSpriteFrame> animFrames = new ArrayList<CCSpriteFrame>();
animFrames.add(frame1);
animFrames.add(frame2);
animFrames.add(frame3);
CCAnimation animation = CCAnimation.animation("run", 0.2f,animFrames);  //run은 애니메이션 이름
temp.addAnimation(animation);
temp.runAction(CCRepeatForever.action(CCAnimate.action(animation,false)));
11. CCAction action = CCSpawn.actions(CCJumpBy.action(2, CGPoint.ccp(300,0), 50, 4), CCRotateBy.action(2, 720) ); // 동시액션, 실행 기간은 가장 긴 서브액션의 기간
CCAction action1 = CCSequence.actions(CCJumpBy.action(2, CGPoint.ccp(300,0), 50, 4), CCRotateBy.action(2, 720) ); //순차 액션 
CCAction action2 = CCRepeat.action(CCJumpBy.action(2, CGPoint.ccp(300,0), 50, 4), x); // x 숫자만큼 반복 액션
CCAction action3 = CCRepeatForever.action(CCJumpBy.action(2, CGPoint.ccp(300,0), 50, 4)); //무한 반복, sequence 내부에 사용 불가
12.    action.setTag(kTagAction1);
         CCSpeed action1 = (CCSpeed)temp.getAction(kTagAction1);
         action1.setSpeed(ccMacros.CCRANDOM_0_1() * 2);   //Speed(액션의 스피드 설정)
  
13.  CCMoveBy move = CCMoveBy.action(1, CGPoint.ccp(150,0));
    CCSequence action = CCSequence.actions(move, CCDelayTime.action(2), move);  //DelayTime( 액션의 대기시간 설정)

14.  CCSequence action = CCSequence.actions(
CCMoveBy.action(2, CGPoint.ccp(200,0)),
CCCallFunc.action(this, "you_win")
);                                         


 15.  CCOrbitCamera orbit1 = CCOrbitCamera.action(2, 1, 0, 0, 180, 0, 0); 
// OrbitCamera(비트맵을 2차원으로 회전 시켜준다)
// CCOrbitCamera.action(duration,radius,deltaRadiusr,angleZ,deltaAngleZ,angleX,deltaAngleX)


반응형