_TheStrongestSnail/TheStrongestSnail/Assets/Scripts/RacingPanel/MoveBg.cs

43 lines
963 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;
public class MoveBg : MonoBehaviour
{
public static MoveBg instance;
public RectTransform rectTransform;
private float moveX = 1372;
public bool isMove;
//public float orPosX;
// Start is called before the first frame update
void Start()
{
//StartMove();
//orPosX = transform.position.x;
instance = this;
}
public void StartMove()//¿ªÊ¼Òƶ¯
{
int add = 0;
if (Screen.width<moveX)
{
add = 30;
}
float move = -(moveX * 2 + moveX - Screen.width - 686-add);
rectTransform.DOAnchorPosX(move,7).SetEase(Ease.Linear);
isMove = true;
}
public void ReturnPos()//¹éλ
{
if (isMove)
{
rectTransform.DOAnchorPosX(686, 2).SetEase(Ease.Linear);
isMove = false;
}
}
}