Saturday, April 12, 2014

Photo by gestures android mobile


're Doing a game in which hand to use a route slip, after hand raised, images of people here the route moves in the past. Please provide some ideas,,,
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
The general idea is that the characters do first two pieces move across the coordinate points record consisting of a collection of hand sliding points (sampling interval can be set not to record each point, little more space to move smoother), recycling collections take the adjacent two points to make the characters move.
Reply:
-,
First you have to rewrite onTouchEvent is
necessary
Then use a
Definition of private ArrayList pinfs = new ArrayList (); to keep it a point

In the onTouchEvent
 
switch (event.getAction ()) {
case MotionEvent.ACTION_DOWN:
pinfs.add (new PointF (event.getX (), event.getY ()));
break;
case MotionEvent.ACTION_MOVE:
pinfs.add (new PointF (event.getX (), event.getY ()));
break;
case MotionEvent.ACTION_UP:
invalidate ();
break;
}

Then @ Override
protected void onDraw (Canvas canvas) {
for (PointF point: pinfs) {
Here drawn characters move
}

}





Probably should be. . No experiments. . When will the trial. == !


Reply:
Amount.
Today achieved under

http://www.yoooo.org/?p=58
Reply:
reference to the third floor hijovi reply:
amount.
Today achieved under

http://www.yoooo.org/?p=58


Really good, more people to share it
Reply:
Learn. . .
Reply:
==! Actually been recommended
Source easy to put up for everyone to see. . .
 
class CustomView1 extends View {

private Paint paint;
private ArrayList graphics = new ArrayList ();
private Paint lPaint;
private Path mPath;
private int of = 0;
private Boolean over = false;
private float mX, mY; ​​
private static final float TOUCH_TOLERANCE = 4;

public CustomView1 (Context context) {
super (context);
paint = new Paint (Paint.ANTI_ALIAS_FLAG);
paint.setColor (Color.RED);
paint.setStrokeJoin (Paint.Join.ROUND);
paint.setStrokeCap ​​(Paint.Cap.ROUND);
paint.setStrokeWidth (65);

lPaint = new Paint (Paint.ANTI_ALIAS_FLAG);
lPaint.setColor (Color.BLACK);
lPaint.setStyle (Paint.Style.STROKE) ;/ / Hollow
lPaint.setStrokeJoin (Paint.Join.ROUND);
lPaint.setStrokeCap ​​(Paint.Cap.ROUND);
lPaint.setStrokeWidth (5);

mPath = new Path ();

}

@ Override
public boolean onTouchEvent (MotionEvent event) {
float x = event.getX ();
float y = event.getY ();
switch (event.getAction ()) {
case MotionEvent.ACTION_DOWN:
over = false;
graphics.clear ();
of = 0;
graphics.add (new PointF (x, y));
touch_start (x, y);
invalidate ();
break;
case MotionEvent.ACTION_MOVE:
graphics.add (new PointF (x, y));
touch_move (x, y);
invalidate ();
break;
case MotionEvent.ACTION_UP:
over = true;
touch_up ();
invalidate ();
break;
}

return true;
}

private void touch_start (float x, float y) {
mPath.reset ();
mPath.moveTo (x, y);
mX = x;
mY = y;
}
private void touch_move (float x, float y) {
float dx = Math.abs (x - mX);
float dy = Math.abs (y - mY);
if (dx> = TOUCH_TOLERANCE | | dy> = TOUCH_TOLERANCE) {
mPath.quadTo (mX, mY, (x + mX) / 2, (y + mY) / 2);
mX = x;
mY = y;
}
}
private void touch_up () {
mPath.lineTo (mX, mY);
}

@ Override
protected void onDraw (Canvas canvas) {
/ / Canvas.drawColor (Color.TRANSPARENT, Mode.CLEAR);
canvas.drawColor (Color.WHITE) ;/ / cleanup
canvas.drawPath (mPath, lPaint);
if (over && graphics.size ()> 0) {
canvas.drawPoint (graphics.get (of) x, graphics.get (of) y, paint..);
of + = 1;
if (of if (of == graphics.size () -1) {
Remove Line
after mPath.reset () ;/ / move completed}
invalidate ();
}
}
}
}

Reply:
Learn
Reply:
MARK learn about ・ ・ ・ ・ android slightly TREASURE HUNT!
Reply:
Andrews good learning! ! !
Reply:
Learn. . .
Reply:
Seemingly very powerful. Top of the
Reply:
Learning.
Reply:
Come on, support Andrews
Reply:
Passing, learning
Reply:
Master clouds ah. Are learning android development.
Reply:
Passing, but not
Reply:
The reply was deleted at the moderator 2011-09-01 10:18:41

Reply:
Learn. . .
Reply:
reference to the third floor hijovi reply:
amount.
Today achieved under

http://www.yoooo.org/?p=58

Good ~ ~
Reply:
Building learning accounting
Reply:
The reply was deleted at the moderator 2011-11-16 10:10:33

Reply:
Good support
Reply:
Just want to learn
Reply:
Really good!
Reply:
This is like watching the clear. Directly used or changed are convenient. Ha ha. Learn.
Reply:
Master eat!!!!!!!!!
Reply:
Master eat!!!!!!!!!
Reply:
reference to the 6th floor hijovi reply:
==! Actually been recommended
Source easy to put up for everyone to see. . .

Java code

class CustomView1 extends View {

private Paint paint;
private ArrayList graphics = new ArrayList ();
......


Last night did not come anxious to see it,,,, today, let's see,,,, thank you very much, ah,,,,,
Reply:
Ready to learn
Reply:
Good ・ ・ ・
Reply:
Passing a low-key access points. .
Reply:
Learn, mark what
Reply:
Low-key get points ...
Reply:
-,
First you have to rewrite onTouchEvent is
necessary
Then use a
Definition of private ArrayList pinfs = new ArrayList (); to keep it a point

In the onTouchEvent
Java code
switch (event.getAction ()) {
case MotionEvent.ACTION_DOWN:
pinfs.add (new PointF (event.getX (), event.getY ()));
break;
case MotionEvent.ACTION_MOVE:
pinfs.add (new PointF (event.getX (), event.getY ()));
break;
case MotionEvent.ACTION_UP:
invalidate ();
break;
}

Then @ Override
protected void onDraw (Canvas canvas) {
for (PointF point: pinfs) {
Here drawn characters move
}

}




Reply:
Really good!
Reply:
Passing, passing, learn, Dingding
Reply:
Understated score points, a lot of experts
Reply:
I have come to learn and get points
Reply:
The reply was deleted at the moderator 2011-09-19 11:53:31

Reply:
The reply was deleted at the moderator 2011-08-22 15:47:32

Reply:
Passing, to learn about.
Reply:
mark
Reply:
The reply was deleted at the moderator 2011-08-22 14:08:15

Reply:
The reply was deleted at the moderator 2011-08-22 14:08:47

Reply:
The reply was deleted at the moderator 2011-08-22 14:09:29

Reply:
onTouchEvent ();
Reply:
Learn Chung ah ・ ・
Reply:
Come on you hard top
Reply:
Learn, leave to score points
Reply:
To the force, learning

No comments:

Post a Comment