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

43 lines
963 B
C#
Raw Normal View History

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;
public class MoveBg : MonoBehaviour
{
public static MoveBg instance;
public RectTransform rectTransform;
2024-12-05 15:48:55 +08:00
private float moveX = 1372;
2024-12-05 15:48:55 +08:00
public bool isMove;
//public float orPosX;
// Start is called before the first frame update
void Start()
{
2024-12-05 15:48:55 +08:00
//StartMove();
//orPosX = transform.position.x;
instance = this;
}
public void StartMove()//<2F><>ʼ<EFBFBD>ƶ<EFBFBD>
{
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);
2024-12-05 15:48:55 +08:00
isMove = true;
}
public void ReturnPos()//<2F><>λ
{
2024-12-05 15:48:55 +08:00
if (isMove)
{
rectTransform.DOAnchorPosX(686, 2).SetEase(Ease.Linear);
2024-12-05 15:48:55 +08:00
isMove = false;
}
}
}