Import the extension!
- For GM:S, right-click on the Extensions folder in the Resource Tree, pick "Import extension", and choose the downloaded GMEZ.
- For GM8.x, pick "menu:Scripts ➜ Import Scripts..." and choose
window_pointer.gml.
Then either copywindow_pointer.dllto the directory with your GMK/GM81 file or add it to your Included Files.
Before you use any extension functions, call
window_pointer_init, like so:window_pointer_init();
typically in some controller object's Create event
Call
window_pointer_flusheach frame after you've done what you wanted with the extension functions, like so:window_pointer_flush();
In GM:S this can be simply added to some "late" event like Draw GUI End.
If you do not call this function, Pressed/Released states will not be cleared, and old pointers indexes will not be recycled!
This is a "cheat sheet" for "window_pointer" extension by YellowAfterlife.
The extension can be found on itch.io.
The source code can be found on GitHub
Quick display controls: Categories · Sections · Everything ·
All of these take an ind argument, which is a 0-based pointer (touch) index,
just like with device_mouse functions in modern GameMaker.
Much like with modern GameMaker, indexes are reused and new pointers occupy use the lowest "available" index.
The extension can store information about up to 256 pointers simultaneously, but hardware rarely supports more than 10, so you might poll only as many as you're willing to handle at any given time.
For example,
for (var i = 0; i < 10; i++) { if (window_pointer_check(i)) { draw_circle(window_pointer_x(i), window_pointer_y(i), 40, true); } } window_pointer_flush();
Returns a unique-ish WinAPI ID of the touch. These can be used to tell touches apart.
These count up and eventually recycle after reaching 65536.
Returns whether n-th pointer is currently active and held down.
Returns whether n-th pointer has been pressed since the last frame.
Returns whether n-th pointer has been released since the last frame.
You may still poll position and related properties until another a new pointer takes up that index (no less than one frame later).
Returns X position of a pointer.
This is measured in window coordinates much like window_mouse_get_x(),
so you may need to do a little math to translate it into room space.
Same as above, but for Y.
Returns whether the pointer is the primary one.
If the user touches the screen with four fingers, the first finger's pointer will be "primary" and no other pointer will be made primary until all fingers are released.
Returns which button the pointer uses.
This will usually be 0, but can be up to 4 for styluses with side buttons/erasers.
Considering the typical implementation details, you probably shouldn't count on this being consistent though.