【发布时间】:2019-07-24 18:33:30
【问题描述】:
我在底部有四个按钮,笔记会从屏幕顶部掉下来,我不知道如何为移动设备编写触摸屏部分,我有它适用于 pc 格式,但我不确定我是什么需要改变它才能工作。
我有 2 个脚本,一个用于按钮,一个用于每个音符掉落。
这是我目前拥有的: 对于按钮:
void Update()
{
if(Input.GetKeyDown(keyToPress))
{
theSR.sprite = pressedImage;
}
if(Input.GetKeyUp(keyToPress))
{
theSR.sprite = defaultImage;
}
}
对于注释: 无效更新()
{
if(Input.GetKeyDown(keyToPress))
{
if(canBePressed)
{
gameObject.SetActive(false);
//GameManager.instance.NoteHit();
//Determine if player hits the note normal, good, perfect
if (Mathf.Abs(transform.position.y) > 0.25)
{
GameManager.instance.NormalHit();
Instantiate(hitEffect, transform.position, hitEffect.transform.rotation);
}
else if (Mathf.Abs(transform.position.y) > 0.05f)
{
GameManager.instance.GoodHit();
Instantiate(goodEffect, transform.position, goodEffect.transform.rotation);
}
else
{
GameManager.instance.PerfectHit();
Instantiate(perfectEffect, transform.position, perfectEffect.transform.rotation);
}
}
}
}
如果它只在 PC 上运行完美,但我只是不知道如何将其更改为按钮以在移动设备上做出与在 PC 上完全相同的反应方式
【问题讨论】:
-
处理多平台输入时考虑使用LeanTouch