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

布置场景:

  众所周知,植物大战僵尸非常好玩,所以我们来制作一款类似的,名字就叫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,给它一个脚本

内容如下:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class LevelLoader : MonoBehaviour
{
    int currentSceneIndex;
    [SerializeField] int loadDelay = 3;
    private void Start()
    {
        currentSceneIndex = SceneManager.GetActiveScene().buildIndex;
        if (currentSceneIndex == 0)
        {
            StartCoroutine(WaitForTime());
        }
    }
    IEnumerator WaitForTime()
    {
        yield return new WaitForSeconds(loadDelay); //使用协成延迟调用场景
        SceneManager.LoadScene(currentSceneIndex + 1);
    }
    public void LoadNextScene()
    {
        SceneManager.LoadScene(currentSceneIndex + 1);
    }
}

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

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

 

然后放在bulid setting中的Scene in bulid


游戏效果:

 过了三秒后自动切换场景

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值