'action'에 해당되는 글 2건

  1. 2014.01.09 [유니티3d][에셋] 유니티 필수 에셋 iTween 에 대해서 알아보자(Action!)
  2. 2014.01.08 [Action] cocos2d-x 액션 사용법

[유니티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

    [Action] cocos2d-x 액션 사용법

    |


    Actions



    Actions 클래스는 CCNode 를 상속받는 모든 객체에 명령을 부여합니다. 액션은  오브젝트의 위치, 회전, 크기 기타등등 값들을 수정합니다

    일정기간동안 수정하는 작업이면 -> CCIntervalAction actions 그렇지 않으면 -> CCInstantAction 입니다.

     예를들면 CCMoveBy는 일정기간동안 수정합니다. CCIntervalAction 액션입니다.

    액션의 사용 예:

    1// 스프라이트가 오른족으로  50 픽셀, 밑으로 10 픽셀 움직임 2초동안.
    2CCActionInterval*  actionBy = CCMoveBy::create(2, ccp(50,10));
    


    가속 관련된 액션들 (점점 빨라지거나 느려지는등)

    • CCEaseIn
    • CCEaseOut
    • CCEaseInOut
    • CCSpeed
      Etc. (See the ActionsEaseTest.cpp example for more info)

    CCActionManager를 사용하면 중간에 액션을 일시정지 하고 재시작 할수도있다.(해당객체의)

    1// Pause actions
    2CCDirector *director = CCDirector::sharedDirector();
    3m_pPausedTargets = director->getActionManager()->pauseAllRunningActions();
    4// resume actions
    5CCDirector *director = CCDirector::sharedDirector();
    6director->getActionManager()->resumeTargets(m_pPausedTargets);
    

    Basic Actions

    Basic actions are the ones that modify basic properties like:

    Position(위치수정관련)

    CCMoveBy
    CCMoveTo
    CCJumpBy
    CCJumpTo
    CCBezierBy
    CCBezierTo
    CCPlace

    Scale(크기수정관련)

    CCScaleBy
    CCScaleTo

    Rotation(회전)

    CCRotateBy
    CCRotateTo

    Visibility(보이는거)

    CCShow
    CCHide
    CCBlink
    CCToggleVisibility

    Opacity(알파값)

    CCFadeIn
    CCFadeOut
    CCFadeTo

    Color(색깔)

    CCTintBy
    CCTintTo

    Example:

    1CCSprite *sprite = CCSprite::create("Images/grossini.png");
    2sprite->setPosition(ccp(100, 100));
    3addChild(sprite);
    4
    5CCMoveBy* act1 = CCMoveBy::create(0.5, ccp(100, 0));
    6sprite->runAction(CCRepeat::create(act1, 1));
    

    The act1 will be a CCMoveBy action of duration 0.5, but with the position value of ccp(100,0).


     뒤에 By 붙는거와 To 붙는거 차이


    By는 현재 값 기준으로 변경 To는 그냥 그런거 상관없이 변경

    만약 현재 캐릭터 위치가 120 .30 이면

    만약 CCMoveBy::create(2, ccp(50,10));    //현재 캐릭터 위치 기준으로 50,10만큼 이동 -> 170,40

           CCMoveTo::create(2ccp(50,10));      //좌표값에 50, 10으로 이동 -> 50,10


    Trackback 0 And Comment 0
    prev | 1 | next