0
考慮兩個圓((0,0)爲中心,110和210分別爲半徑...如何使對象在圓形路徑中移動?
即我有CENTER爲(0,0)和CIRCLE 1半徑爲110和CIRCLE 2半徑爲210。 現在我需要在這兩個圈子之間移動一個物體tball。
這是我的代碼 -
public void run() {
while (isitok == true) {
// perform drawing
if (!holder.getSurface().isValid()) {
continue;
}
Canvas canvas = holder.lockCanvas();
canvas.drawARGB(255, 150, 150, 10);
// System.out.println("Canvas matrix -" + canvas.getm));
Paint p = new Paint();
// canvas.drawBitmap(tball, (x - tball.getWidth())/2,
// (y - tball.getHeight())/2, p);
p.setStyle(Paint.Style.STROKE);
p.setColor(Color.WHITE);
p.setColor(Color.parseColor("#0101DF"));
canvas.drawCircle(canvas.getWidth()/2,
canvas.getHeight()/2, 60, p);
canvas.drawCircle(canvas.getWidth()/2,
canvas.getHeight()/2, 110, p);
float x = (canvas.getWidth()/2) - (tball.getWidth()/2);
float y = (canvas.getHeight()/2) - 110 + (110 - 60)/2
- (tball.getHeight()/2);
canvas.drawBitmap(tball, x, y, p);
float movingpts[];
holder.unlockCanvasAndPost(canvas);
}
}
我想這個'public void run()':) –