superpowers / superpowers-game

:video_game: Make 2D and 3D games in live collaboration with Superpowers
http://superpowers-html5.com/
Other
402 stars 93 forks source link

Cross platform multi touch fixes #44 #174

Open AgileJoshua opened 8 years ago

AgileJoshua commented 8 years ago

Restarting PR #65 (by accident) while trying to cleanup stuff.

Still needs to be tested on devices - this is just the cleanup...

AgileJoshua commented 8 years ago

I have tested this out using this project: https://github.com/AgileJoshua/superpowers-touch-demo which can be downloaded and copied into the projects folder of a SuperPowers server.

The project suports multiple touches and tapping simultaneously. Tested on Samsung S6 & S7, chrome in mobile emulation mode, iPhone simulator (XCode), iPad Mini & iPad Air.

The only issue I have found so far is on Android when tracking multiple touches when a touch is ended then the first touch in the array is also ended. But this only occurs once after there are zero touches. This could be an issue with my demo project...

    function getTouchPosition(identifier: number): Math.Vector2;
    function isTouchDown(identifier?: number): boolean;
    function wasTouchJustStarted(identifier?: number): boolean;
    function wasTouchJustEnded(identifier?: number): boolean;
    function wasTouchJustMoved(identifier?: number): boolean;
    function getTouchesStarted(): number[]; 
    function getTouchesEnded(): number[]; 
    function getTouchesMoved(): number[];
    function getTouchesDown(): number[];

I have tried to keep to the API standard for mouse events: was Thing Just Event is Thing State

plus get Thing Event

AlexBezuska commented 7 years ago

I am pretty new to SP, is there any way I can test out this build of the engine? (I'm not sure how to replace the build with the one on my local computer)

AgileJoshua commented 7 years ago

Updated with current master and finally got around to testing and debugging through the problems that were occuring on Android devices. I have tested this on real devices and in emulators/simulators, single and multitouch works as far as I can tell on Android and iOS. I have not tested on touch enabled Windows devices.

To test this, setup a superpowers dev environment. Switch to this branch of the code for the game system and compile as instructed.

Use my demo project https://github.com/AgileJoshua/superpowers-touch-demo to get a simple test project up. Just create a new folder inside the superpowers project folder and place all the files from https://github.com/AgileJoshua/superpowers-touch-demo there.

AgileJoshua commented 7 years ago

This closes #44, #135, #178

AgileJoshua commented 7 years ago

Rebased the whole fix on top of master to ensure only relevant changes are included...

AgileJoshua commented 7 years ago

Verified to work on Windows 10 on a Phone (Lumia) and Surface Pro 4 (in Chrome).