아이디어는 성격과 독립적으로 계산의 흔적을하는 것입니다 Windows에서 자바와 안드로이드 SDK (이클립스)를 사용하여 프로그래밍하고 잠시 후에
add_point_to_path (mPosX, mPosY);
으로 전화를 걸면 현재 스프라이트 위치가 경로에 추가됩니다.
mPathPaint를 변경하면 추측 할 수있는대로 경로의 종류를 사용자 정의 할 수 있습니다.
public void onDraw(Canvas canvas) {
// we draw our auxiliary bitmap that contains all the trails
canvas.drawBitmap (mTransparentBitmapForTrails, 0, 0, mTransparentBitmapPaint);
.
// then we draw the usual stuff, characters, etc...
canvas.drawBitmap (mCharacterBimap, mPosX, mPosY, mCharacterPaint);
.
.
}
// this creates a transparent background the size of the screen
// you will render trails here and they all will be painted at once in onDraw below the craracters
Bitmap mBitmapForTrails;
Canvas mCanvasForTrails;
public void initializeBitmapForTrails() {
mBitmapForTrails=new Bitmap(); // checkout how to create bitmaps with specific w&h, can't remember at the moment.
mCanvasForTrails=new Canvas(mBitmapForTrails); // we create a canvas to draw in that bitmap
}
// this will paint the trail in our secondary bitmap. This secondary bitmap doesn't get
// erased, so the drawTrail()'s are accumulative
public void drawTrail (int x, int y) {
mCanvasForTrails.drawBitmap(your_cool_trail_bitmap, x, y, mTrailPaint);
invalidate(); // this works, but for performance you'll later do invalidate(rect), so Android only repaints the changed portion of the bitmap. That rect will be the rectangle occupied by the trail bitmap. ie. (x,y,x+trailw,y+trialh)
}
그래서 모든 페인트합니다 또한,
또 다른 해결책은 모든 것을 아래에, 투명, 비트 맵을 만드는 것입니다
더 나은 솔루션 등 ... 호, 곡선을 추가 할 수 있습니다 그 비트 맵의 흔적. 이것은 성능에 전혀 영향을 미치지 않고 경로가 매우 복잡 할 수 있다는 장점이 있습니다.
트레일은 다른 스프라이트가 될 것입니다 – rupps
예 트레일은 또 다른 스프라이트가 될 것입니다. 현재 스프라이트가 비트 맵으로 변환되어 그려져 있지만 그 방법대로 작동하지 않습니다. – user3471603
캐릭터처럼 페인트해야합니다. 무엇이 문제입니까? – rupps