'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
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:
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 ArrayListgraphics = 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 (ofif (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:
Reply:
Learn. . .
Reply:
Good ~ ~
Reply:
Building learning accounting
Reply:
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:
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
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:
Reply:
Reply:
Passing, to learn about.
Reply:
mark
Reply:
Reply:
Reply:
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