2010-08-28 68 views
0

我想知道什麼是最好的方式繪製背景圖像(這將是非常靜態的)和前景對象,這將根據Android中的用戶輸入移動?移動前景圖形的背景圖像

有點像側卷軸遊戲(當foregroudn對象需要動畫和改變比背景更多)。

TIA

回答

0

您可以使用setContentView將背景圖像設置爲主視圖。用於繪製前景圖像您可以使用擴展視圖的自定義類,並使用「onDraw」方法進行繪製。事情是這樣的:

class ForegroundImage extends View 
{ 
    public Foreground(Context ctx) {} 

    public void onDraw(Canvas c) 
    { 
     //here You draw image anything You want on canvas 
    } 
} 

ImageView lBackgroundImage = (ImageView)findViewById(R.id.BackgroundView); 
setContentView(lBackgrounImage); 
ForegroundImage lForegroundImage = new ForegroundImage(this); 
addContentView (lForegroundImage); 

我希望這有助於