using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class moon : MonoBehaviour{
    public bool dir;
    void Start(){
        
    }
    void Update(){
        if(dir){
            GetComponent<RectTransform>().anchoredPosition = new Vector2(GetComponent<RectTransform>().anchoredPosition.x + 100f * Time.deltaTime, GetComponent<RectTransform>().anchoredPosition.y + 120f * Time.deltaTime);
        }else{
            GetComponent<RectTransform>().anchoredPosition = new Vector2(GetComponent<RectTransform>().anchoredPosition.x + -100f * Time.deltaTime, GetComponent<RectTransform>().anchoredPosition.y + -120f * Time.deltaTime);
        }
        if(GetComponent<RectTransform>().anchoredPosition.x >= 154f){
            dir = false;
            transform.SetAsLastSibling();
        }
        if(GetComponent<RectTransform>().anchoredPosition.x <= -249.8985f){
            dir = true;
            transform.SetSiblingIndex(2);
        }
        
    }
}