motion

How to stop responding to a shake before a button is pressed?

邮差的信 提交于 2019-12-31 07:38:15
问题 i am currently making a iPhone app, and a animation reacts to a small shake, this is my code: static BOOL SJHShaking(UIAcceleration* last, UIAcceleration* current, double threshold) { double deltaX = fabs(last.x - current.x), deltaY = fabs(last.y - current.y), deltaZ = fabs(last.z - current.z); return (deltaX > threshold && deltaY > threshold) || (deltaX > threshold && deltaZ > threshold) || (deltaY > threshold && deltaZ > threshold); } - (id)initWithFrame:(CGRect)frame { if (self) { //

How to stop responding to a shake before a button is pressed?

╄→尐↘猪︶ㄣ 提交于 2019-12-31 07:38:06
问题 i am currently making a iPhone app, and a animation reacts to a small shake, this is my code: static BOOL SJHShaking(UIAcceleration* last, UIAcceleration* current, double threshold) { double deltaX = fabs(last.x - current.x), deltaY = fabs(last.y - current.y), deltaZ = fabs(last.z - current.z); return (deltaX > threshold && deltaY > threshold) || (deltaX > threshold && deltaZ > threshold) || (deltaY > threshold && deltaZ > threshold); } - (id)initWithFrame:(CGRect)frame { if (self) { //

Calculate initial velocity to move a set distance with inertia

故事扮演 提交于 2019-12-30 03:26:08
问题 I want to move something a set distance. However in my system there is inertia/drag/negative accelaration. I'm using a simple calculation like this for it: v = oldV + ((targetV - oldV) * inertia) Applying that over a number of frames makes the movement 'ramp up' or decay, eg: v = 10 + ((0 - 10) * 0.25) = 7.5 // velocity changes from 10 to 7.5 this frame So I know the distance I want to travel and the acceleration, but not the initial velocity that will get me there. Maybe a better explanation

How to motion shake only after a button? [duplicate]

雨燕双飞 提交于 2019-12-25 05:08:18
问题 This question already has an answer here : Closed 7 years ago . Possible Duplicate: How to stop responding to a shake before a button is pressed? I have a app and currently if you click the button 'Play' a label show's saying 'Shake to Play' the problem is I am a total beginner and I don't know how to order it so the user has to first press the button, then when the label show's, if the user shake's the label disappears. that's all I need because I have sorted out other parts of the app after

Android MotionEvent.getActionIndex() and MultiTouch

爷,独闯天下 提交于 2019-12-22 11:23:18
问题 I am trying to get the pointer id whene the event MotionEvent.ACTION_MOVE happens. I am doing it by calling event.getActionIndex() but it always returns 0 for the second, the third, the forth and the fifth finger. i am using Gingerbread 2.3.3 on Galaxy S I9000 here is my code switch (event.getActionMasked()) { case MotionEvent.ACTION_MOVE: { Log.d("D"," getActionIndex()="+event.getActionIndex()); };break; } This is the debug results 05-02 19:20:08.628: DEBUG/D(4534): getActionIndex()=0

draw a single-touch motion path in android

ε祈祈猫儿з 提交于 2019-12-22 05:11:57
问题 i am trying to make a drawing application. i want to draw a single-touch motion path in android - like the way the Swype keyboard does it. And consequently i want to store x-y coordinates of EACH of the pixels of the motion path into a data structure. How can i use the MotionEvent pointers to do this? 回答1: You probably don't have to store every pixel - just store a new one when certain parameters are met such as the pixel is further along or if the angle between one pixel and the next is

What's the difference between ACTION_CANCEL and ACTION_UP in MotionEvent?

社会主义新天地 提交于 2019-12-20 12:17:30
问题 I want to track a finger touch on the screen. So what I did was to start recording the position when MotionEvent triggers ACTION_DOWN , but how do I know when the action is finished, at ACTION_CANCEL , or ACTION_UP ? What's the exact difference between them? 回答1: MotionEvent: ACTION_UP: A pressed gesture has finished, the motion contains the final release location as well as any intermediate points since the last down or move event. ACTION_CANCEL: The current gesture has been aborted. ACTION

MotionEvent GetY() and getX() return incorrect values

一笑奈何 提交于 2019-12-18 14:50:10
问题 I have following situation: I have a custom ListView with ImageView and TextView in a row. The ImageView has an onTouchListener, wchich invokes my onTouch method. Here are some lines from it: if (event.getAction()==MotionEvent.ACTION_MOVE) { layout.leftMargin = (int) event.getX() - dragIcon.getWidth()/2; layout.topMargin = (int) event.getY() - dragIcon.getHeight()/2; //Log.d("Tag", "Pozycja: " + event.getX() +", "+ event.getY()); } dragIcon.setLayoutParams(layout); When move is detected I'm

MotionEvent GetY() and getX() return incorrect values

蹲街弑〆低调 提交于 2019-12-18 14:49:12
问题 I have following situation: I have a custom ListView with ImageView and TextView in a row. The ImageView has an onTouchListener, wchich invokes my onTouch method. Here are some lines from it: if (event.getAction()==MotionEvent.ACTION_MOVE) { layout.leftMargin = (int) event.getX() - dragIcon.getWidth()/2; layout.topMargin = (int) event.getY() - dragIcon.getHeight()/2; //Log.d("Tag", "Pozycja: " + event.getX() +", "+ event.getY()); } dragIcon.setLayoutParams(layout); When move is detected I'm

Masking a blob from a binary image

∥☆過路亽.° 提交于 2019-12-18 04:27:05
问题 I am doing motion recognition of walking using openCV and C++ and I would like to create a mask or copied image in order to achieve the effect seen in the picture provided. .The following is an explanation of the images The resulting blob of the human walking is seen. Then, a mask image or copied image of the original frame is created, the binary human blob is now masked and the non-masked pixels are now set to zero. The result is the extracted human body with a black background. The diagram