看到傅园慧女神的洪荒之力,心中也充满了洪荒之力,顺势做一个测手速的小游戏,虽然做的有点渣。谁让我既不会美术又不会动画,图还得自己做、动画还得自己截,差点折腾死我。
下面展示(轻吐槽,我知道做得难看):
再说一下:资源、图、动画啥的就不要太认真了,我费了九牛二虎之力也只这个水平了。(PS:大部分时间就和这些杠上了,没美工真可怕)
首先,第一个scene一张图说明下一下:
 
这个scene的脚本我都不想贴,就这两东西
[C#]  纯文本查看  复制代码
?
1
2
3
4
5
6
7
public void IStart()
     {
         SceneManager.LoadScene( "Scene1" );
     }
     public void IExit()
     {
         Application.Quit();
     }

第二个scene也先来一张图,清晰明了:
这部分使用了两块代码,分别是相机平滑跟随player的followTarget.cs和Move.cs。
其中的第二个脚本虽然用最通俗的if来写的,但是包含了移动的加速减速、动画的播放停止、秒计时器、数据存储等诸多方面,列出来看看吧。
[C#]  纯文本查看  复制代码
?
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
using UnityEngine;
using System.Collections;
public class followTarget : MonoBehaviour {
     public float smoothing = 3;
     private Transform player;
     // Use this for initialization
     void Start()
     {
         //player = GameObject.FindGameObjectWithTag(Tags.player).transform;
         player = GameObject.Find( "swimmer" ).transform;
     }
     // Update is called once per frame
     void FixedUpdate()
     {
         Vector3 targetPos = player.position + new Vector3(0, 0, -6);
         transform.position = Vector3.Lerp(transform.position, targetPos, smoothing * Time.deltaTime);
     }
}

[C#]  纯文本查看  复制代码
?
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class Move : MonoBehaviour {
     public float speed = 1;
     float speed1 = 0;
     float i = 0;
     int m = 0; //时间
     int n = 0; //点击次数
     Vector2 ToPos = new Vector2(1,1);
     GameObject player;
     Text indexClick;
     Text indexTime;
     bool ifSave = true ;
     //动画组件
     private Animator mAnim;
         // Use this for initialization
         void Start () {
         player = GameObject.Find( "swimmer" );
         indexClick = GameObject.Find( "Canvas" ).transform.Find( "clickText" ).GetComponent<Text>();
         indexTime = GameObject.Find( "Canvas" ).transform.Find( "timeText" ).GetComponent<Text>();
         mAnim = GetComponent<Animator>();
         mAnim.SetBool( "idle" , true );
         mAnim.SetBool( "swim" , false );
         }
         
         // Update is called once per frame
         void Update () {
         if (Input.GetMouseButtonDown(0) || Input.GetKeyDown(KeyCode.X))
         {
             speed1 += 0.9f;
             n++;
             indexClick.text = "点 击 次 数:" + n.ToString();
             mAnim.SetBool( "swim" , true );
             mAnim.SetBool( "restart" , true );
         }
         else if (speed1 > 0)
         {
             speed1 -= 0.09f;
             mAnim.SetBool( "swim" , false );
             mAnim.SetBool( "restart" , false );
         }
         else
         {
             speed1 = 0;
             mAnim.SetBool( "stop" , true );
         }
         GetComponent<Rigidbody2D>().MovePosition(transform.position + new Vector3(1, 0, 1) * speed1 * Time.deltaTime);
         //秒计时器
         if (i >= 1.0f)
         {
             i = 0;
             m++;
             indexTime.text = "用时(秒):" + m.ToString();
             //print(m);
         }
         i += Time.deltaTime;
         //数据存储
         if (player.transform.position.x > 8.4f && ifSave == true )
         {
             PlayerPrefs.SetInt( "indexClick" , n);
             PlayerPrefs.SetInt( "indexTime" , m);
             ifSave = false ;
             SceneManager.LoadScene( "Scene2" );
         }
         
         }
}

第三部分就更简单了,取一下第二个scene存的数据,然后显示出来就行了。本来想加个排行榜,然后想了下,这个再说吧,先不浪费时间了。
如图:
代码也很简洁:
[C#]  纯文本查看  复制代码
?
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class showFinal : MonoBehaviour {
     int indexTime;
     int indexClick;
     Text ClickText;
     Text TimeText;
         // Use this for initialization
         void Start () {
         indexClick = PlayerPrefs.GetInt( "indexClick" );
         indexTime = PlayerPrefs.GetInt( "indexTime" );
         ClickText = GameObject.Find( "Canvas" ).transform.Find( "clickText" ).GetComponent<Text>();
         TimeText = GameObject.Find( "Canvas" ).transform.Find( "timeText" ).GetComponent<Text>();
         ClickText.text = "点 击 次 数:" + indexClick.ToString();
         TimeText.text = "用时(秒):" + indexTime.ToString();
         }
         
         // Update is called once per frame
         void Update () {
         
         }
     public void Restart()
     {
         SceneManager.LoadScene( "Scene1" );
     }
     public void Exit()
     {
          Application.Quit();
     }
}

可以发布成安卓的,也可以发布成pc的,pc的按X键或者鼠标加速,小伙伴们,爆发你的洪荒之力吧(傅女神借我点洪荒之力呗)。

奥运测手速小游戏(傅女神)相关推荐

  1. 【Python】利用tkinter开发测手速小游戏

    一.简介 利用tkinter开发测手速的小游戏,大家10s内可以点击鼠标多少次呢?想测试一下吗?来试试测手速下游戏吧!仅供娱乐~ 试玩视频: 测手速小游戏 游戏截图: 二.代码分模块介绍 2.1 导入 ...

  2. JQuery测手速小游戏-遁地龙卷风

    (-1)写在前面 我用的chrome49,jquery3.0,我得到过399分,信不信由你. (1)设计思路 两个p元素放在div里,每个p元素的高度和宽度都和div一样,当鼠标放在div上时,第一个 ...

  3. CocosCreator拼手速小游戏(教程 + 源码)TS实现小游戏

    CocosCreator拼手速小游戏(教程 + 源码)TS实现小游戏 前言 游戏完成后的样子 玩法:在10秒内点击屏幕中间的按钮,最终记录一共点击了多少下 源码在Q群:1130122408 这个游戏比 ...

  4. Alex - 用python来写测手速游戏

    # 测手速游戏 # 文字:按钮:0 次/s # 按钮 import time import tkinter # 1.初始化 mywindow = tkinter.Tk() # 3.设置标题 mywin ...

  5. Deqin- 升级版测手速游戏

    import tkinter import time import cct = tkinter.Tk() t.geometry("500x500") t.title("反 ...

  6. succi -测手速游戏

    import tkinter as tk import time window=tk.Tk() window.title('测手速游戏') window.geometry('600x500') # L ...

  7. 手机测试android程序下载,测手速下载_测手速手机版下载「安卓版」-太平洋下载中心...

    这是一款用来做测试的综合测试类应用,可以测试你的各种能力. 在首页,你可以测试你的手速,首页的测手速共有5秒,10秒,20秒,30秒,60秒共五种模式可选.测试完成后你可以把测试结果分享到qq空间,q ...

  8. 计算机练手速的游戏,玩手速的游戏有哪些 手机上练手速的游戏推荐

    玩手速的游戏有哪些,手速游戏顾名思义就是需要玩家有着敏捷快的反应和手速才能应对的游戏了,跑跑车为您带来手机上练手速的游戏推荐. 点杀泰坦2 作为剑圣来防卫世界的战斗还在持续,但是更多全新的更加危险的巨 ...

  9. ziheng - 测手速游戏

    import tkinter as tk import timet1 = time.time()dian = 0 def zan():global dian # 全球的 变暖 把一个变量变成全局变量d ...

最新文章

  1. SQL Server调优系列基础篇(子查询运算总结)
  2. AcWing算法基础课 Level-2 第三讲 搜索与图论
  3. initial model for Agile Development Organization: Relationship Graph
  4. 万年历c语言编程代码_C语言高效编程与代码优化~
  5. excel几个表合成一张_快速将多个excel表合并成一个excel表
  6. java web sqlmapapi,深入了解SQLMAP API
  7. [蓝桥杯][历届试题]网络寻路(DFS)
  8. Android ndk之Check that/ndk/openssl/crypto/libsfk.so exists or that its path is corret
  9. 分析Spring容器启动流程 Spring初始化
  10. Spring Boot基础学习笔记23:用户自定义授权管理
  11. wordpress支持MySQL5.5_CentOS 5.5安装Nginx、PHP(FastCGI)、MySQL --搭建LNMP环境安装Wordpress...
  12. Navicat 解决方案之ORA-28547
  13. .NET程序中常用的28种代码
  14. 基于C#窗体的酒店管理系统
  15. window操作系统安装教程(PE辅助)
  16. 简练软考知识点整理-激励理论之赫兹伯格双因素理论
  17. 加密狗加密excel ,方法之 C#开发Excel自定义函数
  18. java业务场景-实现订单超时关闭等延时队列操作的几种方式
  19. 【路径规划】基于改进差分实现三维多无人机协同航迹规划matlab源码
  20. Amazon Alexa硬件方案选型

热门文章

  1. java万能盒子_Auslogics Disk Defrag Free最新版-Auslogics Disk Defrag Free下载v8.0.24.0 - 起点软件园...
  2. react项目部署到linux服务器
  3. Ubuntu16.04安装微信教程(亲测可用,不能用直接留言)
  4. 键盘和鼠标无法唤醒计算机,电脑休眠键鼠无法唤醒怎么办 键盘鼠标无法唤醒电脑解决方法...
  5. 好丽友春节活动H5:
  6. MongoDB 查询优化原则
  7. MySQL批量插入与更新
  8. 平民化的短视频和直播将加速世界融合
  9. 面向对象编程三⼤特性 --封装、继承、多态
  10. Android中探究抖音短视频的动态壁纸功能以及拓展功能使用