sửa demo bài
This commit is contained in:
@@ -1,31 +0,0 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
public class FlickArea : MonoBehaviour, IPointerDownHandler, IPointerUpHandler
|
||||
{
|
||||
public BallShooter ballShooter;
|
||||
|
||||
private Vector2 startPos;
|
||||
private float startTime;
|
||||
|
||||
public void OnPointerDown(PointerEventData eventData)
|
||||
{
|
||||
startPos = eventData.position;
|
||||
startTime = Time.time;
|
||||
}
|
||||
|
||||
public void OnPointerUp(PointerEventData eventData)
|
||||
{
|
||||
Vector2 endPos = eventData.position;
|
||||
float endTime = Time.time;
|
||||
|
||||
Vector2 swipeDelta = endPos - startPos;
|
||||
float swipeTime = endTime - startTime;
|
||||
|
||||
// Ensure swipeTime is not 0 to avoid division by zero
|
||||
if (swipeTime > 0 && ballShooter != null)
|
||||
{
|
||||
ballShooter.FlickShoot(swipeDelta, swipeTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a39d896efd271d648ab60642c63b9556
|
||||
Reference in New Issue
Block a user