👨💻个人主页:@元宇宙-秩沅
👨💻 hallo 欢迎 点赞👍 收藏⭐ 留言📝 加关注✅!
👨💻 本文由 秩沅 原创
👨💻 收录于专栏:unity创意
⭐正反相机实现的小创意⭐
🎶内容描述
-
此时相机是挂载到父对象身上的,也就是游戏物体身上,现在可以看到画面的两种形式的切换
-
当物体向右走时通过检视面板可以看出是场景的正面,当物体向左走时也就是反方向走是,可以看到相机的位置变成场景的背面
🎶想法实现
🧠可以变成左右场景切换的游戏,比如向前走时是天堂,而向后走就是地狱
🧠所以只能一直向前走 ---- 该类型的游戏
⭐相关文章⭐
⭐【2023unity游戏制作-mango的冒险】-开始画面API制作
⭐【unity游戏制作-mango的冒险】-场景搭建
⭐“狂飙”游戏制作—游戏分类图鉴(网易游学)
⭐本站最全-unity常用API大全(万字详解),不信你不收藏
你们的点赞👍 收藏⭐ 留言📝 关注✅是我持续创作,输出优质内容的最大动力!
//-------------------------------------
//—————————————————————————————————————
//项目: ______________
//功能: _______________
//创建者:秩沅
//___________________
//-------------------------------------
public class Play : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
PlayerMess boss = new PlayerMess(“孙悟空”, 18, 999, 666);
Equipment equipment1 = new Equipment(“001”, 1);
Equipment equipment2 = new Equipment(“002”, 3); ;
Equipment equipment3 = new Equipment(“003”, 4); ;
boss.AddStateToList(equipment1);
boss.AddStateToList(equipment2);
boss.AddStateToList(equipment3);
boss.Save("Boos1");
boss.Read();
boss.SaveEquip("Boss1");
boss.ReadEquip();
}
// Update is called once per frame
void Update()
{
}
}
///
/// 装备信息类
///
public class Equipment
{
private string id;
private int numb;
public string Id { get => id; }
public int Numb { get => numb; }
public Equipment(string v1, int v2)
{
this.id = v1;
this.numb = v2;
}
}
///
/// 玩家信息类
///
public class PlayerMess
{
private string name;
private int age;
private int atack;
private int defend;
private string NameFlag; //为实现多个对象存储的关键
public List equipMess; //存储装备类中的信息文章来源:https://www.toymoban.com/news/detail-435583.html
public PlayerMess(string name, int age, int atack, int defend)
{
this.name = name;
this.age = age;
this.atack = atack;
this.defend = defend;
equipMess = new List<Equipment>();
}
public void AddStateToList(Equipment t)
{
equipMess.Add(t);
}
/// <summary>
/// 存储装备数据
/// </summary>
public void SaveEquip(string nameFlag)
{
NameFlag = nameFlag;
int i = 1;
foreach (Equipment item in equipMess)
{
string a = nameFlag+"_Equip" + i + "ID";
string b = nameFlag + "_Equip" + i + "Number";
PlayerPrefs.SetString(a, item.Id);
PlayerPrefs.SetInt(b, item.Numb);
i++;
}
}
/// <summary>
/// 存储玩家数据
/// </summary>
public void Save(string nameFlag)
{
NameFlag = nameFlag;
PlayerPrefs.SetString(nameFlag + "_name", name);
PlayerPrefs.SetInt(nameFlag+"_age", age);
PlayerPrefs.SetInt(nameFlag+"_atack", atack);
PlayerPrefs.SetInt(nameFlag+"_defend", defend);
PlayerPrefs.Save();
}
/// <summary>
/// 读取玩家数据·
/// </summary>
public void Read()
{
string a = PlayerPrefs.GetString(NameFlag+"_name");
int b = PlayerPrefs.GetInt(NameFlag + "_age");
int c = PlayerPrefs.GetInt(NameFlag + "_atack");
int d = PlayerPrefs.GetInt(NameFlag + "_defend");
Debug.Log("玩家的姓名为" + a);
Debug.Log("年龄为" + b);
Debug.Log("攻击力为" + c);
Debug.Log("防御力为" + d);
}
/// <summary>
/// 读取装备数量数据
/// </summary>
public void ReadEquip()
{
for (int i = 1; i <= 3; i++)
{
Debug.Log("Equip" + i + "Id为:" + PlayerPrefs.GetString(NameFlag+"_Equip" + i + "ID"));
Debug.Log("Equip" + i + "数量为:"+PlayerPrefs.GetInt(NameFlag+"_Equip" + i + "Number"));
}
}
}文章来源地址https://www.toymoban.com/news/detail-435583.html
>排行榜信息
//-------------------------------------
//—————————————————————————————————————
//___________项目: ______________
//___________功能:排行榜功能
//___________创建者:秩沅_______________
//_____________________________________
//-------------------------------------
public class Chats : MonoBehaviour
{
public List<Player> listSave;
public void Save( ) //多对象存储
{
for (int i = 0; i < listSave.Count ; i++)
{
PlayerPrefs.SetString(listSave[i].PlayName + "_name", listSave[i].RealName);
PlayerPrefs.SetInt(listSave[i].PlayName + "_soccer", listSave[i].Soccer);
PlayerPrefs.SetInt(listSave[i].PlayName + "_time", listSave[i].Time);
}
PlayerPrefs.Save();
}
public void Print() //读取排行榜信息
{
string a;
int b;
int c;
for (int i = 0; i < listSave.Count; i++)
{
a = PlayerPrefs.GetString(listSave[i].PlayName + "_name");
b = PlayerPrefs.GetInt(listSave[i].PlayName + "_soccer");
c = PlayerPrefs.GetInt(listSave[i].PlayName + "_time");
print($"玩家{ listSave[i].PlayName} 的名字为:{a}");
print($"玩家{ listSave[i].PlayName} 的分数为:{b}");
print($"玩家{ listSave[i].PlayName} 的排名为:{a}");
}
}
// Start is called before the first frame update
void Start()
{
listSave = new List<Player>();
Player player1 = new Player("张三", "Baga", 99, 1);
Player player2 = new Player("李四", "Gaji", 56, 3);
Player player3 = new Player("王五", "Wujige", 92, 2);
listSave.Add(player1);
listSave.Add(player2);
listSave.Add(player3);
Save();
Print();
}
// Update is called once per frame
void Update()
{
}
}
到了这里,关于【unity小创意】相机的正反操作实现场景的二维跳跃的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!