当前位置:   article > 正文

[Unity2D入门教程]简单制作仿植物大战僵尸游戏之①搭建场景_pvzunity素材

pvzunity素材

布置场景:

  众所周知,植物大战僵尸非常好玩,所以我们来制作一款类似的,名字就叫Glitch Garden。

  布置场景需要用到很多素材,这里我们在GitHub中找到一位老师的素材并把需要的导入到project面板中

GitHub - CompleteUnityDeveloper/07-Glitch-Garden: In this section we create a lane-based Tower Defense game modelled on the iconic Plants Vs Zombies game. We cover a lot of Unity's animation system, a resource management mechanic, specialised enemy types and more. This repo is part of our Complete Unity C# Developer 2D course (http://gdev.tv/cudgithub). (Ref: GL_CUD)icon-default.png?t=N7T8https://github.com/CompleteUnityDeveloper/07-Glitch-Garden我们找到需要作为开场和加载动画的图片,并创建好两个创建和各自的Canvas

顺便提一嘴,创建好保存各式文件的文件夹是至关重要的,这里我就创建了很多,如果不知道意思的话可以百度翻译查一下

 这是第一个场景Splash Scene

canvas设置要改成1920 * 1080 

 Screen Match Mode改成shrink,防止分辨率改变导致画面变形

上述是对齐方式。

接下来我们进入下一个场景 

 

 这两个Text都要改成向右对齐,也是为了适应分辨率的改变


编写脚本:

我们还要创建加载场景用的空对象Scene Loader,给它一个脚本

内容如下:

  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.SceneManagement;
  5. public class LevelLoader : MonoBehaviour
  6. {
  7. int currentSceneIndex;
  8. [SerializeField] int loadDelay = 3;
  9. private void Start()
  10. {
  11. currentSceneIndex = SceneManager.GetActiveScene().buildIndex;
  12. if (currentSceneIndex == 0)
  13. {
  14. StartCoroutine(WaitForTime());
  15. }
  16. }
  17. IEnumerator WaitForTime()
  18. {
  19. yield return new WaitForSeconds(loadDelay); //使用协成延迟调用场景
  20. SceneManager.LoadScene(currentSceneIndex + 1);
  21. }
  22. public void LoadNextScene()
  23. {
  24. SceneManager.LoadScene(currentSceneIndex + 1);
  25. }
  26. }

 然后再创建一个作为播放音乐的 Load Sound

然后把它们两个都做成prefab放在两个场景

 

然后放在bulid setting中的Scene in bulid


游戏效果:

 过了三秒后自动切换场景

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/IT小白/article/detail/770464
推荐阅读
相关标签
  

闽ICP备14008679号