public GameObject ball;//指代小球物体 // Start is called before the first frame update voidStart() { }
// Update is called once per frame ///<summary> /// 判断是否开始游戏,若按下空格表示开始游戏,给小球一个初始力使其开始弹射 ///</summary> voidUpdate() { if (!isStart) { if (Input.GetKeyDown(KeyCode.Space))//按下空格键 { ball.GetComponent<Rigidbody2D>().AddForce(Vector2.up * force, ForceMode2D.Impulse);//给小球力 transform.DetachChildren();//使得板子的所有子物体脱离自己,这样当板子移动时它们不再跟随 }