本文介紹了Android沿路徑移動對象的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我已經創建了一個圓圈的路徑,并將它們都顯示在屏幕上,如下所示:
I ave created a path a circle and displayed both of them on screen as follows:
public void onDraw(Canvas canvas){
Path sPath = new Path();
sPath.moveTo(100, 100);
sPath.lineTo(300, 100);
sPath.lineTo(300, 300);
sPath.lineTo(100,300);
sPath.lineTo(100,100);
sPath.close();
Paint ballPaint = new Paint();
ballPaint.setColor(Color.GREEN);
Paint pathPaint = new Paint();
pathPaint.setColor(Color.BLUE);
canvas.drawPath(sPath, ballPaint);
canvas.drawCircle(100,100,20,pathPaint);
}
我想讓圓圈沿著路徑移動,我該怎么做?
i would like to have the circle move along the path, how can i do this?
推薦答案
你需要將你的圓圈每幀移動一點點朝向下一個航路點,并在它到達那里時進行檢測,然后開始向下一個航路點移動.據我所知,沒有內置系統.
You would need to move your circle a little bit each frame towards the next waypoint and detect once it gets there, then start moving toward the next. There is no built in system that I know of.
這篇關于Android沿路徑移動對象的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!