以下のコードを使ってスクロールします Surfaceviewスレッドとオフキャンバステクスチャビットマップが生成(変更)され、最初の行(行)、フレームごとに1つの位置)を通常のサーフェイスビューのビットマップにスクロールしてスクロールしてから、その上に他のものを描き続けます。それは私が本当に欲しいものですが、オフスクリーンビットマップのために別のキャンバスを作成していても動作させることはできません。それはまったくスクロールしていないだけです。スクリーンメモリのビットマップをスクロールする方法
他の言葉私はメモリビットマップ、サーフェイスビューキャンバスと同じサイズを持っています。これは、フレームごとに1行下にスクロール(シフト)し、次にトップラインを新しいランダムテクスチャに置き換えてから、通常のサーフェイスビューキャンバス。
ここで私はうまくいくと思います。今、私のゲームトンネルを実行し、https://market.android.com/details?id=com.zubima.TunnelRunについて
@Override
public void run() {
while (running) {
c = null;
try {
// Lock canvas for drawing
c = myHolder.lockCanvas(null);
synchronized (mSurfaceHolder) {
// Scroll down off screen canvas and hopefully underlying bitmap bitmap
Rect src = new Rect(0, 0, intSurfaceWidth, intSurfaceHeight - 1);
Rect dst = new Rect(0, 1, intSurfaceWidth, intSurfaceHeight);
memCanvas.drawBitmap(memBitmap, src, dst, null);
// Note scrolling up like this works fine
// Rect src = new Rect(0, 1, intSurfaceWidth, intSurfaceHeight + 1);
// Rect dst = new Rect(0, 0, intSurfaceWidth, intSurfaceHeight);
// memCanvas.drawBitmap(memBitmap, src, dst, null);
// Create random one line(row) texture bitmap
textureBitmap = Bitmap.createBitmap(imgTexture, 0, rnd.nextInt(intTextureImageHeight), intSurfaceWidth, 1);
// Now add this texture bitmap to top of screen canvas and hopefully underlying bitmap
memCanvas.drawBitmap(textureBitmap,
intSurfaceWidth, 0, null);
// Draw above updated off screen bitmap to regular canvas, at least I thought it would update (save changes) shifting down and add the texture line to off screen bitmap the off screen canvas was pointing to.
c.drawBitmap(memBitmap, 0, 0, null);
// Other drawing to canvas comes here
} finally {
// do this in a finally so that if an exception is thrown
// during the above, we don't leave the Surface in an
// inconsistent state
if (c != null) {
myHolder.unlockCanvasAndPost(c);
}
}
}
}
:のみ不可欠真ん中を示す実行中の一部を
@Override
public void surfaceCreated(SurfaceHolder holder) {
intSurfaceWidth = mSurfaceView.getWidth();
intSurfaceHeight = mSurfaceView.getHeight();
memBitmap = Bitmap.createBitmap(intSurfaceWidth, intSurfaceHeight,
Bitmap.Config.ARGB_8888);
memCanvas = new Canvas(memCanvas);
myThread = new MyThread(holder, this);
myThread.setRunning(true);
blnPause = false;
myThread.start();
}
マイスレッド、:私はビットマップとキャンバスを指定し、スレッドを開始
マイsurfaceChanged私は代わりにビットマップの配列、表面の高さのサイズ、ランダムなテクスチャを設定した後、各フレームのループで下にシフトする作業ソリューションを持っています。私は毎秒50フレームを取得しますが、代わりにビットマップをスクロールしてよりうまくいくと思います。
完全なオフトピックですが、市場のアプリの説明はフルテキスト、段落なし、何もない...あなたはそれを構造化する必要があります!最初の考えは:tldr – WarrenFaith
良い提案、段落を追加しました。これはテキストのみのフィールドです。イメージを追加することはできません。 – DKDiveDude
本当ですが、あなたのテキストフォーマットはかなり醜いものでした。私は完全な "使用方法/演奏方法"ガイドを説明書には欲しくない。広告テキストのような感じがします。リストにいくつかのクールな機能を要約し、読者があなたのゲームに興味を持ってもらうようにします。 – WarrenFaith