Box2D Forums

It is currently Mon May 20, 2013 5:08 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 12 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Wed Mar 02, 2011 6:34 pm 
Offline

Joined: Wed Mar 02, 2011 6:30 pm
Posts: 3
I've hit a wall trying to figure this one out, any help will be greatly appreciated.

Does anyone know how to modify the built-in dragging behavior to use TouchEvents instead of MouseEvents? Specifically for use with multiple touch points/draggable objects at once?


Top
 Profile  
 
PostPosted: Wed Mar 02, 2011 7:15 pm 
Offline

Joined: Fri Dec 14, 2007 8:07 pm
Posts: 913
What device are you publishing to? Is this iOS?


Top
 Profile  
 
PostPosted: Wed Mar 02, 2011 7:31 pm 
Offline

Joined: Wed Mar 02, 2011 6:30 pm
Posts: 3
I'm targeting the BlackBerry Playbook.


Top
 Profile  
 
PostPosted: Wed Mar 02, 2011 10:23 pm 
Offline

Joined: Tue Jun 24, 2008 8:25 pm
Posts: 1515
Location: Tokyo
The "built-in dragging behaviour"? Are you talking about the testbed? That's not likely to work for multitouch at all, since it was only ever intended to have a single 'touch'.

I think you will have to do your own creating and destroying of MouseJoints to get this working properly. I did it recently on the iPhone - as long as you can tell which touch events belong to the same finger it shouldn't be too hard. You just need to hold a map from the 'fingers' to your MouseJoints, so that when a touch/finger does something, you know which MouseJoint to move or destroy.


Top
 Profile  
 
PostPosted: Wed Mar 02, 2011 10:47 pm 
Offline

Joined: Wed Mar 02, 2011 6:30 pm
Posts: 3
Thanks! That should put me in the right direction. Much appreciated.


Top
 Profile  
 
PostPosted: Fri Mar 04, 2011 11:53 am 
Offline

Joined: Fri Dec 14, 2007 8:07 pm
Posts: 913
irresistible force wrote:
I did it recently on the iPhone


Wait wait wait. You got the alchemy port running on the iPhone?


Top
 Profile  
 
PostPosted: Sat Mar 05, 2011 1:22 pm 
Offline

Joined: Tue Jun 24, 2008 8:25 pm
Posts: 1515
Location: Tokyo
oops... no. I thought you were gonna do that :p

Sorry sometimes I forget which sub-forum I'm talking to.


Top
 Profile  
 
PostPosted: Wed Dec 26, 2012 3:22 am 
Offline

Joined: Sun Nov 11, 2012 11:31 am
Posts: 21
Happy xmas everyone,
I'm trying to get multitouch working with WCK. Can this be modified in one of the classes? I've looked around but could not find any startDrag code. My multitouch
code doesn't work with wck objects. Is there any way? It's crucial to the game I want to make, so would be a shame if it's not possible. If the object has to be a simple Mc
or sprite without attached bodies, that would be ok!

D1 and D2 are 2 movieclips which I need to be dragged at the same time by 2 players on the iPad.

I pasted the multitouch import classes in the WCK.as, and my 'onTouchMove' function works, but not the others.

Thanks,
Matt



import flash.ui.Multitouch;
import flash.ui.MultitouchInputMode;
import flash.events.TouchEvent;

Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;

var dragArray:Array = [D1, D2];

for (var i:int = 0; i < dragArray.length; i++) {

dragArray[i].addEventListener(TouchEvent.TOUCH_BEGIN, onTouchBegin);
dragArray[i].addEventListener(TouchEvent.TOUCH_MOVE, onTouchMove);
dragArray[i].addEventListener(TouchEvent.TOUCH_END, onTouchEnd);

}



function onTouchBegin(evt:TouchEvent) {
evt.currentTarget.startTouchDrag(evt.touchPointID);

}

function onTouchMove(evt:TouchEvent) {
evt.currentTarget.alpha = 0.5;
}

function onTouchEnd(evt:TouchEvent) {
evt.currentTarget.stopTouchDrag(evt.touchPointID);
}


Top
 Profile  
 
PostPosted: Wed Jan 02, 2013 6:21 am 
Offline

Joined: Sun Nov 11, 2012 11:31 am
Posts: 21
Has no one tried this yet? I think this post was started about 4 years ago!


Top
 Profile  
 
PostPosted: Mon Jan 14, 2013 9:47 pm 
Offline

Joined: Thu Mar 01, 2012 9:31 am
Posts: 153
According to my calculations: 2013 - 2011 = 2 years ;)

Not sure if it makes a difference but on one webpage I saw evt.target being used instead of evt.currentTarget.

Since you mentioned onTouchMove working, I would try to set the position with something like:
evt.target.x = evt.stageX;


If D1 and D2 are box2d objects then add:
evt.currentTarget.syncTransform();

Or maybe use:
evt.currentTarget.b2body.SetTransform(new V2(new_x/world_scale, new_y/world_scale), 0);


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ]  Go to page 1, 2  Next

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group