Candycrush Candy Saga mini-game Summary

Source: Internet
Author: User

1. Unity comes with a trigger event

Every collider object in unity has events such as onmousedown, onmouseover, and so on, which are present in Monobehaviour scripts, and Monobehaviour is the base class for each script. These events are known according to the manual (the mouse calls onmousedown when clicked on Guielement (GUI Element) or collider (collision body), and is a trigger!

2. Destroying objects

In order not to consume system resources or to avoid a memory leak, when we destroy an object, we have to deal with what this object refers to!

The script introduced by this object script is null, destory the object introduced by this object script, and then destroys itself!

3, Vibration screen effect

Create a new script CameraShake.cs

usingUnityengine;usingSystem.Collections; Public classcamerashake:monobehaviour{ Public Static BOOLStartshake =false;  Public Static floatseconds =0.0f;  Public Static BOOLstarted =false;  Public Static floatQuake =0.2f; PrivateVector3 CamPOS;  Public BOOLis2d; voidStart () {CamPOS=transform.position; }    voidlateupdate () {if(startshake) {transform.position= Random.insideunitsphere *quake; if(is2d) Transform.position =NewVector3 (transform.position.x, TRANSFORM.POSITION.Y, campos.z); }        if(started) {Startcoroutine (Waitforsecond (seconds)); Started=false; }    }     Public Static voidShakefor (floatAfloatb) {seconds=A; Started=true; Quake=b; } IEnumerator Waitforsecond (floata) {CamPOS=transform.position; Startshake=true; yield return NewWaitforseconds (a); Startshake=false; Transform.position=CamPOS; }}

This script hangs on the camera and is called Where needed: Camerashake.shakefor (0.5f,0.1f)

Candycrush Candy Saga mini-game Summary

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.