赞
踩
public float minX = -500.0f;
public float maxX = 500.0f;
private bool movingRight = true;
void PingPang()
{
float step = 500f * Time.deltaTime;
if (movingRight)
{
rectTransform.anchoredPosition += new Vector2(step, 0);
if (rectTransform.anchoredPosition.x >= maxX)
{
rectTransform.anchoredPosition = new Vector2(maxX, rectTransform.anchoredPosition.y);
movingRight = false;
}
}
else
{
rectTransform.anchoredPosition -= new Vector2(step, 0);
if (rectTransform.anchoredPosition.x <= minX)
{
rectTransform.anchoredPosition = new Vector2(minX, rectTransform.anchoredPosition.y);
movingRight = true;
}
}
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。