贪吃蛇资源包下载:传送门
Gesture currentGesture = EasyTouch.current;
currentGesture != null && currentGesture.swipe == EasyTouch.SwipeDirection.Up
currentGesture != null && currentGesture.swipe == EasyTouch.SwipeDirection.Down
currentGesture != null && currentGesture.swipe == EasyTouch.SwipeDirection.Left
currentGesture != null && currentGesture.swipe == EasyTouch.SwipeDirection.Right
该功能有两种实现方法。
将如下方法注册到EasyTouch Button的On Down()和On Up()事件上去即可。
public void ButtonDown()
{
if (MainUIController.Instance.isPause == false && isDie == false)
{
CancelInvoke();
InvokeRepeating("Move", 0, velocity - 0.2f);
}
}
public void ButtonUp()
{
if (MainUIController.Instance.isPause == false && isDie == false)
{
CancelInvoke();
InvokeRepeating("Move", 0, velocity);
}
}
//SpeedUpButton为Button的名字
if (ETCInput.GetButtonDown("SpeedUpButton") && MainUIController.Instance.isPause == false && isDie == false)
{
CancelInvoke();
InvokeRepeating("Move", 0, velocity - 0.2f);
}
if (ETCInput.GetButtonUp("SpeedUpButton") && MainUIController.Instance.isPause == false && isDie == false)
{
CancelInvoke();
InvokeRepeating("Move", 0, velocity);
}
EasyTouch的Button键或许或有bug,我们根据文档提示按步骤操作
If you found problems in the behavior of the buttons with ETCInput.GetButtonDown or ETCInput.GetButtonUp,please force the script execution order like this : 1- Open Script Execution Order (Edit => Project Settings => Script Execution Order) 2- Add ETCButton in first 3- Add yours scripts that use ETCInput.
翻译过来即是:
任意一个脚本- Inspector面板- Script Execution Order- 首先添加ETCButton,其次添加用到ETCInput的脚本- Apply
大家还有什么问题,欢迎在下方留言!