Unity + win8.1 apps game demo, unitywin8.1

Source: Internet
Author: User

Unity + win8.1 apps game demo, unitywin8.1

Unity3d is used by many people... I was trying to write a 3d game .. .. It seems quite troublesome .. ..... Use unity to write a simple 2d game ..




(Adsw press ENTER or touch screen virtual joystick)


Development Environment unity4.5.1f3 vs2013 express win8.1

The implementation method is as follows:

1. Create your own tank Sprite

2. Create an enemy tank Prefab

3. Create a bullet Prefab

4. Add a virtual joystick

5. Collision Detection




Implementation

1. Control the code of your own tank

if (Input.GetKey (KeyCode.W)) {Rotate (0);} else  if (Input.GetKey (KeyCode.S)) {Rotate (180);} else if (Input.GetKey (KeyCode.A)) {Rotate (90);} else if (Input.GetKey (KeyCode.D)) {Rotate (270);}i++;if (i == 10) {i=0;if (Input.GetKey (KeyCode.Return)||rotateJoystick.tapCount > 0) {m.tag = "GOOD";Instantiate (m, transform.position, transform.rotation);}}


2. Code for controlling local tanks

if (step == 0){int i=Random.Range(0, 4);Rotate(angles[i]);step = Random.Range(0, 20) + 85;if(Random.Range(0,50)>40){m.tag="BAD";Instantiate(m, transform.position, transform.rotation);}}else{step--;}transform.Translate (Vector3.up*Time.deltaTime*4);


3. Control bullet Movement

Transform. Translate (Vector3.up * Time. deltaTime * 10 );


4. Standard Assets (Mobile). unityPackage

5. Collision Detection code

void OnTriggerEnter2D(Collider2D mCollider){if ((mCollider.gameObject.tag == "Enemy"&&gameObject.tag=="GOOD")||(mCollider.gameObject.tag == "Player"&&gameObject.tag=="BAD")){Destroy(mCollider.gameObject);Destroy(this.gameObject);if(gameObject.tag=="BAD"){PlayerPrefs.SetString("key","OVER");Application.LoadLevel(1);}}}




Code download: http://download.csdn.net/detail/xiaoxiao108/7674235


If you find anything unreasonable and need improvement, leave a message. Or you can contact me via 328452421@qq.com. Thank you very much.





Unity cannot be installed in win81.

Path cannot contain Chinese Characters

WIN81 unzip swsapps File

There is no such folder!

Pan.baidu.com/s/1l9uKZ

The folder is ready !!!



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.