Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

8 years ago by Philip

Hej,

just published the multitouch plugin: https://github.com/Houly/ImpactMultiTouch

It's pretty much build around what we needed for Steamclash, but this should work in other cases, too.

8 years ago by Graphikos

Right on. Be sure to submit it to http://www.pointofimpactjs.com also! ;)

8 years ago by Philip

Just did that :)

8 years ago by mimik

so how do i bind it in my main.js=
with something like?

ig.keydown.bind( 'touchstuff mouse' );

ig.input.touches.mouse.state();*/

Got any example on how to use it on main.js
Got kinda confused when i looked at button.js class and the source.

thanks

8 years ago by Philip

hum, okey. Maybe this needs a little more explanation

I tried to implement it like it is optional.. All you have to do is bind a click action on Mouse 1 an you are set. Like this ig.input.bind( ig.KEY.MOUSE1, 'click' );

There are a few ways to handle touches now.

There is the old way with ig.input.state( 'click' ) or for the position ig.input.mouse.x This is the way impact normally handles mouse and touch events and this still works.

But the nature of multitouch is in multiple states and positions.If you want to handle those, you have to look at ig.input.touches which at the moment is an object. This could be optimized as an array, but for the sake of less code I used an object.

Just iterate over it with for ( var t in ig.input.touches ) and you have all the states and positons of the currently active touches. A touch object has the following attributs:

{
  x: the x Positon,
  y: the y Position,
  state: the state of the touch. State can be up or down
  id: the id of the touch
}

Normally when a touchup happens, the touch gets removed fromt the list. But only after the current game loop finshes. So to be sure, you have to check the state.

I'm sorry that htis is a little bit more complicated, but handling multiple touches is more complicated than one touch. I don't think this can be that much easier.

I hope this helped.

8 years ago by mimik

thanks for taking the time to explain a little more.

For testing, did you make the mouse same as touch or did i just read the src wrong?

8 years ago by Philip

The mouse position is the same as the position of a touch. Which touch i can't say, depends on the system. So if you just need single touch, this plugin still works with ig.input.mouse

7 years ago by Joncom

Wanted to thank you Philip for creating this plugin. It's very useful!

This works very well for 2 touches. Is it possible to capture more than 2 simultaneous touches?

7 years ago by Philip

Hum, just looked into this. It works fine for me. At least with the test code i wrote back then, the rectangles are drawn correctly for every finger that touches the screen.

I optimized the code a tiny little bit, but that shouldn't help with your problem.

7 years ago by Joncom

Ran two different tests using mobile Safari:

Oiriginal iPad (iOS 4.3.3) picks up no more than 2 touches.
iPod Touch 5th Gen (iOS 6.1) picks no more than 5 touches.

By the way, there was a scaling issue which made your plugin unusable when scale was not equal to 1.

Forked your repo, fixed the scaling issue, and made a pull request.

7 years ago by Philip

I have an original iPad, too, but with iOS 5.1.1. maybe that is an problem with the iOS Version? Can't think of another reason.

I get up to 10 touches an the iPad, must ask another person to help me find the real maximum, but I don't have more than 10 finger :)

There is some weird behavior on my iPhone (iOS 6.1.2) where after 5 touches the old ones don't go away. I will look into that.

And thanks for the pull request, i will merge that :)

7 years ago by Philip

Hum, I did some testing and it looks like it's not really save to use more than 2 touches on the iPhone. With more than 2 touches I get inconsistent behavior. Like moving of touches where my finger doesn't move and even touchup and touchdown events.

I will look into this, but not right now and maybe not the next weeks cause IU have a shitload of work to do. So, if you figure something out, I will happily merge that into the repo

5 years ago by Krisjet

Tried out this plugin now for one of my projects, and I'm not registering any touches using the old ig.input.pressed('click') method anymore. Anyone know if this is compatible with newer versions of Impact?
Page 1 of 1
« first « previous next › last »