我想在我的屏幕中随机生成气泡.当气泡在一个地方产生时,其他气泡不能在其半径1区域附近产生.表示气泡不会与任何其他气泡碰撞或触发.
我该怎么做 ?
public void GenerateBubble ()
{
newBubbleXPos = Random.Range (-7, 7);
newBubbleYPos = Random.Range (-3, 3);
bubbleClone = (GameObject)Instantiate (bubblePrefab, new Vector3 (newBubbleXPos, newBubbleYPos, 0), Quaternion.identity);
UIManager.instance.ChangeBubbleSprite (bubbleClone);
bubbleList.Add (bubbleClone);
if (bubblePosList.Contains (bubbleClone.transform.position)) {
bubbleClone.transform.position=new Vector3(Random.Range (-7,7),Random.Range (-3,3),0);
}
bubblePosList.Add (bubbleClone.transform.position);
bubbleClone.transform.parent = UIManager.instance.CurrentLevel.transform;
GLOBALS.bubbleCounter++;
}
Run Code Online (Sandbox Code Playgroud)
在我的代码中,每个气泡都生成在不同的位置,但它可以与其他气泡碰撞,我想生成新的气泡不同的位置,也不会碰撞.我的泡泡对手的半径是1.
当两个协程正在运行时,如何停止第一个协程?
GLOBALS.stableTime = 5;
IEnumerator StableWaittingTime ()
{
yield return new WaitForSeconds (1f);
if (GLOBALS.stableTime == 0) {
GameManager.instance.LevelFaildMethod ();
} else {
GameManager.instance.stableWaittingTime.text = GLOBALS.stableTime.ToString ();
GLOBALS.stableTime--;
StartCoroutine ("StableWaittingTime");
}
}
Run Code Online (Sandbox Code Playgroud) 如何统一进行屏幕录像?我想在跑步游戏中记录屏幕(游戏性)。那应该是play / stop,replay,将录制内容从设备本地保存,从我的设备打开/加载(我们已经录制了)。
在我的游戏中,一台可以捕获本地相机的相机和一台3D模型。
我希望将两者都记录下来,并在需要时使用我的功能。
先感谢您。
我可以在后台运行计时器吗?当我最小化游戏然后我的计时器应该是工作继续我可以吗?
我试过Application.runInBackground=true;但它无法正常工作.
public class Counter : MonoBehaviour
{
public Text counterText;
private int counterValue;
// Use this for initialization
void Start ()
{
Application.runInBackground=true;
StartCoroutine ("StartCounter");
}
IEnumerator StartCounter ()
{
yield return new WaitForSeconds (1f);
counterText.text = "Counter : " + counterValue.ToString ();
counterValue++;
StartCoroutine ("StartCounter");
}
}
Run Code Online (Sandbox Code Playgroud)