Multitouch Extension Download
I'm hoping others can extend this to make some functions for swipe, pinch, button, and joystick actions. So here's the code! It's simple! Good luck!
function touchInit(argument0){
this.canvas = document.getElementById('canvas');
window.touches = [];
this.canvas.addEventListener('touchstart', function(event) {
window.touches = event.touches;
}, false);
this.canvas.addEventListener('touchend', function(event) {
window.touches = event.touches;
}, false);
}
function touchNumber(){
return window.touches.length;
}
function touchX(argument0){
return (window.touches[argument0]).clientX;
}
function touchY(argument0){
return (window.touches[argument0]).clientY;
}I made this extension following the instructions in this article: Developing for Multi-touch Article
Instructions:
touchInit() - Call this at the beginning of your game.
touchNumber() - Returns the number of fingers on the mobile device screen.
touchX(touchIndex) - Returns the X value of the touch with ID touchIndex. touchIndex starts at 0 and goes up to touchNumber().
touchX(touchIndex) - Returns the Y value of the touch with ID touchIndex.
Yeah, so I didn't know how to do anything in Javascript or with canvas or with multi-touch stuff about 6 hours ago. I got so frustrated that I couldn't do multi-touch in my mobile game that I just looked it up on the net and did it myself.
For someone that KNEW how to program in Javascript, this would have taken 15 minutes. The Virtual Keys in the YoYoGames functions DO NOT SUPPORT MULTITOUCH (on iOS5 at least).
I just want to know why the YoYo team hasn't gotten here first and written 20 lines of code to help us utilize these features. Mobile games look and feel broken without multitouch capabilities that have become the mobile game standard.
Come on YoYoGames, it woulda been so easy to include the above functions, and they really make a big difference. Hope you can create these functions in the next release.
Anyway, you'll have to write your own functions to make it easier to make your own buttons/joysticks ect. to utilize these functions, but it should be fairly straightforward.
Good luck guys!



Find content
Not Telling
