コード例 #1
0
    private int count;        //objects picked up

    // Use this for initialization
    void Start()
    {
        //Get and store a reference to the Rigidbody2D component so that we can access it.
        rb2d  = GetComponent <Rigidbody2D>();
        count = 0; //no pickups at PlayerStart

        //Initialze winText to a blank string since we haven't won yet at beginning.
        winText.text = "";

        countText.text = HelperClassTest.UpdateTextField("Count: ", count);
    }
コード例 #2
0
    //OnTriggerEnter2D is called whenever this object overlaps with a trigger collider.
    void OnTriggerEnter2D(Collider2D other)
    {
        //Check the provided Collider2D parameter other to see if it is tagged "PickUp", if it is...
        if (other.gameObject.CompareTag("PickUp"))
        {
            other.gameObject.SetActive(false);
            count += 1;
            //TODO: Can I group UI elements together, score being Count and a num value tied to actual score?
            countText.text = HelperClassTest.UpdateTextField("Count: ", count);

            if (count >= 2)
            {
                //... then set the text property of our winText object to "You win!"
                winText.text = "You win YEET!";
            }
        }
    }
コード例 #3
0
 void Update()
 {
     touchCountText.text = HelperClassTest.UpdateTextField("touchCount: ", Input.touchCount);
 }