Unity做一个魔方
最近项目周期变得平稳,不再像之前那么忙了,所以抽空写了个魔方小游戏,在这里跟大家分享。
游戏原理并不复杂,在场景中,我们放了27个Cube,和6个面的触发器,根据触发器的Enter检测和Exit检测,确定对应面的子物体,使得触发器底下的9个Cube能同时转动,同时,再设置X,Y,Z三个轴向的整体转动,子物体是固定的27个Cube。
有了思路以后,我们来做场景,做完场景以后,画面大概是这样:
在FrontContent及以下5个物体中,我们要挂靠BoxCollider,和Rigibody组件,如图:
接下来,我们来写脚本,因为总体逻辑并不复杂,所以主逻辑只写了了一个GameController脚本,另外还有6个触发器脚本,以下是代码:
GameController.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;public class GameController : MonoBehaviour {public static GameController Instance;public enum Axis {//旋转轴X = 1,Y = 2,Z = 3}public enum RotateModel {//旋转模式Forward = 90,Back = -90}public enum Direction {//旋转方位First = -90,Second = -180,Third = 90,Fourth = 0}private Direction cubeDirF;//F面转向private Direction cubeDirB;//B面转向private Direction cubeDirU;//U面转向private Direction cubeDirD;//D面转向private Direction cubeDirL;//L面转向private Direction cubeDirR;//R面转向private Direction cubeDirWholeX;//整体转向private Direction cubeDirWholeY;private Direction cubeDirWholeZ;private const float rotateSpeed = 150f;//旋转速度private Quaternion targetRotationF;//旋转角度private Quaternion targetRotationB;private Quaternion targetRotationU;private Quaternion targetRotationD;private Quaternion targetRotationL;private Quaternion targetRotationR;private Quaternion targetRotationWholeX;private Quaternion targetRotationWholeY;private Quaternion targetRotationWholeZ;private int targetFZ = 0;//旋转轴度数private int targetBZ = 0;private int targetUY = 0;private int targetDY = 0;private int targetLX = 0;private int targetRX = 0;private int targetWholeX = 0;private int targetWholeY = 0;private int targetWholeZ = 0;public Button FButton;public Button FAntiButton;public Button BButton;public Button BAntiButton;public Button UButton;public Button UAntiButton;public Button DButton;public Button DAntiButton;public Button LButton;public Button LAntiButton;public Button RButton;public Button RAntiButton;public Button XButton;public Button XAntiButton;public Button YButton;public Button YAntiButton;public Button ZButton;public Button ZAntiButton;public GameObject FrontContent;//旋转父物体public GameObject BackContent;public GameObject UpContent;public GameObject DownContent;public GameObject LeftContent;public GameObject RightContent;public GameObject WholeXContent;public GameObject WholeYContent;public GameObject WholeZContent;private GameObject prevContent;//上一个转动的模块public List<GameObject> FrontObjList;//旋转面方块集合public List<GameObject> BackObjList;public List<GameObject> UpObjList;public List<GameObject> DownObjList;public List<GameObject> LeftObjList;public List<GameObject> RightObjList;public List<GameObject> WholeObjList; private bool isFrontClockwise = false;//旋转判断条件private bool isFrontAntiClockwise = false;private bool isBackClockwise = false;private bool isBackAntiClockwise = false;private bool isUpClockwise = false;private bool isUpAntiClockwise = false;private bool isDownClockwise = false;private bool isDownAntiClockwise = false;private bool isLeftClockwise = false;private bool isLeftAntiClockwise = false;private bool isRightClockwise = false;private bool isRightAntiClockwise = false;private bool isXClockwise = false;private bool isXAntiClockwise = false;private bool isYClockwise = false;private bool isYAntiClockwise = false;private bool isZClockwise = false;private bool isZAntiClockwise = false;private bool isPlaying = false;//正在旋转void Awake(){Instance = this;}void Start () {FButton.onClick.AddListener(OnClickFBtn);FAntiButton.onClick.AddListener(OnClickFAntiBtn);BButton.onClick.AddListener(OnClickBBtn);BAntiButton.onClick.AddListener(OnClickBAntiBtn);UButton.onClick.AddListener(OnClickUBtn);UAntiButton.onClick.AddListener(OnClickUAntiBtn);DButton.onClick.AddListener(OnClickDBtn);DAntiButton.onClick.AddListener(OnClickDAntiBtn);LButton.onClick.AddListener(OnClickLBtn);LAntiButton.onClick.AddListener(OnClickLAntiBtn);RButton.onClick.AddListener(OnClickRBtn);RAntiButton.onClick.AddListener(OnClickRAntiBtn);XButton.onClick.AddListener(OnClickXBtn);XAntiButton.onClick.AddListener(OnClickXAntiBtn);YButton.onClick.AddListener(OnClickYBtn);YAntiButton.onClick.AddListener(OnClickYAntiBtn);ZButton.onClick.AddListener(OnClickZBtn);ZAntiButton.onClick.AddListener(OnClickZAntiBtn);}void Update () {UpdateFrontClockwise();UpdateFrontAntiClockwise();UpdateBackClockwise();UpdateBackAntiClosewise();UpdateUpClockwise();UpdateUpAntiClockwise();UpdateDownClockwise();UpdateDownAntiClockwise();UpdateLeftClockwise();UpdateLeftAntiClockwise();UpdateRightClockwise();UpdateRightAntiClockwise();UpdateXAxisClockwise();UpdateXAxisAntiClockwise();UpdateYAxisClockwise();UpdateYAxisAntiClockwise();UpdateZAxisClockwise();UpdateZAxisAntiClockwise();}public void OnClickFBtn()//点击F按钮{ClickBtnEvent(RotateModel.Back, Axis.Z, ref FrontContent, ref FrontObjList, ref targetFZ, ref cubeDirF, ref targetRotationF, ref isFrontClockwise);}public void OnClickFAntiBtn()//点击F'按钮{ClickBtnEvent(RotateModel.Forward, Axis.Z, ref FrontContent, ref FrontObjList, ref targetFZ, ref cubeDirF, ref targetRotationF, ref isFrontAntiClockwise);}private void UpdateFrontClockwise()//F面正向旋转{UpdateRotateZEvent(Vector3.back, cubeDirF, targetRotationF, RotateModel.Back, ref FrontContent, ref isFrontClockwise, ref isFrontAntiClockwise);}private void UpdateFrontAntiClockwise()//F面反向旋转{UpdateRotateZEvent(Vector3.forward, cubeDirF, targetRotationF, RotateModel.Forward, ref FrontContent, ref isFrontAntiClockwise, ref isFrontClockwise);}public void OnClickBBtn()//点击B按钮{ClickBtnEvent(RotateModel.Forward, Axis.Z, ref BackContent, ref BackObjList,ref targetBZ, ref cubeDirB, ref targetRotationB, ref isBackClockwise);}public void OnClickBAntiBtn()//点击B'按钮{ClickBtnEvent(RotateModel.Back, Axis.Z, ref BackContent, ref BackObjList, ref targetBZ, ref cubeDirB, ref targetRotationB, ref isBackAntiClockwise);}public void UpdateBackClockwise()//B面正向旋转{UpdateRotateZEvent(Vector3.forward, cubeDirB, targetRotationB, RotateModel.Forward, ref BackContent,ref isBackClockwise,ref isBackAntiClockwise);}public void UpdateBackAntiClosewise()//B面反向旋转{UpdateRotateZEvent(Vector3.back, cubeDirB, targetRotationB, RotateModel.Back, ref BackContent, ref isBackAntiClockwise, ref isBackClockwise);}public void OnClickUBtn()//点击U按钮{ClickBtnEvent(RotateModel.Forward, Axis.Y, ref UpContent, ref UpObjList, ref targetUY, ref cubeDirU, ref targetRotationU, ref isUpClockwise);}public void OnClickUAntiBtn()//点击U'按钮{ClickBtnEvent(RotateModel.Back, Axis.Y, ref UpContent, ref UpObjList, ref targetUY, ref cubeDirU, ref targetRotationU, ref isUpAntiClockwise);}public void UpdateUpClockwise()//U面正向旋转{UpdateRotateYEvent(Vector3.up, cubeDirU, targetRotationU, RotateModel.Forward, ref UpContent, ref isUpClockwise, ref isUpAntiClockwise);}public void UpdateUpAntiClockwise()//U面反向旋转{UpdateRotateYEvent(Vector3.down, cubeDirU, targetRotationU, RotateModel.Back, ref UpContent, ref isUpAntiClockwise, ref isUpClockwise);}public void OnClickDBtn()//点击D按钮{ClickBtnEvent(RotateModel.Back, Axis.Y, ref DownContent, ref DownObjList, ref targetDY, ref cubeDirD, ref targetRotationD, ref isDownClockwise);}public void OnClickDAntiBtn()//点击D'按钮{ClickBtnEvent(RotateModel.Forward, Axis.Y, ref DownContent, ref DownObjList, ref targetDY, ref cubeDirD, ref targetRotationD, ref isDownAntiClockwise);}public void UpdateDownClockwise()//D面正向旋转{UpdateRotateYEvent(Vector3.down, cubeDirD, targetRotationD, RotateModel.Back, ref DownContent, ref isDownClockwise, ref isDownAntiClockwise);}public void UpdateDownAntiClockwise()//D面反向旋转{UpdateRotateYEvent(Vector3.up, cubeDirD, targetRotationD, RotateModel.Forward, ref DownContent, ref isDownAntiClockwise, ref isDownClockwise);}public void OnClickLBtn()//点击L按钮{ClickBtnEvent(RotateModel.Back, Axis.X, ref LeftContent, ref LeftObjList, ref targetLX, ref cubeDirL, ref targetRotationL, ref isLeftClockwise);}public void OnClickLAntiBtn()//点击L'按钮{ClickBtnEvent(RotateModel.Forward, Axis.X, ref LeftContent, ref LeftObjList, ref targetLX, ref cubeDirL, ref targetRotationL, ref isLeftAntiClockwise);}public void UpdateLeftClockwise()//L面正向旋转{UpdateRotateXEvent(Vector3.left, cubeDirL, targetRotationL, RotateModel.Back, ref LeftContent, ref isLeftClockwise, ref isLeftAntiClockwise);}public void UpdateLeftAntiClockwise()//L面反向旋转{UpdateRotateXEvent(Vector3.right, cubeDirL, targetRotationL, RotateModel.Forward, ref LeftContent, ref isLeftAntiClockwise, ref isLeftClockwise);}public void OnClickRBtn()//点击R按钮{ClickBtnEvent(RotateModel.Forward, Axis.X, ref RightContent, ref RightObjList, ref targetRX, ref cubeDirR, ref targetRotationR, ref isRightClockwise);}public void OnClickRAntiBtn()//点击R'按钮{ClickBtnEvent(RotateModel.Back, Axis.X, ref RightContent, ref RightObjList, ref targetRX, ref cubeDirR, ref targetRotationR, ref isRightAntiClockwise);}public void UpdateRightClockwise()//R面正向旋转{UpdateRotateXEvent(Vector3.right, cubeDirR, targetRotationR, RotateModel.Forward, ref RightContent, ref isRightClockwise, ref isRightAntiClockwise);}public void UpdateRightAntiClockwise()//R面反向旋转{UpdateRotateXEvent(Vector3.left, cubeDirR, targetRotationR, RotateModel.Back, ref RightContent, ref isRightAntiClockwise, ref isRightClockwise);}public void OnClickXBtn()//点击X按钮{ClickBtnEvent(RotateModel.Forward, Axis.X, ref WholeXContent, ref WholeObjList, ref targetWholeX, ref cubeDirWholeX, ref targetRotationWholeX, ref isXClockwise);}public void OnClickXAntiBtn()//点击X'按钮{ClickBtnEvent(RotateModel.Back, Axis.X, ref WholeXContent, ref WholeObjList, ref targetWholeX, ref cubeDirWholeX, ref targetRotationWholeX, ref isXAntiClockwise);}public void UpdateXAxisClockwise()//X轴正向旋转{UpdateRotateXEvent(Vector3.right, cubeDirWholeX, targetRotationWholeX, RotateModel.Forward, ref WholeXContent, ref isXClockwise, ref isXAntiClockwise);}public void UpdateXAxisAntiClockwise()//X轴反向旋转{UpdateRotateXEvent(Vector3.left, cubeDirWholeX, targetRotationWholeX, RotateModel.Back, ref WholeXContent, ref isXAntiClockwise, ref isXClockwise);}public void OnClickYBtn()//点击Y按钮{ClickBtnEvent(RotateModel.Forward, Axis.Y, ref WholeYContent, ref WholeObjList, ref targetWholeY, ref cubeDirWholeY, ref targetRotationWholeY, ref isYClockwise);}public void OnClickYAntiBtn()//点击Y'按钮{ClickBtnEvent(RotateModel.Back, Axis.Y, ref WholeYContent, ref WholeObjList, ref targetWholeY, ref cubeDirWholeY, ref targetRotationWholeY, ref isYAntiClockwise);}public void UpdateYAxisClockwise()//Y轴正向旋转{UpdateRotateYEvent(Vector3.up, cubeDirWholeY, targetRotationWholeY, RotateModel.Forward, ref WholeYContent, ref isYClockwise, ref isYAntiClockwise);}public void UpdateYAxisAntiClockwise()//Y轴反向旋转{UpdateRotateYEvent(Vector3.down, cubeDirWholeY, targetRotationWholeY, RotateModel.Back, ref WholeYContent, ref isYAntiClockwise, ref isYClockwise);}public void OnClickZBtn()//点击Z按钮{ClickBtnEvent(RotateModel.Forward, Axis.Z, ref WholeZContent, ref WholeObjList, ref targetWholeZ, ref cubeDirWholeZ, ref targetRotationWholeZ, ref isZClockwise);}public void OnClickZAntiBtn()//点击Z'按钮{ClickBtnEvent(RotateModel.Back, Axis.Z, ref WholeZContent, ref WholeObjList, ref targetWholeZ, ref cubeDirWholeZ, ref targetRotationWholeZ, ref isZAntiClockwise);}public void UpdateZAxisClockwise()//Z轴正向旋转{UpdateRotateZEvent(Vector3.forward, cubeDirWholeZ, targetRotationWholeZ, RotateModel.Forward, ref WholeZContent, ref isZClockwise, ref isZAntiClockwise);}public void UpdateZAxisAntiClockwise()//Z轴反向旋转{UpdateRotateZEvent(Vector3.back, cubeDirWholeZ, targetRotationWholeZ, RotateModel.Back, ref WholeZContent, ref isZAntiClockwise, ref isZClockwise);}//封装点击事件public void ClickBtnEvent(RotateModel model, Axis axis, ref GameObject nowContent,ref List<GameObject> objList,ref int targetDegree,ref Direction cubeDir,ref Quaternion targetRotation,ref bool isRotateStart){if (isPlaying)return;foreach (GameObject cubeObj in objList){cubeObj.transform.SetParent(nowContent.transform);}targetDegree += (int)model;int index = targetDegree % 360;if (index == -270)index = 90;if (index == 270)index = -90;if (index == 180)index = -180;//Debug.Log("Dir:" + cubeDir);cubeDir = (Direction)index;switch (axis){case Axis.X:targetRotation = Quaternion.Euler((float)cubeDir, 0, 0);break;case Axis.Y:targetRotation = Quaternion.Euler(0, (float)cubeDir, 0);break;case Axis.Z:targetRotation = Quaternion.Euler(0, 0, (float)cubeDir);break;default:break;}if (nowContent.GetComponent<Rigidbody>() != null)Destroy(nowContent.GetComponent<Rigidbody>());isRotateStart = true;prevContent = nowContent;}//魔方旋转(x轴)public void UpdateRotateXEvent(Vector3 rotateDir, Direction cubeDir, Quaternion targetRotation, RotateModel model, ref GameObject nowContent, ref bool isRotateStart, ref bool isRotateAntiStart){if (isRotateStart){isPlaying = isRotateStart;nowContent.transform.Rotate(rotateDir * Time.deltaTime * rotateSpeed);//Debug.Log("X:" + nowContent.transform.localRotation.x);//Debug.Log("X2:" + targetRotation.x);bool isBreak = false;switch (model){case RotateModel.Forward:{switch (cubeDir){case Direction.First:{if (nowContent.transform.localRotation.x >= targetRotation.x){isBreak = true;}}break;case Direction.Second:{if (nowContent.transform.localRotation.x >= -targetRotation.x - 0.0001f){isBreak = true;}}break;case Direction.Third:{if (nowContent.transform.localRotation.x >= targetRotation.x){isBreak = true;}}break;case Direction.Fourth:{if (nowContent.transform.localRotation.x >= targetRotation.x){isBreak = true;}}break;}}break;case RotateModel.Back:{switch (cubeDir){case Direction.First:{if (nowContent.transform.localRotation.x <= targetRotation.x){isBreak = true;}}break;case Direction.Second:{if (nowContent.transform.localRotation.x <= targetRotation.x + 0.0001f){isBreak = true;}}break;case Direction.Third:{if (nowContent.transform.localRotation.x >= -targetRotation.x){isBreak = true;}}break;case Direction.Fourth:{if (nowContent.transform.localRotation.x <= targetRotation.x){isBreak = true;}}break;}}break;}if (isBreak){nowContent.transform.localRotation = targetRotation;isRotateStart = false;isRotateAntiStart = false;Rigidbody rigidbody = nowContent.AddComponent<Rigidbody>();rigidbody.useGravity = false;isPlaying = isRotateStart;}}}//魔方旋转(y轴)public void UpdateRotateYEvent(Vector3 rotateDir, Direction cubeDir, Quaternion targetRotation, RotateModel model, ref GameObject nowContent, ref bool isRotateStart, ref bool isRotateAntiStart){if (isRotateStart){isPlaying = isRotateStart;nowContent.transform.Rotate(rotateDir * Time.deltaTime * rotateSpeed);bool isBreak = false;switch (model){case RotateModel.Forward:{switch (cubeDir){case Direction.First:{if (nowContent.transform.localRotation.y >= targetRotation.y){isBreak = true;}}break;case Direction.Second:{if (nowContent.transform.localRotation.y >= -targetRotation.y - 0.0001f){isBreak = true;}}break;case Direction.Third:{if (nowContent.transform.localRotation.y >= targetRotation.y){isBreak = true;}}break;case Direction.Fourth:{if (nowContent.transform.localRotation.y >= targetRotation.y){isBreak = true;}}break;}}break;case RotateModel.Back:{switch (cubeDir){case Direction.First:{if (nowContent.transform.localRotation.y <= targetRotation.y){isBreak = true;}}break;case Direction.Second:{if (nowContent.transform.localRotation.y <= targetRotation.y + 0.0001f){isBreak = true;}}break;case Direction.Third:{if (nowContent.transform.localRotation.y >= -targetRotation.y){isBreak = true;}}break;case Direction.Fourth:{if (nowContent.transform.localRotation.y <= targetRotation.y){isBreak = true;}}break;}}break;}if (isBreak){nowContent.transform.localRotation = targetRotation;isRotateStart = false;isRotateAntiStart = false;Rigidbody rigidbody = nowContent.AddComponent<Rigidbody>();rigidbody.useGravity = false;isPlaying = isRotateStart;}}}//魔方旋转(z轴)public void UpdateRotateZEvent(Vector3 rotateDir, Direction cubeDir, Quaternion targetRotation,RotateModel model, ref GameObject nowContent, ref bool isRotateStart, ref bool isRotateAntiStart){if (isRotateStart){isPlaying = isRotateStart;nowContent.transform.Rotate(rotateDir * Time.deltaTime * rotateSpeed);bool isBreak = false;switch (model) {case RotateModel.Forward:{switch (cubeDir){case Direction.First:{if (nowContent.transform.localRotation.z >= targetRotation.z){isBreak = true;}}break;case Direction.Second:{if (nowContent.transform.localRotation.z >= -targetRotation.z - 0.0001f){isBreak = true;}}break;case Direction.Third:{if (nowContent.transform.localRotation.z >= targetRotation.z){isBreak = true;}}break;case Direction.Fourth:{if (nowContent.transform.localRotation.z >= targetRotation.z){isBreak = true;}}break;}}break;case RotateModel.Back:{switch (cubeDir){case Direction.First:{if (nowContent.transform.localRotation.z <= targetRotation.z){isBreak = true;}}break;case Direction.Second:{if (nowContent.transform.localRotation.z <= targetRotation.z + 0.0001f){isBreak = true;}}break;case Direction.Third:{if (nowContent.transform.localRotation.z >= -targetRotation.z){isBreak = true;}}break;case Direction.Fourth:{if (nowContent.transform.localRotation.z <= targetRotation.z){isBreak = true;}}break;}}break;}if (isBreak){nowContent.transform.localRotation = targetRotation;isRotateStart = false;isRotateAntiStart = false;Rigidbody rigidbody = nowContent.AddComponent<Rigidbody>();rigidbody.useGravity = false;isPlaying = isRotateStart;}}}
}
FrontContentTrigger.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;public class FrontContentTrigger : MonoBehaviour {private void OnTriggerEnter(Collider other){if (other.gameObject.tag == "Cube")if(!GameController.Instance.FrontObjList.Contains(other.gameObject))GameController.Instance.FrontObjList.Add(other.gameObject);}private void OnTriggerExit(Collider other){if (other.gameObject.tag == "Cube")if(GameController.Instance.FrontObjList.Contains(other.gameObject))GameController.Instance.FrontObjList.Remove(other.gameObject);}}
BackContentTrigger.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;public class BackContentTrigger : MonoBehaviour {private void OnTriggerEnter(Collider other){if (other.gameObject.tag == "Cube")if (!GameController.Instance.BackObjList.Contains(other.gameObject))GameController.Instance.BackObjList.Add(other.gameObject); }private void OnTriggerExit(Collider other){if (other.gameObject.tag == "Cube")if (GameController.Instance.BackObjList.Contains(other.gameObject))GameController.Instance.BackObjList.Remove(other.gameObject);}}
UpContentTrigger.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;public class UpContentTrigger : MonoBehaviour {private void OnTriggerEnter(Collider other){if (other.gameObject.tag == "Cube")if (!GameController.Instance.UpObjList.Contains(other.gameObject))GameController.Instance.UpObjList.Add(other.gameObject);}private void OnTriggerExit(Collider other){if (other.gameObject.tag == "Cube")if (GameController.Instance.UpObjList.Contains(other.gameObject))GameController.Instance.UpObjList.Remove(other.gameObject);}}
DownContentTrigger.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;public class DownContentTrigger : MonoBehaviour {private void OnTriggerEnter(Collider other){if (other.gameObject.tag == "Cube")if (!GameController.Instance.DownObjList.Contains(other.gameObject))GameController.Instance.DownObjList.Add(other.gameObject);}private void OnTriggerExit(Collider other){if (other.gameObject.tag == "Cube")if (GameController.Instance.DownObjList.Contains(other.gameObject))GameController.Instance.DownObjList.Remove(other.gameObject);}}
LeftContentTrigger.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;public class LeftContentTrigger : MonoBehaviour {private void OnTriggerEnter(Collider other){if (other.gameObject.tag == "Cube")if (!GameController.Instance.LeftObjList.Contains(other.gameObject))GameController.Instance.LeftObjList.Add(other.gameObject);}private void OnTriggerExit(Collider other){if (other.gameObject.tag == "Cube")if (GameController.Instance.LeftObjList.Contains(other.gameObject))GameController.Instance.LeftObjList.Remove(other.gameObject);}}
RightContentTrigger.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;public class RightContentTrigger : MonoBehaviour {private void OnTriggerEnter(Collider other){if (other.gameObject.tag == "Cube")if (!GameController.Instance.RightObjList.Contains(other.gameObject))GameController.Instance.RightObjList.Add(other.gameObject);}private void OnTriggerExit(Collider other){if (other.gameObject.tag == "Cube")if (GameController.Instance.RightObjList.Contains(other.gameObject))GameController.Instance.RightObjList.Remove(other.gameObject);}}
写完脚本以后,我们把GameController脚本挂到MainCamera上,然后吧场景中对应的游戏物体拖上去,如下图:
接着,把FrontContent到RightContent对应的触发器脚本挂上,同时,需要注意的是,要把27个Cube游戏物体的tag值,改成“Cube”。整个魔方的控制,就算完成了。
按上面的按钮可以整体转动魔方,按下面的按钮可以转动单独的某个魔方面。
以上。
Unity做一个魔方相关推荐
- [css] 使用css3做一个魔方旋转的效果
[css] 使用css3做一个魔方旋转的效果 总的来说,用了一些 3D 效果的样式,如 translate3d,rotate3d,perspective,transform-style: preser ...
- 零基础Unity做一个中秋诗词鉴赏网页,提前祝您中秋快乐!(DoTween动画 | WebGL视频 | 大文件上传GitHub)
零基础Unity做一个中秋诗词鉴赏网页,提前祝您中秋快乐! 前言 一,环境搭建 1.1 安装Unity 1.2 添加WebGl模块 二,开发项目 2.1 导入插件 2.2 项目搭建 2.3 逻辑处理 ...
- Unity做一个太阳系
Unity做一个太阳系(适合初学者学习) 步骤 1.新建Unity项目(我用的unity2019) 2.在assets中建script文件夹,material文件夹. 2.创造9个sphere物体:太 ...
- 用python-OpenCV做一个魔方墙找茬 (3D视眼训练)
前言 相信有些朋友接触过魔方墙找茬这类游戏,在两边对照的众多颜色块中找到其中一个不同的颜色块,有些人会用来训练3D视眼,那么就来做一个魔方墙找茬的程序吧. 本次采用OpenCV来制作,用到了基础库Nu ...
- 用Unity做一个小Demo入门Unity
文章目录 前言 个人介绍 一.准备工作 1. unity下载安装 2. 个人许可证激活 3. 素材下载 二.项目准备 1. 项目创建 2. 素材导入 三.开始项目 1. 将素材变为精灵 2. 将精灵放 ...
- html魔方转动效果,简单说 用CSS做一个魔方旋转的效果
说明 魔方大家应该是不会陌生的,这次我们来一起用CSS实现一个魔方旋转的特效,先来看看效果图! 解释 我们要做这样的效果,重点在于怎么把6张图片,摆放成魔方的样子,而把它们摆放成魔方的样子,重点在于用 ...
- 简单说 用CSS做一个魔方旋转的效果
说明 魔方大家应该是不会陌生的,这次我们来一起用CSS实现一个魔方旋转的特效,先来看看效果图! 解释 我们要做这样的效果,重点在于怎么把6张图片,摆放成魔方的样子,而把它们摆放成魔方的样子,重点在于用 ...
- unity做一个小游戏(适合零基础或者巩固加深unity中的工具类的用法)
今天跟着官方unity做了一个小游戏.巩固一下之前学习的unity的知识.注意unity的版本要在2018.3以上 大概游戏是这样子的如图:人物只能控制左右移动,空格发射饼干,动物从屏幕上方随机出现在 ...
- 使用Unity做一个艺术字系统
为了熟悉CaptureScreen方法,做一个艺术字系统. 首先声明一个公共变量toward,以便在书脚本Cature_Use中调用,然后给另一个变量delays赋予一个随机值,以便每个小球的运动显得 ...
最新文章
- P1203 [USACO1.1]坏掉的项链Broken Necklace
- DHCP Snooping的作用
- word下设置多个起始页面
- C# 学习笔记1 .NET平台,C#的重要概念
- 安装 pptpd 服务
- Java面试题一:字符串的字符分类器
- 卷积神经网络学习指南_卷积神经网络的直观指南
- 有了这三个神器工具集,应用开发想怎么玩就怎么玩
- qt connect函数_Qt Inside信号和槽之connect
- 2019 开源安全报告:开发者安全技能短板明显,热门项目成漏洞重灾区!
- 【直通BAT】剑指Offer 经典试题整理(5)
- java 抽奖算法_Java实现游戏抽奖算法
- PAYPAL使用虚拟信用卡验证的技巧
- 别折腾安全软件了 你的手机也许还不配被黑客破解
- jq插件jquery-barcode.js生成条形码
- 计算机的用户账户无法更改密码,windows不能更改密码怎么办【解决方法】
- 「读书笔记」余生,请多指教
- 看精神小伙是如何智斗骗子的
- 微信防封汇总,解决办法及数据分析
- python2 + django 导出 excel 功能 接口示例代码(做记录)