-
Notifications
You must be signed in to change notification settings - Fork 160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Engine,Editor: add Touch Script API #2440
base: ags4
Are you sure you want to change the base?
Conversation
DynObjectRef create_touchpoint(int n) | ||
{ | ||
if (n < 0 || n >= tp::MAX_POINTERS) | ||
quit("!Touch: invalid index for touchpoint"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not a good idea to use quit
here, for something that is neither a fatal error nor a user's fault.
An assertion and returning null
should be enough.
But seeing how this function is used, I am not sure why is it needed at all.
The loop in Touch_GetTouchPoints() below could call CreateTouchPointRef
directly instead, and limit iterations to MAX_POINTERS too.
Trying to understand how this api works, am I right that this returned array is always as long as the maximal number of touches done during the gameplay (it only grows and never shrinks)? My big question in regards to API is: why return array, and not have an indexed attribute?
|
That wasy first sketch of the API, I am not sure which is better. Currently, each touch point is a position (x,y), if the finger is down or not, and a finger id that is unique. Now apparently Safari on iPhone currently can only have at maximum 2 touch positions, while on Android Chrome it seems possible to go up to 10. On an Android app it seems, at least on my phone, it goes up to 10 (ignoring the hard limit set in ags in this PR), and in my iPhone I need to test again - I forgot. But I thought about using the max to limit the count to how many touches are actually being used in the application. I was debating about which way is better, to handle the touch points, for instance, I think I like more the way you mentioned, but I was also thinking about dropping the "is down" property from the touch point and return an array and any items in the array means the finger is down, as I think the position in the touch release may not be relevant. |
fix #1538
A minimal touch api that can be used to detect touching a screen.