第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

隨時(shí)間移動(dòng)游戲?qū)ο?/h1>

隨時(shí)間移動(dòng)游戲?qū)ο笪艺趶腟wift SpriteKit背景中學(xué)習(xí)UnityofSpriteKit,其中移動(dòng)一個(gè)精靈的x位置就像運(yùn)行一個(gè)動(dòng)作一樣直接,如下所示:let moveLeft = SKAction.moveToX(self.frame.width/5, duration: 1.0)let delayAction = SKAction.waitForDuration(1.0)let handSequence = SKAction. sequence([delayAction, moveLeft])sprite.runAction(handSequence)我想知道一種等效或類似的方法,可以在特定的時(shí)間內(nèi)(例如,第二次)將sprite移動(dòng)到一個(gè)特定的位置,并且在UPDATE函數(shù)中不需要調(diào)用這個(gè)延遲。
查看完整描述

3 回答

?
幕布斯7119047

TA貢獻(xiàn)1794條經(jīng)驗(yàn) 獲得超8個(gè)贊

gjttt 1的答案是接近的,但缺少重要的功能和使用WaitForSeconds()用于移動(dòng)游戲?qū)ο?/strong>是不能接受的。您應(yīng)該使用LerpCoroutineTime.deltaTime..你必須了解這些東西,才能從統(tǒng)一腳本中制作動(dòng)畫(huà)。

public GameObject objectectA;public GameObject objectectB;void Start(){
    StartCoroutine(moveToX(objectectA.transform, objectectB.transform.position, 1.0f));}bool isMoving = false;
    IEnumerator moveToX(Transform fromPosition, Vector3 toPosition, float duration){
    //Make sure there is only one instance of this function running
    if (isMoving)
    {
        yield break; ///exit if this is still running
    }
    isMoving = true;

    float counter = 0;

    //Get the current position of the object to be moved
    Vector3 startPos = fromPosition.position;

    while (counter < duration)
    {
        counter += Time.deltaTime;
        fromPosition.position = Vector3.Lerp(startPos, toPosition, counter / duration);
        yield return null;
    }

    isMoving = false;}

類似的問(wèn)題:SKAction.ScaleXto


查看完整回答
反對(duì) 回復(fù) 2019-07-02
?
慕萊塢森

TA貢獻(xiàn)1810條經(jīng)驗(yàn) 獲得超4個(gè)贊

git 1的答案是好的,但是如果您不想使用禮貌,還有另一個(gè)解決方案。

你可以用InvokeRepeating反復(fù)觸發(fā)一個(gè)函數(shù)。

float duration; //duration of movementfloat durationTime; //this will be the value used to check if Time.
time passed the current duration setvoid Start(){
    StartMovement();}void StartMovement(){
    InvokeRepeating("MovementFunction", Time.deltaTime, Time.deltaTime); //Time.deltaTime is the time passed between two frames
    durationTime = Time.time + duration; //This is how long the invoke will repeat}void MovementFunction(){
    if(durationTime > Time.time)
    {
        //Movement
    } 
    else 
    {
        CancelInvoke("MovementFunction"); //Stop the invoking of this function
        return;
    }}


查看完整回答
反對(duì) 回復(fù) 2019-07-02
  • 3 回答
  • 0 關(guān)注
  • 441 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)