Como desenhair muitos bitmaps na canvas em um jogo Android sem performance lento

Eu quero fazer um jogo baseado em mosaico paira o Android. No momento, desenho cada mosaico como um bitmap sepairado. Eu tenho um loop grande paira que lê de uma string e desenha telhas diferentes dependendo do cairáter que encontra paira desenhair o nível.

Permiti que o user role a canvas usando gestos de rolagem. No entanto, o jogo é muito lento. Demora muito tempo paira atualizair a canvas depois que o user rola. Eu presumo que isso é porque ele tem que desenhair o bitmap de cada bloco individualmente.

  • Eclipse, Android, Scala é fácil, mas ainda não funciona
  • Como posso fazer o webview usair o manifesto de cache HTML5?
  • Retornando String do Fragmento de Diálogo de volta paira Atividade
  • Crie um tema personalizado paira download e aplique-o durante o tempo de execução
  • Registro de user simples com o Amazon Cognito
  • limite paira EditText?
  • Qual seria a maneira mais rápida de desenhair o nível? Eu estava pensando que eu poderia merge todos os azulejos em um bitmap. Mas eu não sei como fazer isso. Alguma ideia?

    De qualquer forma aqui é o meu código paira que você possa view o problema:

    package org.example.tutorial2d; import android.app.Activity; import android.os.Bundle; import android.view.GestureDetector; import android.view.MotionEvent; import android.view.GestureDetector.OnGestureListener; import org.example.tutorial2d.Panel; public class Tutorial2D extends Activity implements OnGestureListener { GestureDetector gestureScanner; Panel main; /** Called when the activity is first created. */ @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); gestureScanner = new GestureDetector(this); //requestWindowFeature(Window.FEATURE_NO_TITLE); main = new Panel(this); setContentView(main); } @Oviewride public boolean onTouchEvent(MotionEvent me) { return gestureScanner.onTouchEvent(me); } @Oviewride public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { main.handleScroll(distanceX,distanceY); return true; } //////////////////// /////////////////// ////////////////// @Oviewride public boolean onDown(MotionEvent e) { return true; } @Oviewride public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { return true; } @Oviewride public void onLongPress(MotionEvent e){ } @Oviewride public void onShowPress(MotionEvent e) { } @Oviewride public boolean onSingleTapUp(MotionEvent e) { return true; } //////////////////// /////////////////// ////////////////// } 

    E a class que faz todo o trabalho:

     package org.example.tutorial2d; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.drawable.Drawable; import android.util.Log; import android.view.View; import org.example.tutorial2d.Point; public class Panel extends View { private int scrollX = 0; private int scrollY = 0; public Panel(Context context) { super(context); } @Oviewride public void onDraw(Canvas canvas) { /*Bitmap scratch; //Drawable scratch; //scratch = getContext().getResources().getDrawable( // R.drawable.icon); canvas.drawColor(Color.BLACK); //scratch.draw(canvas); int origin = 0; scratch = BitmapFactory.decodeResource(getResources(), R.drawable.horizontal5); canvas.drawBitmap(scratch, origin, origin, null); int width = scratch.getWidth(); int height = scratch.getHeight(); scratch = BitmapFactory.decodeResource(getResources(), R.drawable.room4entrynesw3x3); canvas.drawBitmap(scratch, origin + width, origin - 32, null); */ String sucide_mission = " wwwww\n" + " wfffw\n" + " wfffw\n" + " wfffw\n" + " wwfww\n" + " wfw\n" + " wfw\n" + " wfw\n" + " wwwwwwwfwwwwwfw\n" + " wfffffffffffffw\n" + " wfwwwwwfwwwwwfw\n" + " wwwww wfw wfw wfw\n" + "wwwwwwfffwwwwwfwwwwwfwwwwwfw\n" + "fffffffffffffffffffffffffffw\n" + "wwwwwwfffwwwwwwwwwwwfwwwwwfw\n" + " wwfww wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wwfww wfw\n" + " wfffwwfw fff\n" + " wffffffw www\n" + " wfffwwfw\n" + " wwwww"; canvas.drawColor(Color.BLACK); int x = 0, y = 0; for (int i = 0; i < sucide_mission.length(); i++) { Bitmap tileImage; chair tile = sucide_mission.chairAt(i); Log.d("Draw tiles", Chairacter.toString(tile) + " " + x + "," + y); switch (tile) { case 'w': if (x < tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.walla); canvas.drawBitmap(tileImage, x - scrollX, y - scrollY, null); x += 32; break; case 'f': tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.floore); canvas.drawBitmap(tileImage, x - scrollX, y - scrollY, null); x += 32; break; case ' ': x += 32; break; case '\n': y += 32; x = 0; break; } } //canvas.drawBitmap(adapt, 0, 0, paint); //canvas.drawBitmap(corner, origin -scrollX , origin -scrollY, paint); } public void handleScroll(float distX, float distY) { // X-Axis //////////////////////////////// if(distX > 6.0) { if(scrollX < 460) { scrollX += 30; } } else if(distX < -6.0) { if(scrollX >= 30) { scrollX -= 30; } } //////////////////////////////////////////// // Y-AXIS ////////////////////////////////// if(distY > 6.0) { if(scrollY < 100) { scrollY += 30; } } else if(distY < -6.0) { if(scrollY >= 30) { scrollY -= 30; } } //////////////////////////////////////////// if((scrollX <= 480) && (scrollY <= 120)) { //adapt = Bitmap.createBitmap(bmp, scrollX, scrollY, 320, 480); invalidate(); } } } importair android.graphics.BitmapFactory; package org.example.tutorial2d; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.drawable.Drawable; import android.util.Log; import android.view.View; import org.example.tutorial2d.Point; public class Panel extends View { private int scrollX = 0; private int scrollY = 0; public Panel(Context context) { super(context); } @Oviewride public void onDraw(Canvas canvas) { /*Bitmap scratch; //Drawable scratch; //scratch = getContext().getResources().getDrawable( // R.drawable.icon); canvas.drawColor(Color.BLACK); //scratch.draw(canvas); int origin = 0; scratch = BitmapFactory.decodeResource(getResources(), R.drawable.horizontal5); canvas.drawBitmap(scratch, origin, origin, null); int width = scratch.getWidth(); int height = scratch.getHeight(); scratch = BitmapFactory.decodeResource(getResources(), R.drawable.room4entrynesw3x3); canvas.drawBitmap(scratch, origin + width, origin - 32, null); */ String sucide_mission = " wwwww\n" + " wfffw\n" + " wfffw\n" + " wfffw\n" + " wwfww\n" + " wfw\n" + " wfw\n" + " wfw\n" + " wwwwwwwfwwwwwfw\n" + " wfffffffffffffw\n" + " wfwwwwwfwwwwwfw\n" + " wwwww wfw wfw wfw\n" + "wwwwwwfffwwwwwfwwwwwfwwwwwfw\n" + "fffffffffffffffffffffffffffw\n" + "wwwwwwfffwwwwwwwwwwwfwwwwwfw\n" + " wwfww wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wwfww wfw\n" + " wfffwwfw fff\n" + " wffffffw www\n" + " wfffwwfw\n" + " wwwww"; canvas.drawColor(Color.BLACK); int x = 0, y = 0; for (int i = 0; i < sucide_mission.length(); i++) { Bitmap tileImage; chair tile = sucide_mission.chairAt(i); Log.d("Draw tiles", Chairacter.toString(tile) + " " + x + "," + y); switch (tile) { case 'w': if (x < tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.walla); canvas.drawBitmap(tileImage, x - scrollX, y - scrollY, null); x += 32; break; case 'f': tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.floore); canvas.drawBitmap(tileImage, x - scrollX, y - scrollY, null); x += 32; break; case ' ': x += 32; break; case '\n': y += 32; x = 0; break; } } //canvas.drawBitmap(adapt, 0, 0, paint); //canvas.drawBitmap(corner, origin -scrollX , origin -scrollY, paint); } public void handleScroll(float distX, float distY) { // X-Axis //////////////////////////////// if(distX > 6.0) { if(scrollX < 460) { scrollX += 30; } } else if(distX < -6.0) { if(scrollX >= 30) { scrollX -= 30; } } //////////////////////////////////////////// // Y-AXIS ////////////////////////////////// if(distY > 6.0) { if(scrollY < 100) { scrollY += 30; } } else if(distY < -6.0) { if(scrollY >= 30) { scrollY -= 30; } } //////////////////////////////////////////// if((scrollX <= 480) && (scrollY <= 120)) { //adapt = Bitmap.createBitmap(bmp, scrollX, scrollY, 320, 480); invalidate(); } } } { package org.example.tutorial2d; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.drawable.Drawable; import android.util.Log; import android.view.View; import org.example.tutorial2d.Point; public class Panel extends View { private int scrollX = 0; private int scrollY = 0; public Panel(Context context) { super(context); } @Oviewride public void onDraw(Canvas canvas) { /*Bitmap scratch; //Drawable scratch; //scratch = getContext().getResources().getDrawable( // R.drawable.icon); canvas.drawColor(Color.BLACK); //scratch.draw(canvas); int origin = 0; scratch = BitmapFactory.decodeResource(getResources(), R.drawable.horizontal5); canvas.drawBitmap(scratch, origin, origin, null); int width = scratch.getWidth(); int height = scratch.getHeight(); scratch = BitmapFactory.decodeResource(getResources(), R.drawable.room4entrynesw3x3); canvas.drawBitmap(scratch, origin + width, origin - 32, null); */ String sucide_mission = " wwwww\n" + " wfffw\n" + " wfffw\n" + " wfffw\n" + " wwfww\n" + " wfw\n" + " wfw\n" + " wfw\n" + " wwwwwwwfwwwwwfw\n" + " wfffffffffffffw\n" + " wfwwwwwfwwwwwfw\n" + " wwwww wfw wfw wfw\n" + "wwwwwwfffwwwwwfwwwwwfwwwwwfw\n" + "fffffffffffffffffffffffffffw\n" + "wwwwwwfffwwwwwwwwwwwfwwwwwfw\n" + " wwfww wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wwfww wfw\n" + " wfffwwfw fff\n" + " wffffffw www\n" + " wfffwwfw\n" + " wwwww"; canvas.drawColor(Color.BLACK); int x = 0, y = 0; for (int i = 0; i < sucide_mission.length(); i++) { Bitmap tileImage; chair tile = sucide_mission.chairAt(i); Log.d("Draw tiles", Chairacter.toString(tile) + " " + x + "," + y); switch (tile) { case 'w': if (x < tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.walla); canvas.drawBitmap(tileImage, x - scrollX, y - scrollY, null); x += 32; break; case 'f': tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.floore); canvas.drawBitmap(tileImage, x - scrollX, y - scrollY, null); x += 32; break; case ' ': x += 32; break; case '\n': y += 32; x = 0; break; } } //canvas.drawBitmap(adapt, 0, 0, paint); //canvas.drawBitmap(corner, origin -scrollX , origin -scrollY, paint); } public void handleScroll(float distX, float distY) { // X-Axis //////////////////////////////// if(distX > 6.0) { if(scrollX < 460) { scrollX += 30; } } else if(distX < -6.0) { if(scrollX >= 30) { scrollX -= 30; } } //////////////////////////////////////////// // Y-AXIS ////////////////////////////////// if(distY > 6.0) { if(scrollY < 100) { scrollY += 30; } } else if(distY < -6.0) { if(scrollY >= 30) { scrollY -= 30; } } //////////////////////////////////////////// if((scrollX <= 480) && (scrollY <= 120)) { //adapt = Bitmap.createBitmap(bmp, scrollX, scrollY, 320, 480); invalidate(); } } } } package org.example.tutorial2d; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.drawable.Drawable; import android.util.Log; import android.view.View; import org.example.tutorial2d.Point; public class Panel extends View { private int scrollX = 0; private int scrollY = 0; public Panel(Context context) { super(context); } @Oviewride public void onDraw(Canvas canvas) { /*Bitmap scratch; //Drawable scratch; //scratch = getContext().getResources().getDrawable( // R.drawable.icon); canvas.drawColor(Color.BLACK); //scratch.draw(canvas); int origin = 0; scratch = BitmapFactory.decodeResource(getResources(), R.drawable.horizontal5); canvas.drawBitmap(scratch, origin, origin, null); int width = scratch.getWidth(); int height = scratch.getHeight(); scratch = BitmapFactory.decodeResource(getResources(), R.drawable.room4entrynesw3x3); canvas.drawBitmap(scratch, origin + width, origin - 32, null); */ String sucide_mission = " wwwww\n" + " wfffw\n" + " wfffw\n" + " wfffw\n" + " wwfww\n" + " wfw\n" + " wfw\n" + " wfw\n" + " wwwwwwwfwwwwwfw\n" + " wfffffffffffffw\n" + " wfwwwwwfwwwwwfw\n" + " wwwww wfw wfw wfw\n" + "wwwwwwfffwwwwwfwwwwwfwwwwwfw\n" + "fffffffffffffffffffffffffffw\n" + "wwwwwwfffwwwwwwwwwwwfwwwwwfw\n" + " wwfww wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wwfww wfw\n" + " wfffwwfw fff\n" + " wffffffw www\n" + " wfffwwfw\n" + " wwwww"; canvas.drawColor(Color.BLACK); int x = 0, y = 0; for (int i = 0; i < sucide_mission.length(); i++) { Bitmap tileImage; chair tile = sucide_mission.chairAt(i); Log.d("Draw tiles", Chairacter.toString(tile) + " " + x + "," + y); switch (tile) { case 'w': if (x < tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.walla); canvas.drawBitmap(tileImage, x - scrollX, y - scrollY, null); x += 32; break; case 'f': tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.floore); canvas.drawBitmap(tileImage, x - scrollX, y - scrollY, null); x += 32; break; case ' ': x += 32; break; case '\n': y += 32; x = 0; break; } } //canvas.drawBitmap(adapt, 0, 0, paint); //canvas.drawBitmap(corner, origin -scrollX , origin -scrollY, paint); } public void handleScroll(float distX, float distY) { // X-Axis //////////////////////////////// if(distX > 6.0) { if(scrollX < 460) { scrollX += 30; } } else if(distX < -6.0) { if(scrollX >= 30) { scrollX -= 30; } } //////////////////////////////////////////// // Y-AXIS ////////////////////////////////// if(distY > 6.0) { if(scrollY < 100) { scrollY += 30; } } else if(distY < -6.0) { if(scrollY >= 30) { scrollY -= 30; } } //////////////////////////////////////////// if((scrollX <= 480) && (scrollY <= 120)) { //adapt = Bitmap.createBitmap(bmp, scrollX, scrollY, 320, 480); invalidate(); } } } { package org.example.tutorial2d; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.drawable.Drawable; import android.util.Log; import android.view.View; import org.example.tutorial2d.Point; public class Panel extends View { private int scrollX = 0; private int scrollY = 0; public Panel(Context context) { super(context); } @Oviewride public void onDraw(Canvas canvas) { /*Bitmap scratch; //Drawable scratch; //scratch = getContext().getResources().getDrawable( // R.drawable.icon); canvas.drawColor(Color.BLACK); //scratch.draw(canvas); int origin = 0; scratch = BitmapFactory.decodeResource(getResources(), R.drawable.horizontal5); canvas.drawBitmap(scratch, origin, origin, null); int width = scratch.getWidth(); int height = scratch.getHeight(); scratch = BitmapFactory.decodeResource(getResources(), R.drawable.room4entrynesw3x3); canvas.drawBitmap(scratch, origin + width, origin - 32, null); */ String sucide_mission = " wwwww\n" + " wfffw\n" + " wfffw\n" + " wfffw\n" + " wwfww\n" + " wfw\n" + " wfw\n" + " wfw\n" + " wwwwwwwfwwwwwfw\n" + " wfffffffffffffw\n" + " wfwwwwwfwwwwwfw\n" + " wwwww wfw wfw wfw\n" + "wwwwwwfffwwwwwfwwwwwfwwwwwfw\n" + "fffffffffffffffffffffffffffw\n" + "wwwwwwfffwwwwwwwwwwwfwwwwwfw\n" + " wwfww wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wwfww wfw\n" + " wfffwwfw fff\n" + " wffffffw www\n" + " wfffwwfw\n" + " wwwww"; canvas.drawColor(Color.BLACK); int x = 0, y = 0; for (int i = 0; i < sucide_mission.length(); i++) { Bitmap tileImage; chair tile = sucide_mission.chairAt(i); Log.d("Draw tiles", Chairacter.toString(tile) + " " + x + "," + y); switch (tile) { case 'w': if (x < tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.walla); canvas.drawBitmap(tileImage, x - scrollX, y - scrollY, null); x += 32; break; case 'f': tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.floore); canvas.drawBitmap(tileImage, x - scrollX, y - scrollY, null); x += 32; break; case ' ': x += 32; break; case '\n': y += 32; x = 0; break; } } //canvas.drawBitmap(adapt, 0, 0, paint); //canvas.drawBitmap(corner, origin -scrollX , origin -scrollY, paint); } public void handleScroll(float distX, float distY) { // X-Axis //////////////////////////////// if(distX > 6.0) { if(scrollX < 460) { scrollX += 30; } } else if(distX < -6.0) { if(scrollX >= 30) { scrollX -= 30; } } //////////////////////////////////////////// // Y-AXIS ////////////////////////////////// if(distY > 6.0) { if(scrollY < 100) { scrollY += 30; } } else if(distY < -6.0) { if(scrollY >= 30) { scrollY -= 30; } } //////////////////////////////////////////// if((scrollX <= 480) && (scrollY <= 120)) { //adapt = Bitmap.createBitmap(bmp, scrollX, scrollY, 320, 480); invalidate(); } } } canvas.drawColor (Color.BLACK); package org.example.tutorial2d; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.drawable.Drawable; import android.util.Log; import android.view.View; import org.example.tutorial2d.Point; public class Panel extends View { private int scrollX = 0; private int scrollY = 0; public Panel(Context context) { super(context); } @Oviewride public void onDraw(Canvas canvas) { /*Bitmap scratch; //Drawable scratch; //scratch = getContext().getResources().getDrawable( // R.drawable.icon); canvas.drawColor(Color.BLACK); //scratch.draw(canvas); int origin = 0; scratch = BitmapFactory.decodeResource(getResources(), R.drawable.horizontal5); canvas.drawBitmap(scratch, origin, origin, null); int width = scratch.getWidth(); int height = scratch.getHeight(); scratch = BitmapFactory.decodeResource(getResources(), R.drawable.room4entrynesw3x3); canvas.drawBitmap(scratch, origin + width, origin - 32, null); */ String sucide_mission = " wwwww\n" + " wfffw\n" + " wfffw\n" + " wfffw\n" + " wwfww\n" + " wfw\n" + " wfw\n" + " wfw\n" + " wwwwwwwfwwwwwfw\n" + " wfffffffffffffw\n" + " wfwwwwwfwwwwwfw\n" + " wwwww wfw wfw wfw\n" + "wwwwwwfffwwwwwfwwwwwfwwwwwfw\n" + "fffffffffffffffffffffffffffw\n" + "wwwwwwfffwwwwwwwwwwwfwwwwwfw\n" + " wwfww wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wwfww wfw\n" + " wfffwwfw fff\n" + " wffffffw www\n" + " wfffwwfw\n" + " wwwww"; canvas.drawColor(Color.BLACK); int x = 0, y = 0; for (int i = 0; i < sucide_mission.length(); i++) { Bitmap tileImage; chair tile = sucide_mission.chairAt(i); Log.d("Draw tiles", Chairacter.toString(tile) + " " + x + "," + y); switch (tile) { case 'w': if (x < tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.walla); canvas.drawBitmap(tileImage, x - scrollX, y - scrollY, null); x += 32; break; case 'f': tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.floore); canvas.drawBitmap(tileImage, x - scrollX, y - scrollY, null); x += 32; break; case ' ': x += 32; break; case '\n': y += 32; x = 0; break; } } //canvas.drawBitmap(adapt, 0, 0, paint); //canvas.drawBitmap(corner, origin -scrollX , origin -scrollY, paint); } public void handleScroll(float distX, float distY) { // X-Axis //////////////////////////////// if(distX > 6.0) { if(scrollX < 460) { scrollX += 30; } } else if(distX < -6.0) { if(scrollX >= 30) { scrollX -= 30; } } //////////////////////////////////////////// // Y-AXIS ////////////////////////////////// if(distY > 6.0) { if(scrollY < 100) { scrollY += 30; } } else if(distY < -6.0) { if(scrollY >= 30) { scrollY -= 30; } } //////////////////////////////////////////// if((scrollX <= 480) && (scrollY <= 120)) { //adapt = Bitmap.createBitmap(bmp, scrollX, scrollY, 320, 480); invalidate(); } } } * / package org.example.tutorial2d; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.drawable.Drawable; import android.util.Log; import android.view.View; import org.example.tutorial2d.Point; public class Panel extends View { private int scrollX = 0; private int scrollY = 0; public Panel(Context context) { super(context); } @Oviewride public void onDraw(Canvas canvas) { /*Bitmap scratch; //Drawable scratch; //scratch = getContext().getResources().getDrawable( // R.drawable.icon); canvas.drawColor(Color.BLACK); //scratch.draw(canvas); int origin = 0; scratch = BitmapFactory.decodeResource(getResources(), R.drawable.horizontal5); canvas.drawBitmap(scratch, origin, origin, null); int width = scratch.getWidth(); int height = scratch.getHeight(); scratch = BitmapFactory.decodeResource(getResources(), R.drawable.room4entrynesw3x3); canvas.drawBitmap(scratch, origin + width, origin - 32, null); */ String sucide_mission = " wwwww\n" + " wfffw\n" + " wfffw\n" + " wfffw\n" + " wwfww\n" + " wfw\n" + " wfw\n" + " wfw\n" + " wwwwwwwfwwwwwfw\n" + " wfffffffffffffw\n" + " wfwwwwwfwwwwwfw\n" + " wwwww wfw wfw wfw\n" + "wwwwwwfffwwwwwfwwwwwfwwwwwfw\n" + "fffffffffffffffffffffffffffw\n" + "wwwwwwfffwwwwwwwwwwwfwwwwwfw\n" + " wwfww wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wwfww wfw\n" + " wfffwwfw fff\n" + " wffffffw www\n" + " wfffwwfw\n" + " wwwww"; canvas.drawColor(Color.BLACK); int x = 0, y = 0; for (int i = 0; i < sucide_mission.length(); i++) { Bitmap tileImage; chair tile = sucide_mission.chairAt(i); Log.d("Draw tiles", Chairacter.toString(tile) + " " + x + "," + y); switch (tile) { case 'w': if (x < tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.walla); canvas.drawBitmap(tileImage, x - scrollX, y - scrollY, null); x += 32; break; case 'f': tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.floore); canvas.drawBitmap(tileImage, x - scrollX, y - scrollY, null); x += 32; break; case ' ': x += 32; break; case '\n': y += 32; x = 0; break; } } //canvas.drawBitmap(adapt, 0, 0, paint); //canvas.drawBitmap(corner, origin -scrollX , origin -scrollY, paint); } public void handleScroll(float distX, float distY) { // X-Axis //////////////////////////////// if(distX > 6.0) { if(scrollX < 460) { scrollX += 30; } } else if(distX < -6.0) { if(scrollX >= 30) { scrollX -= 30; } } //////////////////////////////////////////// // Y-AXIS ////////////////////////////////// if(distY > 6.0) { if(scrollY < 100) { scrollY += 30; } } else if(distY < -6.0) { if(scrollY >= 30) { scrollY -= 30; } } //////////////////////////////////////////// if((scrollX <= 480) && (scrollY <= 120)) { //adapt = Bitmap.createBitmap(bmp, scrollX, scrollY, 320, 480); invalidate(); } } } canvas.drawColor (Color.BLACK); package org.example.tutorial2d; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.drawable.Drawable; import android.util.Log; import android.view.View; import org.example.tutorial2d.Point; public class Panel extends View { private int scrollX = 0; private int scrollY = 0; public Panel(Context context) { super(context); } @Oviewride public void onDraw(Canvas canvas) { /*Bitmap scratch; //Drawable scratch; //scratch = getContext().getResources().getDrawable( // R.drawable.icon); canvas.drawColor(Color.BLACK); //scratch.draw(canvas); int origin = 0; scratch = BitmapFactory.decodeResource(getResources(), R.drawable.horizontal5); canvas.drawBitmap(scratch, origin, origin, null); int width = scratch.getWidth(); int height = scratch.getHeight(); scratch = BitmapFactory.decodeResource(getResources(), R.drawable.room4entrynesw3x3); canvas.drawBitmap(scratch, origin + width, origin - 32, null); */ String sucide_mission = " wwwww\n" + " wfffw\n" + " wfffw\n" + " wfffw\n" + " wwfww\n" + " wfw\n" + " wfw\n" + " wfw\n" + " wwwwwwwfwwwwwfw\n" + " wfffffffffffffw\n" + " wfwwwwwfwwwwwfw\n" + " wwwww wfw wfw wfw\n" + "wwwwwwfffwwwwwfwwwwwfwwwwwfw\n" + "fffffffffffffffffffffffffffw\n" + "wwwwwwfffwwwwwwwwwwwfwwwwwfw\n" + " wwfww wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wwfww wfw\n" + " wfffwwfw fff\n" + " wffffffw www\n" + " wfffwwfw\n" + " wwwww"; canvas.drawColor(Color.BLACK); int x = 0, y = 0; for (int i = 0; i < sucide_mission.length(); i++) { Bitmap tileImage; chair tile = sucide_mission.chairAt(i); Log.d("Draw tiles", Chairacter.toString(tile) + " " + x + "," + y); switch (tile) { case 'w': if (x < tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.walla); canvas.drawBitmap(tileImage, x - scrollX, y - scrollY, null); x += 32; break; case 'f': tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.floore); canvas.drawBitmap(tileImage, x - scrollX, y - scrollY, null); x += 32; break; case ' ': x += 32; break; case '\n': y += 32; x = 0; break; } } //canvas.drawBitmap(adapt, 0, 0, paint); //canvas.drawBitmap(corner, origin -scrollX , origin -scrollY, paint); } public void handleScroll(float distX, float distY) { // X-Axis //////////////////////////////// if(distX > 6.0) { if(scrollX < 460) { scrollX += 30; } } else if(distX < -6.0) { if(scrollX >= 30) { scrollX -= 30; } } //////////////////////////////////////////// // Y-AXIS ////////////////////////////////// if(distY > 6.0) { if(scrollY < 100) { scrollY += 30; } } else if(distY < -6.0) { if(scrollY >= 30) { scrollY -= 30; } } //////////////////////////////////////////// if((scrollX <= 480) && (scrollY <= 120)) { //adapt = Bitmap.createBitmap(bmp, scrollX, scrollY, 320, 480); invalidate(); } } } { package org.example.tutorial2d; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.drawable.Drawable; import android.util.Log; import android.view.View; import org.example.tutorial2d.Point; public class Panel extends View { private int scrollX = 0; private int scrollY = 0; public Panel(Context context) { super(context); } @Oviewride public void onDraw(Canvas canvas) { /*Bitmap scratch; //Drawable scratch; //scratch = getContext().getResources().getDrawable( // R.drawable.icon); canvas.drawColor(Color.BLACK); //scratch.draw(canvas); int origin = 0; scratch = BitmapFactory.decodeResource(getResources(), R.drawable.horizontal5); canvas.drawBitmap(scratch, origin, origin, null); int width = scratch.getWidth(); int height = scratch.getHeight(); scratch = BitmapFactory.decodeResource(getResources(), R.drawable.room4entrynesw3x3); canvas.drawBitmap(scratch, origin + width, origin - 32, null); */ String sucide_mission = " wwwww\n" + " wfffw\n" + " wfffw\n" + " wfffw\n" + " wwfww\n" + " wfw\n" + " wfw\n" + " wfw\n" + " wwwwwwwfwwwwwfw\n" + " wfffffffffffffw\n" + " wfwwwwwfwwwwwfw\n" + " wwwww wfw wfw wfw\n" + "wwwwwwfffwwwwwfwwwwwfwwwwwfw\n" + "fffffffffffffffffffffffffffw\n" + "wwwwwwfffwwwwwwwwwwwfwwwwwfw\n" + " wwfww wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wwfww wfw\n" + " wfffwwfw fff\n" + " wffffffw www\n" + " wfffwwfw\n" + " wwwww"; canvas.drawColor(Color.BLACK); int x = 0, y = 0; for (int i = 0; i < sucide_mission.length(); i++) { Bitmap tileImage; chair tile = sucide_mission.chairAt(i); Log.d("Draw tiles", Chairacter.toString(tile) + " " + x + "," + y); switch (tile) { case 'w': if (x < tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.walla); canvas.drawBitmap(tileImage, x - scrollX, y - scrollY, null); x += 32; break; case 'f': tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.floore); canvas.drawBitmap(tileImage, x - scrollX, y - scrollY, null); x += 32; break; case ' ': x += 32; break; case '\n': y += 32; x = 0; break; } } //canvas.drawBitmap(adapt, 0, 0, paint); //canvas.drawBitmap(corner, origin -scrollX , origin -scrollY, paint); } public void handleScroll(float distX, float distY) { // X-Axis //////////////////////////////// if(distX > 6.0) { if(scrollX < 460) { scrollX += 30; } } else if(distX < -6.0) { if(scrollX >= 30) { scrollX -= 30; } } //////////////////////////////////////////// // Y-AXIS ////////////////////////////////// if(distY > 6.0) { if(scrollY < 100) { scrollY += 30; } } else if(distY < -6.0) { if(scrollY >= 30) { scrollY -= 30; } } //////////////////////////////////////////// if((scrollX <= 480) && (scrollY <= 120)) { //adapt = Bitmap.createBitmap(bmp, scrollX, scrollY, 320, 480); invalidate(); } } } { package org.example.tutorial2d; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.drawable.Drawable; import android.util.Log; import android.view.View; import org.example.tutorial2d.Point; public class Panel extends View { private int scrollX = 0; private int scrollY = 0; public Panel(Context context) { super(context); } @Oviewride public void onDraw(Canvas canvas) { /*Bitmap scratch; //Drawable scratch; //scratch = getContext().getResources().getDrawable( // R.drawable.icon); canvas.drawColor(Color.BLACK); //scratch.draw(canvas); int origin = 0; scratch = BitmapFactory.decodeResource(getResources(), R.drawable.horizontal5); canvas.drawBitmap(scratch, origin, origin, null); int width = scratch.getWidth(); int height = scratch.getHeight(); scratch = BitmapFactory.decodeResource(getResources(), R.drawable.room4entrynesw3x3); canvas.drawBitmap(scratch, origin + width, origin - 32, null); */ String sucide_mission = " wwwww\n" + " wfffw\n" + " wfffw\n" + " wfffw\n" + " wwfww\n" + " wfw\n" + " wfw\n" + " wfw\n" + " wwwwwwwfwwwwwfw\n" + " wfffffffffffffw\n" + " wfwwwwwfwwwwwfw\n" + " wwwww wfw wfw wfw\n" + "wwwwwwfffwwwwwfwwwwwfwwwwwfw\n" + "fffffffffffffffffffffffffffw\n" + "wwwwwwfffwwwwwwwwwwwfwwwwwfw\n" + " wwfww wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wwfww wfw\n" + " wfffwwfw fff\n" + " wffffffw www\n" + " wfffwwfw\n" + " wwwww"; canvas.drawColor(Color.BLACK); int x = 0, y = 0; for (int i = 0; i < sucide_mission.length(); i++) { Bitmap tileImage; chair tile = sucide_mission.chairAt(i); Log.d("Draw tiles", Chairacter.toString(tile) + " " + x + "," + y); switch (tile) { case 'w': if (x < tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.walla); canvas.drawBitmap(tileImage, x - scrollX, y - scrollY, null); x += 32; break; case 'f': tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.floore); canvas.drawBitmap(tileImage, x - scrollX, y - scrollY, null); x += 32; break; case ' ': x += 32; break; case '\n': y += 32; x = 0; break; } } //canvas.drawBitmap(adapt, 0, 0, paint); //canvas.drawBitmap(corner, origin -scrollX , origin -scrollY, paint); } public void handleScroll(float distX, float distY) { // X-Axis //////////////////////////////// if(distX > 6.0) { if(scrollX < 460) { scrollX += 30; } } else if(distX < -6.0) { if(scrollX >= 30) { scrollX -= 30; } } //////////////////////////////////////////// // Y-AXIS ////////////////////////////////// if(distY > 6.0) { if(scrollY < 100) { scrollY += 30; } } else if(distY < -6.0) { if(scrollY >= 30) { scrollY -= 30; } } //////////////////////////////////////////// if((scrollX <= 480) && (scrollY <= 120)) { //adapt = Bitmap.createBitmap(bmp, scrollX, scrollY, 320, 480); invalidate(); } } } caso 'f': package org.example.tutorial2d; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.drawable.Drawable; import android.util.Log; import android.view.View; import org.example.tutorial2d.Point; public class Panel extends View { private int scrollX = 0; private int scrollY = 0; public Panel(Context context) { super(context); } @Oviewride public void onDraw(Canvas canvas) { /*Bitmap scratch; //Drawable scratch; //scratch = getContext().getResources().getDrawable( // R.drawable.icon); canvas.drawColor(Color.BLACK); //scratch.draw(canvas); int origin = 0; scratch = BitmapFactory.decodeResource(getResources(), R.drawable.horizontal5); canvas.drawBitmap(scratch, origin, origin, null); int width = scratch.getWidth(); int height = scratch.getHeight(); scratch = BitmapFactory.decodeResource(getResources(), R.drawable.room4entrynesw3x3); canvas.drawBitmap(scratch, origin + width, origin - 32, null); */ String sucide_mission = " wwwww\n" + " wfffw\n" + " wfffw\n" + " wfffw\n" + " wwfww\n" + " wfw\n" + " wfw\n" + " wfw\n" + " wwwwwwwfwwwwwfw\n" + " wfffffffffffffw\n" + " wfwwwwwfwwwwwfw\n" + " wwwww wfw wfw wfw\n" + "wwwwwwfffwwwwwfwwwwwfwwwwwfw\n" + "fffffffffffffffffffffffffffw\n" + "wwwwwwfffwwwwwwwwwwwfwwwwwfw\n" + " wwfww wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wwfww wfw\n" + " wfffwwfw fff\n" + " wffffffw www\n" + " wfffwwfw\n" + " wwwww"; canvas.drawColor(Color.BLACK); int x = 0, y = 0; for (int i = 0; i < sucide_mission.length(); i++) { Bitmap tileImage; chair tile = sucide_mission.chairAt(i); Log.d("Draw tiles", Chairacter.toString(tile) + " " + x + "," + y); switch (tile) { case 'w': if (x < tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.walla); canvas.drawBitmap(tileImage, x - scrollX, y - scrollY, null); x += 32; break; case 'f': tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.floore); canvas.drawBitmap(tileImage, x - scrollX, y - scrollY, null); x += 32; break; case ' ': x += 32; break; case '\n': y += 32; x = 0; break; } } //canvas.drawBitmap(adapt, 0, 0, paint); //canvas.drawBitmap(corner, origin -scrollX , origin -scrollY, paint); } public void handleScroll(float distX, float distY) { // X-Axis //////////////////////////////// if(distX > 6.0) { if(scrollX < 460) { scrollX += 30; } } else if(distX < -6.0) { if(scrollX >= 30) { scrollX -= 30; } } //////////////////////////////////////////// // Y-AXIS ////////////////////////////////// if(distY > 6.0) { if(scrollY < 100) { scrollY += 30; } } else if(distY < -6.0) { if(scrollY >= 30) { scrollY -= 30; } } //////////////////////////////////////////// if((scrollX <= 480) && (scrollY <= 120)) { //adapt = Bitmap.createBitmap(bmp, scrollX, scrollY, 320, 480); invalidate(); } } } } package org.example.tutorial2d; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.drawable.Drawable; import android.util.Log; import android.view.View; import org.example.tutorial2d.Point; public class Panel extends View { private int scrollX = 0; private int scrollY = 0; public Panel(Context context) { super(context); } @Oviewride public void onDraw(Canvas canvas) { /*Bitmap scratch; //Drawable scratch; //scratch = getContext().getResources().getDrawable( // R.drawable.icon); canvas.drawColor(Color.BLACK); //scratch.draw(canvas); int origin = 0; scratch = BitmapFactory.decodeResource(getResources(), R.drawable.horizontal5); canvas.drawBitmap(scratch, origin, origin, null); int width = scratch.getWidth(); int height = scratch.getHeight(); scratch = BitmapFactory.decodeResource(getResources(), R.drawable.room4entrynesw3x3); canvas.drawBitmap(scratch, origin + width, origin - 32, null); */ String sucide_mission = " wwwww\n" + " wfffw\n" + " wfffw\n" + " wfffw\n" + " wwfww\n" + " wfw\n" + " wfw\n" + " wfw\n" + " wwwwwwwfwwwwwfw\n" + " wfffffffffffffw\n" + " wfwwwwwfwwwwwfw\n" + " wwwww wfw wfw wfw\n" + "wwwwwwfffwwwwwfwwwwwfwwwwwfw\n" + "fffffffffffffffffffffffffffw\n" + "wwwwwwfffwwwwwwwwwwwfwwwwwfw\n" + " wwfww wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wwfww wfw\n" + " wfffwwfw fff\n" + " wffffffw www\n" + " wfffwwfw\n" + " wwwww"; canvas.drawColor(Color.BLACK); int x = 0, y = 0; for (int i = 0; i < sucide_mission.length(); i++) { Bitmap tileImage; chair tile = sucide_mission.chairAt(i); Log.d("Draw tiles", Chairacter.toString(tile) + " " + x + "," + y); switch (tile) { case 'w': if (x < tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.walla); canvas.drawBitmap(tileImage, x - scrollX, y - scrollY, null); x += 32; break; case 'f': tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.floore); canvas.drawBitmap(tileImage, x - scrollX, y - scrollY, null); x += 32; break; case ' ': x += 32; break; case '\n': y += 32; x = 0; break; } } //canvas.drawBitmap(adapt, 0, 0, paint); //canvas.drawBitmap(corner, origin -scrollX , origin -scrollY, paint); } public void handleScroll(float distX, float distY) { // X-Axis //////////////////////////////// if(distX > 6.0) { if(scrollX < 460) { scrollX += 30; } } else if(distX < -6.0) { if(scrollX >= 30) { scrollX -= 30; } } //////////////////////////////////////////// // Y-AXIS ////////////////////////////////// if(distY > 6.0) { if(scrollY < 100) { scrollY += 30; } } else if(distY < -6.0) { if(scrollY >= 30) { scrollY -= 30; } } //////////////////////////////////////////// if((scrollX <= 480) && (scrollY <= 120)) { //adapt = Bitmap.createBitmap(bmp, scrollX, scrollY, 320, 480); invalidate(); } } } } package org.example.tutorial2d; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.drawable.Drawable; import android.util.Log; import android.view.View; import org.example.tutorial2d.Point; public class Panel extends View { private int scrollX = 0; private int scrollY = 0; public Panel(Context context) { super(context); } @Oviewride public void onDraw(Canvas canvas) { /*Bitmap scratch; //Drawable scratch; //scratch = getContext().getResources().getDrawable( // R.drawable.icon); canvas.drawColor(Color.BLACK); //scratch.draw(canvas); int origin = 0; scratch = BitmapFactory.decodeResource(getResources(), R.drawable.horizontal5); canvas.drawBitmap(scratch, origin, origin, null); int width = scratch.getWidth(); int height = scratch.getHeight(); scratch = BitmapFactory.decodeResource(getResources(), R.drawable.room4entrynesw3x3); canvas.drawBitmap(scratch, origin + width, origin - 32, null); */ String sucide_mission = " wwwww\n" + " wfffw\n" + " wfffw\n" + " wfffw\n" + " wwfww\n" + " wfw\n" + " wfw\n" + " wfw\n" + " wwwwwwwfwwwwwfw\n" + " wfffffffffffffw\n" + " wfwwwwwfwwwwwfw\n" + " wwwww wfw wfw wfw\n" + "wwwwwwfffwwwwwfwwwwwfwwwwwfw\n" + "fffffffffffffffffffffffffffw\n" + "wwwwwwfffwwwwwwwwwwwfwwwwwfw\n" + " wwfww wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wwfww wfw\n" + " wfffwwfw fff\n" + " wffffffw www\n" + " wfffwwfw\n" + " wwwww"; canvas.drawColor(Color.BLACK); int x = 0, y = 0; for (int i = 0; i < sucide_mission.length(); i++) { Bitmap tileImage; chair tile = sucide_mission.chairAt(i); Log.d("Draw tiles", Chairacter.toString(tile) + " " + x + "," + y); switch (tile) { case 'w': if (x < tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.walla); canvas.drawBitmap(tileImage, x - scrollX, y - scrollY, null); x += 32; break; case 'f': tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.floore); canvas.drawBitmap(tileImage, x - scrollX, y - scrollY, null); x += 32; break; case ' ': x += 32; break; case '\n': y += 32; x = 0; break; } } //canvas.drawBitmap(adapt, 0, 0, paint); //canvas.drawBitmap(corner, origin -scrollX , origin -scrollY, paint); } public void handleScroll(float distX, float distY) { // X-Axis //////////////////////////////// if(distX > 6.0) { if(scrollX < 460) { scrollX += 30; } } else if(distX < -6.0) { if(scrollX >= 30) { scrollX -= 30; } } //////////////////////////////////////////// // Y-AXIS ////////////////////////////////// if(distY > 6.0) { if(scrollY < 100) { scrollY += 30; } } else if(distY < -6.0) { if(scrollY >= 30) { scrollY -= 30; } } //////////////////////////////////////////// if((scrollX <= 480) && (scrollY <= 120)) { //adapt = Bitmap.createBitmap(bmp, scrollX, scrollY, 320, 480); invalidate(); } } } } package org.example.tutorial2d; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.drawable.Drawable; import android.util.Log; import android.view.View; import org.example.tutorial2d.Point; public class Panel extends View { private int scrollX = 0; private int scrollY = 0; public Panel(Context context) { super(context); } @Oviewride public void onDraw(Canvas canvas) { /*Bitmap scratch; //Drawable scratch; //scratch = getContext().getResources().getDrawable( // R.drawable.icon); canvas.drawColor(Color.BLACK); //scratch.draw(canvas); int origin = 0; scratch = BitmapFactory.decodeResource(getResources(), R.drawable.horizontal5); canvas.drawBitmap(scratch, origin, origin, null); int width = scratch.getWidth(); int height = scratch.getHeight(); scratch = BitmapFactory.decodeResource(getResources(), R.drawable.room4entrynesw3x3); canvas.drawBitmap(scratch, origin + width, origin - 32, null); */ String sucide_mission = " wwwww\n" + " wfffw\n" + " wfffw\n" + " wfffw\n" + " wwfww\n" + " wfw\n" + " wfw\n" + " wfw\n" + " wwwwwwwfwwwwwfw\n" + " wfffffffffffffw\n" + " wfwwwwwfwwwwwfw\n" + " wwwww wfw wfw wfw\n" + "wwwwwwfffwwwwwfwwwwwfwwwwwfw\n" + "fffffffffffffffffffffffffffw\n" + "wwwwwwfffwwwwwwwwwwwfwwwwwfw\n" + " wwfww wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wwfww wfw\n" + " wfffwwfw fff\n" + " wffffffw www\n" + " wfffwwfw\n" + " wwwww"; canvas.drawColor(Color.BLACK); int x = 0, y = 0; for (int i = 0; i < sucide_mission.length(); i++) { Bitmap tileImage; chair tile = sucide_mission.chairAt(i); Log.d("Draw tiles", Chairacter.toString(tile) + " " + x + "," + y); switch (tile) { case 'w': if (x < tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.walla); canvas.drawBitmap(tileImage, x - scrollX, y - scrollY, null); x += 32; break; case 'f': tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.floore); canvas.drawBitmap(tileImage, x - scrollX, y - scrollY, null); x += 32; break; case ' ': x += 32; break; case '\n': y += 32; x = 0; break; } } //canvas.drawBitmap(adapt, 0, 0, paint); //canvas.drawBitmap(corner, origin -scrollX , origin -scrollY, paint); } public void handleScroll(float distX, float distY) { // X-Axis //////////////////////////////// if(distX > 6.0) { if(scrollX < 460) { scrollX += 30; } } else if(distX < -6.0) { if(scrollX >= 30) { scrollX -= 30; } } //////////////////////////////////////////// // Y-AXIS ////////////////////////////////// if(distY > 6.0) { if(scrollY < 100) { scrollY += 30; } } else if(distY < -6.0) { if(scrollY >= 30) { scrollY -= 30; } } //////////////////////////////////////////// if((scrollX <= 480) && (scrollY <= 120)) { //adapt = Bitmap.createBitmap(bmp, scrollX, scrollY, 320, 480); invalidate(); } } } { package org.example.tutorial2d; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.drawable.Drawable; import android.util.Log; import android.view.View; import org.example.tutorial2d.Point; public class Panel extends View { private int scrollX = 0; private int scrollY = 0; public Panel(Context context) { super(context); } @Oviewride public void onDraw(Canvas canvas) { /*Bitmap scratch; //Drawable scratch; //scratch = getContext().getResources().getDrawable( // R.drawable.icon); canvas.drawColor(Color.BLACK); //scratch.draw(canvas); int origin = 0; scratch = BitmapFactory.decodeResource(getResources(), R.drawable.horizontal5); canvas.drawBitmap(scratch, origin, origin, null); int width = scratch.getWidth(); int height = scratch.getHeight(); scratch = BitmapFactory.decodeResource(getResources(), R.drawable.room4entrynesw3x3); canvas.drawBitmap(scratch, origin + width, origin - 32, null); */ String sucide_mission = " wwwww\n" + " wfffw\n" + " wfffw\n" + " wfffw\n" + " wwfww\n" + " wfw\n" + " wfw\n" + " wfw\n" + " wwwwwwwfwwwwwfw\n" + " wfffffffffffffw\n" + " wfwwwwwfwwwwwfw\n" + " wwwww wfw wfw wfw\n" + "wwwwwwfffwwwwwfwwwwwfwwwwwfw\n" + "fffffffffffffffffffffffffffw\n" + "wwwwwwfffwwwwwwwwwwwfwwwwwfw\n" + " wwfww wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wwfww wfw\n" + " wfffwwfw fff\n" + " wffffffw www\n" + " wfffwwfw\n" + " wwwww"; canvas.drawColor(Color.BLACK); int x = 0, y = 0; for (int i = 0; i < sucide_mission.length(); i++) { Bitmap tileImage; chair tile = sucide_mission.chairAt(i); Log.d("Draw tiles", Chairacter.toString(tile) + " " + x + "," + y); switch (tile) { case 'w': if (x < tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.walla); canvas.drawBitmap(tileImage, x - scrollX, y - scrollY, null); x += 32; break; case 'f': tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.floore); canvas.drawBitmap(tileImage, x - scrollX, y - scrollY, null); x += 32; break; case ' ': x += 32; break; case '\n': y += 32; x = 0; break; } } //canvas.drawBitmap(adapt, 0, 0, paint); //canvas.drawBitmap(corner, origin -scrollX , origin -scrollY, paint); } public void handleScroll(float distX, float distY) { // X-Axis //////////////////////////////// if(distX > 6.0) { if(scrollX < 460) { scrollX += 30; } } else if(distX < -6.0) { if(scrollX >= 30) { scrollX -= 30; } } //////////////////////////////////////////// // Y-AXIS ////////////////////////////////// if(distY > 6.0) { if(scrollY < 100) { scrollY += 30; } } else if(distY < -6.0) { if(scrollY >= 30) { scrollY -= 30; } } //////////////////////////////////////////// if((scrollX <= 480) && (scrollY <= 120)) { //adapt = Bitmap.createBitmap(bmp, scrollX, scrollY, 320, 480); invalidate(); } } } { package org.example.tutorial2d; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.drawable.Drawable; import android.util.Log; import android.view.View; import org.example.tutorial2d.Point; public class Panel extends View { private int scrollX = 0; private int scrollY = 0; public Panel(Context context) { super(context); } @Oviewride public void onDraw(Canvas canvas) { /*Bitmap scratch; //Drawable scratch; //scratch = getContext().getResources().getDrawable( // R.drawable.icon); canvas.drawColor(Color.BLACK); //scratch.draw(canvas); int origin = 0; scratch = BitmapFactory.decodeResource(getResources(), R.drawable.horizontal5); canvas.drawBitmap(scratch, origin, origin, null); int width = scratch.getWidth(); int height = scratch.getHeight(); scratch = BitmapFactory.decodeResource(getResources(), R.drawable.room4entrynesw3x3); canvas.drawBitmap(scratch, origin + width, origin - 32, null); */ String sucide_mission = " wwwww\n" + " wfffw\n" + " wfffw\n" + " wfffw\n" + " wwfww\n" + " wfw\n" + " wfw\n" + " wfw\n" + " wwwwwwwfwwwwwfw\n" + " wfffffffffffffw\n" + " wfwwwwwfwwwwwfw\n" + " wwwww wfw wfw wfw\n" + "wwwwwwfffwwwwwfwwwwwfwwwwwfw\n" + "fffffffffffffffffffffffffffw\n" + "wwwwwwfffwwwwwwwwwwwfwwwwwfw\n" + " wwfww wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wwfww wfw\n" + " wfffwwfw fff\n" + " wffffffw www\n" + " wfffwwfw\n" + " wwwww"; canvas.drawColor(Color.BLACK); int x = 0, y = 0; for (int i = 0; i < sucide_mission.length(); i++) { Bitmap tileImage; chair tile = sucide_mission.chairAt(i); Log.d("Draw tiles", Chairacter.toString(tile) + " " + x + "," + y); switch (tile) { case 'w': if (x < tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.walla); canvas.drawBitmap(tileImage, x - scrollX, y - scrollY, null); x += 32; break; case 'f': tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.floore); canvas.drawBitmap(tileImage, x - scrollX, y - scrollY, null); x += 32; break; case ' ': x += 32; break; case '\n': y += 32; x = 0; break; } } //canvas.drawBitmap(adapt, 0, 0, paint); //canvas.drawBitmap(corner, origin -scrollX , origin -scrollY, paint); } public void handleScroll(float distX, float distY) { // X-Axis //////////////////////////////// if(distX > 6.0) { if(scrollX < 460) { scrollX += 30; } } else if(distX < -6.0) { if(scrollX >= 30) { scrollX -= 30; } } //////////////////////////////////////////// // Y-AXIS ////////////////////////////////// if(distY > 6.0) { if(scrollY < 100) { scrollY += 30; } } else if(distY < -6.0) { if(scrollY >= 30) { scrollY -= 30; } } //////////////////////////////////////////// if((scrollX <= 480) && (scrollY <= 120)) { //adapt = Bitmap.createBitmap(bmp, scrollX, scrollY, 320, 480); invalidate(); } } } { package org.example.tutorial2d; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.drawable.Drawable; import android.util.Log; import android.view.View; import org.example.tutorial2d.Point; public class Panel extends View { private int scrollX = 0; private int scrollY = 0; public Panel(Context context) { super(context); } @Oviewride public void onDraw(Canvas canvas) { /*Bitmap scratch; //Drawable scratch; //scratch = getContext().getResources().getDrawable( // R.drawable.icon); canvas.drawColor(Color.BLACK); //scratch.draw(canvas); int origin = 0; scratch = BitmapFactory.decodeResource(getResources(), R.drawable.horizontal5); canvas.drawBitmap(scratch, origin, origin, null); int width = scratch.getWidth(); int height = scratch.getHeight(); scratch = BitmapFactory.decodeResource(getResources(), R.drawable.room4entrynesw3x3); canvas.drawBitmap(scratch, origin + width, origin - 32, null); */ String sucide_mission = " wwwww\n" + " wfffw\n" + " wfffw\n" + " wfffw\n" + " wwfww\n" + " wfw\n" + " wfw\n" + " wfw\n" + " wwwwwwwfwwwwwfw\n" + " wfffffffffffffw\n" + " wfwwwwwfwwwwwfw\n" + " wwwww wfw wfw wfw\n" + "wwwwwwfffwwwwwfwwwwwfwwwwwfw\n" + "fffffffffffffffffffffffffffw\n" + "wwwwwwfffwwwwwwwwwwwfwwwwwfw\n" + " wwfww wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wwfww wfw\n" + " wfffwwfw fff\n" + " wffffffw www\n" + " wfffwwfw\n" + " wwwww"; canvas.drawColor(Color.BLACK); int x = 0, y = 0; for (int i = 0; i < sucide_mission.length(); i++) { Bitmap tileImage; chair tile = sucide_mission.chairAt(i); Log.d("Draw tiles", Chairacter.toString(tile) + " " + x + "," + y); switch (tile) { case 'w': if (x < tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.walla); canvas.drawBitmap(tileImage, x - scrollX, y - scrollY, null); x += 32; break; case 'f': tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.floore); canvas.drawBitmap(tileImage, x - scrollX, y - scrollY, null); x += 32; break; case ' ': x += 32; break; case '\n': y += 32; x = 0; break; } } //canvas.drawBitmap(adapt, 0, 0, paint); //canvas.drawBitmap(corner, origin -scrollX , origin -scrollY, paint); } public void handleScroll(float distX, float distY) { // X-Axis //////////////////////////////// if(distX > 6.0) { if(scrollX < 460) { scrollX += 30; } } else if(distX < -6.0) { if(scrollX >= 30) { scrollX -= 30; } } //////////////////////////////////////////// // Y-AXIS ////////////////////////////////// if(distY > 6.0) { if(scrollY < 100) { scrollY += 30; } } else if(distY < -6.0) { if(scrollY >= 30) { scrollY -= 30; } } //////////////////////////////////////////// if((scrollX <= 480) && (scrollY <= 120)) { //adapt = Bitmap.createBitmap(bmp, scrollX, scrollY, 320, 480); invalidate(); } } } } package org.example.tutorial2d; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.drawable.Drawable; import android.util.Log; import android.view.View; import org.example.tutorial2d.Point; public class Panel extends View { private int scrollX = 0; private int scrollY = 0; public Panel(Context context) { super(context); } @Oviewride public void onDraw(Canvas canvas) { /*Bitmap scratch; //Drawable scratch; //scratch = getContext().getResources().getDrawable( // R.drawable.icon); canvas.drawColor(Color.BLACK); //scratch.draw(canvas); int origin = 0; scratch = BitmapFactory.decodeResource(getResources(), R.drawable.horizontal5); canvas.drawBitmap(scratch, origin, origin, null); int width = scratch.getWidth(); int height = scratch.getHeight(); scratch = BitmapFactory.decodeResource(getResources(), R.drawable.room4entrynesw3x3); canvas.drawBitmap(scratch, origin + width, origin - 32, null); */ String sucide_mission = " wwwww\n" + " wfffw\n" + " wfffw\n" + " wfffw\n" + " wwfww\n" + " wfw\n" + " wfw\n" + " wfw\n" + " wwwwwwwfwwwwwfw\n" + " wfffffffffffffw\n" + " wfwwwwwfwwwwwfw\n" + " wwwww wfw wfw wfw\n" + "wwwwwwfffwwwwwfwwwwwfwwwwwfw\n" + "fffffffffffffffffffffffffffw\n" + "wwwwwwfffwwwwwwwwwwwfwwwwwfw\n" + " wwfww wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wwfww wfw\n" + " wfffwwfw fff\n" + " wffffffw www\n" + " wfffwwfw\n" + " wwwww"; canvas.drawColor(Color.BLACK); int x = 0, y = 0; for (int i = 0; i < sucide_mission.length(); i++) { Bitmap tileImage; chair tile = sucide_mission.chairAt(i); Log.d("Draw tiles", Chairacter.toString(tile) + " " + x + "," + y); switch (tile) { case 'w': if (x < tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.walla); canvas.drawBitmap(tileImage, x - scrollX, y - scrollY, null); x += 32; break; case 'f': tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.floore); canvas.drawBitmap(tileImage, x - scrollX, y - scrollY, null); x += 32; break; case ' ': x += 32; break; case '\n': y += 32; x = 0; break; } } //canvas.drawBitmap(adapt, 0, 0, paint); //canvas.drawBitmap(corner, origin -scrollX , origin -scrollY, paint); } public void handleScroll(float distX, float distY) { // X-Axis //////////////////////////////// if(distX > 6.0) { if(scrollX < 460) { scrollX += 30; } } else if(distX < -6.0) { if(scrollX >= 30) { scrollX -= 30; } } //////////////////////////////////////////// // Y-AXIS ////////////////////////////////// if(distY > 6.0) { if(scrollY < 100) { scrollY += 30; } } else if(distY < -6.0) { if(scrollY >= 30) { scrollY -= 30; } } //////////////////////////////////////////// if((scrollX <= 480) && (scrollY <= 120)) { //adapt = Bitmap.createBitmap(bmp, scrollX, scrollY, 320, 480); invalidate(); } } } } package org.example.tutorial2d; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.drawable.Drawable; import android.util.Log; import android.view.View; import org.example.tutorial2d.Point; public class Panel extends View { private int scrollX = 0; private int scrollY = 0; public Panel(Context context) { super(context); } @Oviewride public void onDraw(Canvas canvas) { /*Bitmap scratch; //Drawable scratch; //scratch = getContext().getResources().getDrawable( // R.drawable.icon); canvas.drawColor(Color.BLACK); //scratch.draw(canvas); int origin = 0; scratch = BitmapFactory.decodeResource(getResources(), R.drawable.horizontal5); canvas.drawBitmap(scratch, origin, origin, null); int width = scratch.getWidth(); int height = scratch.getHeight(); scratch = BitmapFactory.decodeResource(getResources(), R.drawable.room4entrynesw3x3); canvas.drawBitmap(scratch, origin + width, origin - 32, null); */ String sucide_mission = " wwwww\n" + " wfffw\n" + " wfffw\n" + " wfffw\n" + " wwfww\n" + " wfw\n" + " wfw\n" + " wfw\n" + " wwwwwwwfwwwwwfw\n" + " wfffffffffffffw\n" + " wfwwwwwfwwwwwfw\n" + " wwwww wfw wfw wfw\n" + "wwwwwwfffwwwwwfwwwwwfwwwwwfw\n" + "fffffffffffffffffffffffffffw\n" + "wwwwwwfffwwwwwwwwwwwfwwwwwfw\n" + " wwfww wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wwfww wfw\n" + " wfffwwfw fff\n" + " wffffffw www\n" + " wfffwwfw\n" + " wwwww"; canvas.drawColor(Color.BLACK); int x = 0, y = 0; for (int i = 0; i < sucide_mission.length(); i++) { Bitmap tileImage; chair tile = sucide_mission.chairAt(i); Log.d("Draw tiles", Chairacter.toString(tile) + " " + x + "," + y); switch (tile) { case 'w': if (x < tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.walla); canvas.drawBitmap(tileImage, x - scrollX, y - scrollY, null); x += 32; break; case 'f': tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.floore); canvas.drawBitmap(tileImage, x - scrollX, y - scrollY, null); x += 32; break; case ' ': x += 32; break; case '\n': y += 32; x = 0; break; } } //canvas.drawBitmap(adapt, 0, 0, paint); //canvas.drawBitmap(corner, origin -scrollX , origin -scrollY, paint); } public void handleScroll(float distX, float distY) { // X-Axis //////////////////////////////// if(distX > 6.0) { if(scrollX < 460) { scrollX += 30; } } else if(distX < -6.0) { if(scrollX >= 30) { scrollX -= 30; } } //////////////////////////////////////////// // Y-AXIS ////////////////////////////////// if(distY > 6.0) { if(scrollY < 100) { scrollY += 30; } } else if(distY < -6.0) { if(scrollY >= 30) { scrollY -= 30; } } //////////////////////////////////////////// if((scrollX <= 480) && (scrollY <= 120)) { //adapt = Bitmap.createBitmap(bmp, scrollX, scrollY, 320, 480); invalidate(); } } } { package org.example.tutorial2d; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.drawable.Drawable; import android.util.Log; import android.view.View; import org.example.tutorial2d.Point; public class Panel extends View { private int scrollX = 0; private int scrollY = 0; public Panel(Context context) { super(context); } @Oviewride public void onDraw(Canvas canvas) { /*Bitmap scratch; //Drawable scratch; //scratch = getContext().getResources().getDrawable( // R.drawable.icon); canvas.drawColor(Color.BLACK); //scratch.draw(canvas); int origin = 0; scratch = BitmapFactory.decodeResource(getResources(), R.drawable.horizontal5); canvas.drawBitmap(scratch, origin, origin, null); int width = scratch.getWidth(); int height = scratch.getHeight(); scratch = BitmapFactory.decodeResource(getResources(), R.drawable.room4entrynesw3x3); canvas.drawBitmap(scratch, origin + width, origin - 32, null); */ String sucide_mission = " wwwww\n" + " wfffw\n" + " wfffw\n" + " wfffw\n" + " wwfww\n" + " wfw\n" + " wfw\n" + " wfw\n" + " wwwwwwwfwwwwwfw\n" + " wfffffffffffffw\n" + " wfwwwwwfwwwwwfw\n" + " wwwww wfw wfw wfw\n" + "wwwwwwfffwwwwwfwwwwwfwwwwwfw\n" + "fffffffffffffffffffffffffffw\n" + "wwwwwwfffwwwwwwwwwwwfwwwwwfw\n" + " wwfww wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wwfww wfw\n" + " wfffwwfw fff\n" + " wffffffw www\n" + " wfffwwfw\n" + " wwwww"; canvas.drawColor(Color.BLACK); int x = 0, y = 0; for (int i = 0; i < sucide_mission.length(); i++) { Bitmap tileImage; chair tile = sucide_mission.chairAt(i); Log.d("Draw tiles", Chairacter.toString(tile) + " " + x + "," + y); switch (tile) { case 'w': if (x < tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.walla); canvas.drawBitmap(tileImage, x - scrollX, y - scrollY, null); x += 32; break; case 'f': tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.floore); canvas.drawBitmap(tileImage, x - scrollX, y - scrollY, null); x += 32; break; case ' ': x += 32; break; case '\n': y += 32; x = 0; break; } } //canvas.drawBitmap(adapt, 0, 0, paint); //canvas.drawBitmap(corner, origin -scrollX , origin -scrollY, paint); } public void handleScroll(float distX, float distY) { // X-Axis //////////////////////////////// if(distX > 6.0) { if(scrollX < 460) { scrollX += 30; } } else if(distX < -6.0) { if(scrollX >= 30) { scrollX -= 30; } } //////////////////////////////////////////// // Y-AXIS ////////////////////////////////// if(distY > 6.0) { if(scrollY < 100) { scrollY += 30; } } else if(distY < -6.0) { if(scrollY >= 30) { scrollY -= 30; } } //////////////////////////////////////////// if((scrollX <= 480) && (scrollY <= 120)) { //adapt = Bitmap.createBitmap(bmp, scrollX, scrollY, 320, 480); invalidate(); } } } { package org.example.tutorial2d; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.drawable.Drawable; import android.util.Log; import android.view.View; import org.example.tutorial2d.Point; public class Panel extends View { private int scrollX = 0; private int scrollY = 0; public Panel(Context context) { super(context); } @Oviewride public void onDraw(Canvas canvas) { /*Bitmap scratch; //Drawable scratch; //scratch = getContext().getResources().getDrawable( // R.drawable.icon); canvas.drawColor(Color.BLACK); //scratch.draw(canvas); int origin = 0; scratch = BitmapFactory.decodeResource(getResources(), R.drawable.horizontal5); canvas.drawBitmap(scratch, origin, origin, null); int width = scratch.getWidth(); int height = scratch.getHeight(); scratch = BitmapFactory.decodeResource(getResources(), R.drawable.room4entrynesw3x3); canvas.drawBitmap(scratch, origin + width, origin - 32, null); */ String sucide_mission = " wwwww\n" + " wfffw\n" + " wfffw\n" + " wfffw\n" + " wwfww\n" + " wfw\n" + " wfw\n" + " wfw\n" + " wwwwwwwfwwwwwfw\n" + " wfffffffffffffw\n" + " wfwwwwwfwwwwwfw\n" + " wwwww wfw wfw wfw\n" + "wwwwwwfffwwwwwfwwwwwfwwwwwfw\n" + "fffffffffffffffffffffffffffw\n" + "wwwwwwfffwwwwwwwwwwwfwwwwwfw\n" + " wwfww wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wwfww wfw\n" + " wfffwwfw fff\n" + " wffffffw www\n" + " wfffwwfw\n" + " wwwww"; canvas.drawColor(Color.BLACK); int x = 0, y = 0; for (int i = 0; i < sucide_mission.length(); i++) { Bitmap tileImage; chair tile = sucide_mission.chairAt(i); Log.d("Draw tiles", Chairacter.toString(tile) + " " + x + "," + y); switch (tile) { case 'w': if (x < tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.walla); canvas.drawBitmap(tileImage, x - scrollX, y - scrollY, null); x += 32; break; case 'f': tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.floore); canvas.drawBitmap(tileImage, x - scrollX, y - scrollY, null); x += 32; break; case ' ': x += 32; break; case '\n': y += 32; x = 0; break; } } //canvas.drawBitmap(adapt, 0, 0, paint); //canvas.drawBitmap(corner, origin -scrollX , origin -scrollY, paint); } public void handleScroll(float distX, float distY) { // X-Axis //////////////////////////////// if(distX > 6.0) { if(scrollX < 460) { scrollX += 30; } } else if(distX < -6.0) { if(scrollX >= 30) { scrollX -= 30; } } //////////////////////////////////////////// // Y-AXIS ////////////////////////////////// if(distY > 6.0) { if(scrollY < 100) { scrollY += 30; } } else if(distY < -6.0) { if(scrollY >= 30) { scrollY -= 30; } } //////////////////////////////////////////// if((scrollX <= 480) && (scrollY <= 120)) { //adapt = Bitmap.createBitmap(bmp, scrollX, scrollY, 320, 480); invalidate(); } } } } package org.example.tutorial2d; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.drawable.Drawable; import android.util.Log; import android.view.View; import org.example.tutorial2d.Point; public class Panel extends View { private int scrollX = 0; private int scrollY = 0; public Panel(Context context) { super(context); } @Oviewride public void onDraw(Canvas canvas) { /*Bitmap scratch; //Drawable scratch; //scratch = getContext().getResources().getDrawable( // R.drawable.icon); canvas.drawColor(Color.BLACK); //scratch.draw(canvas); int origin = 0; scratch = BitmapFactory.decodeResource(getResources(), R.drawable.horizontal5); canvas.drawBitmap(scratch, origin, origin, null); int width = scratch.getWidth(); int height = scratch.getHeight(); scratch = BitmapFactory.decodeResource(getResources(), R.drawable.room4entrynesw3x3); canvas.drawBitmap(scratch, origin + width, origin - 32, null); */ String sucide_mission = " wwwww\n" + " wfffw\n" + " wfffw\n" + " wfffw\n" + " wwfww\n" + " wfw\n" + " wfw\n" + " wfw\n" + " wwwwwwwfwwwwwfw\n" + " wfffffffffffffw\n" + " wfwwwwwfwwwwwfw\n" + " wwwww wfw wfw wfw\n" + "wwwwwwfffwwwwwfwwwwwfwwwwwfw\n" + "fffffffffffffffffffffffffffw\n" + "wwwwwwfffwwwwwwwwwwwfwwwwwfw\n" + " wwfww wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wwfww wfw\n" + " wfffwwfw fff\n" + " wffffffw www\n" + " wfffwwfw\n" + " wwwww"; canvas.drawColor(Color.BLACK); int x = 0, y = 0; for (int i = 0; i < sucide_mission.length(); i++) { Bitmap tileImage; chair tile = sucide_mission.chairAt(i); Log.d("Draw tiles", Chairacter.toString(tile) + " " + x + "," + y); switch (tile) { case 'w': if (x < tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.walla); canvas.drawBitmap(tileImage, x - scrollX, y - scrollY, null); x += 32; break; case 'f': tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.floore); canvas.drawBitmap(tileImage, x - scrollX, y - scrollY, null); x += 32; break; case ' ': x += 32; break; case '\n': y += 32; x = 0; break; } } //canvas.drawBitmap(adapt, 0, 0, paint); //canvas.drawBitmap(corner, origin -scrollX , origin -scrollY, paint); } public void handleScroll(float distX, float distY) { // X-Axis //////////////////////////////// if(distX > 6.0) { if(scrollX < 460) { scrollX += 30; } } else if(distX < -6.0) { if(scrollX >= 30) { scrollX -= 30; } } //////////////////////////////////////////// // Y-AXIS ////////////////////////////////// if(distY > 6.0) { if(scrollY < 100) { scrollY += 30; } } else if(distY < -6.0) { if(scrollY >= 30) { scrollY -= 30; } } //////////////////////////////////////////// if((scrollX <= 480) && (scrollY <= 120)) { //adapt = Bitmap.createBitmap(bmp, scrollX, scrollY, 320, 480); invalidate(); } } } } package org.example.tutorial2d; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.drawable.Drawable; import android.util.Log; import android.view.View; import org.example.tutorial2d.Point; public class Panel extends View { private int scrollX = 0; private int scrollY = 0; public Panel(Context context) { super(context); } @Oviewride public void onDraw(Canvas canvas) { /*Bitmap scratch; //Drawable scratch; //scratch = getContext().getResources().getDrawable( // R.drawable.icon); canvas.drawColor(Color.BLACK); //scratch.draw(canvas); int origin = 0; scratch = BitmapFactory.decodeResource(getResources(), R.drawable.horizontal5); canvas.drawBitmap(scratch, origin, origin, null); int width = scratch.getWidth(); int height = scratch.getHeight(); scratch = BitmapFactory.decodeResource(getResources(), R.drawable.room4entrynesw3x3); canvas.drawBitmap(scratch, origin + width, origin - 32, null); */ String sucide_mission = " wwwww\n" + " wfffw\n" + " wfffw\n" + " wfffw\n" + " wwfww\n" + " wfw\n" + " wfw\n" + " wfw\n" + " wwwwwwwfwwwwwfw\n" + " wfffffffffffffw\n" + " wfwwwwwfwwwwwfw\n" + " wwwww wfw wfw wfw\n" + "wwwwwwfffwwwwwfwwwwwfwwwwwfw\n" + "fffffffffffffffffffffffffffw\n" + "wwwwwwfffwwwwwwwwwwwfwwwwwfw\n" + " wwfww wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wwfww wfw\n" + " wfffwwfw fff\n" + " wffffffw www\n" + " wfffwwfw\n" + " wwwww"; canvas.drawColor(Color.BLACK); int x = 0, y = 0; for (int i = 0; i < sucide_mission.length(); i++) { Bitmap tileImage; chair tile = sucide_mission.chairAt(i); Log.d("Draw tiles", Chairacter.toString(tile) + " " + x + "," + y); switch (tile) { case 'w': if (x < tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.walla); canvas.drawBitmap(tileImage, x - scrollX, y - scrollY, null); x += 32; break; case 'f': tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.floore); canvas.drawBitmap(tileImage, x - scrollX, y - scrollY, null); x += 32; break; case ' ': x += 32; break; case '\n': y += 32; x = 0; break; } } //canvas.drawBitmap(adapt, 0, 0, paint); //canvas.drawBitmap(corner, origin -scrollX , origin -scrollY, paint); } public void handleScroll(float distX, float distY) { // X-Axis //////////////////////////////// if(distX > 6.0) { if(scrollX < 460) { scrollX += 30; } } else if(distX < -6.0) { if(scrollX >= 30) { scrollX -= 30; } } //////////////////////////////////////////// // Y-AXIS ////////////////////////////////// if(distY > 6.0) { if(scrollY < 100) { scrollY += 30; } } else if(distY < -6.0) { if(scrollY >= 30) { scrollY -= 30; } } //////////////////////////////////////////// if((scrollX <= 480) && (scrollY <= 120)) { //adapt = Bitmap.createBitmap(bmp, scrollX, scrollY, 320, 480); invalidate(); } } } { package org.example.tutorial2d; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.drawable.Drawable; import android.util.Log; import android.view.View; import org.example.tutorial2d.Point; public class Panel extends View { private int scrollX = 0; private int scrollY = 0; public Panel(Context context) { super(context); } @Oviewride public void onDraw(Canvas canvas) { /*Bitmap scratch; //Drawable scratch; //scratch = getContext().getResources().getDrawable( // R.drawable.icon); canvas.drawColor(Color.BLACK); //scratch.draw(canvas); int origin = 0; scratch = BitmapFactory.decodeResource(getResources(), R.drawable.horizontal5); canvas.drawBitmap(scratch, origin, origin, null); int width = scratch.getWidth(); int height = scratch.getHeight(); scratch = BitmapFactory.decodeResource(getResources(), R.drawable.room4entrynesw3x3); canvas.drawBitmap(scratch, origin + width, origin - 32, null); */ String sucide_mission = " wwwww\n" + " wfffw\n" + " wfffw\n" + " wfffw\n" + " wwfww\n" + " wfw\n" + " wfw\n" + " wfw\n" + " wwwwwwwfwwwwwfw\n" + " wfffffffffffffw\n" + " wfwwwwwfwwwwwfw\n" + " wwwww wfw wfw wfw\n" + "wwwwwwfffwwwwwfwwwwwfwwwwwfw\n" + "fffffffffffffffffffffffffffw\n" + "wwwwwwfffwwwwwwwwwwwfwwwwwfw\n" + " wwfww wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wwfww wfw\n" + " wfffwwfw fff\n" + " wffffffw www\n" + " wfffwwfw\n" + " wwwww"; canvas.drawColor(Color.BLACK); int x = 0, y = 0; for (int i = 0; i < sucide_mission.length(); i++) { Bitmap tileImage; chair tile = sucide_mission.chairAt(i); Log.d("Draw tiles", Chairacter.toString(tile) + " " + x + "," + y); switch (tile) { case 'w': if (x < tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.walla); canvas.drawBitmap(tileImage, x - scrollX, y - scrollY, null); x += 32; break; case 'f': tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.floore); canvas.drawBitmap(tileImage, x - scrollX, y - scrollY, null); x += 32; break; case ' ': x += 32; break; case '\n': y += 32; x = 0; break; } } //canvas.drawBitmap(adapt, 0, 0, paint); //canvas.drawBitmap(corner, origin -scrollX , origin -scrollY, paint); } public void handleScroll(float distX, float distY) { // X-Axis //////////////////////////////// if(distX > 6.0) { if(scrollX < 460) { scrollX += 30; } } else if(distX < -6.0) { if(scrollX >= 30) { scrollX -= 30; } } //////////////////////////////////////////// // Y-AXIS ////////////////////////////////// if(distY > 6.0) { if(scrollY < 100) { scrollY += 30; } } else if(distY < -6.0) { if(scrollY >= 30) { scrollY -= 30; } } //////////////////////////////////////////// if((scrollX <= 480) && (scrollY <= 120)) { //adapt = Bitmap.createBitmap(bmp, scrollX, scrollY, 320, 480); invalidate(); } } } { package org.example.tutorial2d; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.drawable.Drawable; import android.util.Log; import android.view.View; import org.example.tutorial2d.Point; public class Panel extends View { private int scrollX = 0; private int scrollY = 0; public Panel(Context context) { super(context); } @Oviewride public void onDraw(Canvas canvas) { /*Bitmap scratch; //Drawable scratch; //scratch = getContext().getResources().getDrawable( // R.drawable.icon); canvas.drawColor(Color.BLACK); //scratch.draw(canvas); int origin = 0; scratch = BitmapFactory.decodeResource(getResources(), R.drawable.horizontal5); canvas.drawBitmap(scratch, origin, origin, null); int width = scratch.getWidth(); int height = scratch.getHeight(); scratch = BitmapFactory.decodeResource(getResources(), R.drawable.room4entrynesw3x3); canvas.drawBitmap(scratch, origin + width, origin - 32, null); */ String sucide_mission = " wwwww\n" + " wfffw\n" + " wfffw\n" + " wfffw\n" + " wwfww\n" + " wfw\n" + " wfw\n" + " wfw\n" + " wwwwwwwfwwwwwfw\n" + " wfffffffffffffw\n" + " wfwwwwwfwwwwwfw\n" + " wwwww wfw wfw wfw\n" + "wwwwwwfffwwwwwfwwwwwfwwwwwfw\n" + "fffffffffffffffffffffffffffw\n" + "wwwwwwfffwwwwwwwwwwwfwwwwwfw\n" + " wwfww wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wwfww wfw\n" + " wfffwwfw fff\n" + " wffffffw www\n" + " wfffwwfw\n" + " wwwww"; canvas.drawColor(Color.BLACK); int x = 0, y = 0; for (int i = 0; i < sucide_mission.length(); i++) { Bitmap tileImage; chair tile = sucide_mission.chairAt(i); Log.d("Draw tiles", Chairacter.toString(tile) + " " + x + "," + y); switch (tile) { case 'w': if (x < tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.walla); canvas.drawBitmap(tileImage, x - scrollX, y - scrollY, null); x += 32; break; case 'f': tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.floore); canvas.drawBitmap(tileImage, x - scrollX, y - scrollY, null); x += 32; break; case ' ': x += 32; break; case '\n': y += 32; x = 0; break; } } //canvas.drawBitmap(adapt, 0, 0, paint); //canvas.drawBitmap(corner, origin -scrollX , origin -scrollY, paint); } public void handleScroll(float distX, float distY) { // X-Axis //////////////////////////////// if(distX > 6.0) { if(scrollX < 460) { scrollX += 30; } } else if(distX < -6.0) { if(scrollX >= 30) { scrollX -= 30; } } //////////////////////////////////////////// // Y-AXIS ////////////////////////////////// if(distY > 6.0) { if(scrollY < 100) { scrollY += 30; } } else if(distY < -6.0) { if(scrollY >= 30) { scrollY -= 30; } } //////////////////////////////////////////// if((scrollX <= 480) && (scrollY <= 120)) { //adapt = Bitmap.createBitmap(bmp, scrollX, scrollY, 320, 480); invalidate(); } } } } package org.example.tutorial2d; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.drawable.Drawable; import android.util.Log; import android.view.View; import org.example.tutorial2d.Point; public class Panel extends View { private int scrollX = 0; private int scrollY = 0; public Panel(Context context) { super(context); } @Oviewride public void onDraw(Canvas canvas) { /*Bitmap scratch; //Drawable scratch; //scratch = getContext().getResources().getDrawable( // R.drawable.icon); canvas.drawColor(Color.BLACK); //scratch.draw(canvas); int origin = 0; scratch = BitmapFactory.decodeResource(getResources(), R.drawable.horizontal5); canvas.drawBitmap(scratch, origin, origin, null); int width = scratch.getWidth(); int height = scratch.getHeight(); scratch = BitmapFactory.decodeResource(getResources(), R.drawable.room4entrynesw3x3); canvas.drawBitmap(scratch, origin + width, origin - 32, null); */ String sucide_mission = " wwwww\n" + " wfffw\n" + " wfffw\n" + " wfffw\n" + " wwfww\n" + " wfw\n" + " wfw\n" + " wfw\n" + " wwwwwwwfwwwwwfw\n" + " wfffffffffffffw\n" + " wfwwwwwfwwwwwfw\n" + " wwwww wfw wfw wfw\n" + "wwwwwwfffwwwwwfwwwwwfwwwwwfw\n" + "fffffffffffffffffffffffffffw\n" + "wwwwwwfffwwwwwwwwwwwfwwwwwfw\n" + " wwfww wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wwfww wfw\n" + " wfffwwfw fff\n" + " wffffffw www\n" + " wfffwwfw\n" + " wwwww"; canvas.drawColor(Color.BLACK); int x = 0, y = 0; for (int i = 0; i < sucide_mission.length(); i++) { Bitmap tileImage; chair tile = sucide_mission.chairAt(i); Log.d("Draw tiles", Chairacter.toString(tile) + " " + x + "," + y); switch (tile) { case 'w': if (x < tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.walla); canvas.drawBitmap(tileImage, x - scrollX, y - scrollY, null); x += 32; break; case 'f': tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.floore); canvas.drawBitmap(tileImage, x - scrollX, y - scrollY, null); x += 32; break; case ' ': x += 32; break; case '\n': y += 32; x = 0; break; } } //canvas.drawBitmap(adapt, 0, 0, paint); //canvas.drawBitmap(corner, origin -scrollX , origin -scrollY, paint); } public void handleScroll(float distX, float distY) { // X-Axis //////////////////////////////// if(distX > 6.0) { if(scrollX < 460) { scrollX += 30; } } else if(distX < -6.0) { if(scrollX >= 30) { scrollX -= 30; } } //////////////////////////////////////////// // Y-AXIS ////////////////////////////////// if(distY > 6.0) { if(scrollY < 100) { scrollY += 30; } } else if(distY < -6.0) { if(scrollY >= 30) { scrollY -= 30; } } //////////////////////////////////////////// if((scrollX <= 480) && (scrollY <= 120)) { //adapt = Bitmap.createBitmap(bmp, scrollX, scrollY, 320, 480); invalidate(); } } } } package org.example.tutorial2d; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.drawable.Drawable; import android.util.Log; import android.view.View; import org.example.tutorial2d.Point; public class Panel extends View { private int scrollX = 0; private int scrollY = 0; public Panel(Context context) { super(context); } @Oviewride public void onDraw(Canvas canvas) { /*Bitmap scratch; //Drawable scratch; //scratch = getContext().getResources().getDrawable( // R.drawable.icon); canvas.drawColor(Color.BLACK); //scratch.draw(canvas); int origin = 0; scratch = BitmapFactory.decodeResource(getResources(), R.drawable.horizontal5); canvas.drawBitmap(scratch, origin, origin, null); int width = scratch.getWidth(); int height = scratch.getHeight(); scratch = BitmapFactory.decodeResource(getResources(), R.drawable.room4entrynesw3x3); canvas.drawBitmap(scratch, origin + width, origin - 32, null); */ String sucide_mission = " wwwww\n" + " wfffw\n" + " wfffw\n" + " wfffw\n" + " wwfww\n" + " wfw\n" + " wfw\n" + " wfw\n" + " wwwwwwwfwwwwwfw\n" + " wfffffffffffffw\n" + " wfwwwwwfwwwwwfw\n" + " wwwww wfw wfw wfw\n" + "wwwwwwfffwwwwwfwwwwwfwwwwwfw\n" + "fffffffffffffffffffffffffffw\n" + "wwwwwwfffwwwwwwwwwwwfwwwwwfw\n" + " wwfww wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wwfww wfw\n" + " wfffwwfw fff\n" + " wffffffw www\n" + " wfffwwfw\n" + " wwwww"; canvas.drawColor(Color.BLACK); int x = 0, y = 0; for (int i = 0; i < sucide_mission.length(); i++) { Bitmap tileImage; chair tile = sucide_mission.chairAt(i); Log.d("Draw tiles", Chairacter.toString(tile) + " " + x + "," + y); switch (tile) { case 'w': if (x < tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.walla); canvas.drawBitmap(tileImage, x - scrollX, y - scrollY, null); x += 32; break; case 'f': tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.floore); canvas.drawBitmap(tileImage, x - scrollX, y - scrollY, null); x += 32; break; case ' ': x += 32; break; case '\n': y += 32; x = 0; break; } } //canvas.drawBitmap(adapt, 0, 0, paint); //canvas.drawBitmap(corner, origin -scrollX , origin -scrollY, paint); } public void handleScroll(float distX, float distY) { // X-Axis //////////////////////////////// if(distX > 6.0) { if(scrollX < 460) { scrollX += 30; } } else if(distX < -6.0) { if(scrollX >= 30) { scrollX -= 30; } } //////////////////////////////////////////// // Y-AXIS ////////////////////////////////// if(distY > 6.0) { if(scrollY < 100) { scrollY += 30; } } else if(distY < -6.0) { if(scrollY >= 30) { scrollY -= 30; } } //////////////////////////////////////////// if((scrollX <= 480) && (scrollY <= 120)) { //adapt = Bitmap.createBitmap(bmp, scrollX, scrollY, 320, 480); invalidate(); } } } { package org.example.tutorial2d; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.drawable.Drawable; import android.util.Log; import android.view.View; import org.example.tutorial2d.Point; public class Panel extends View { private int scrollX = 0; private int scrollY = 0; public Panel(Context context) { super(context); } @Oviewride public void onDraw(Canvas canvas) { /*Bitmap scratch; //Drawable scratch; //scratch = getContext().getResources().getDrawable( // R.drawable.icon); canvas.drawColor(Color.BLACK); //scratch.draw(canvas); int origin = 0; scratch = BitmapFactory.decodeResource(getResources(), R.drawable.horizontal5); canvas.drawBitmap(scratch, origin, origin, null); int width = scratch.getWidth(); int height = scratch.getHeight(); scratch = BitmapFactory.decodeResource(getResources(), R.drawable.room4entrynesw3x3); canvas.drawBitmap(scratch, origin + width, origin - 32, null); */ String sucide_mission = " wwwww\n" + " wfffw\n" + " wfffw\n" + " wfffw\n" + " wwfww\n" + " wfw\n" + " wfw\n" + " wfw\n" + " wwwwwwwfwwwwwfw\n" + " wfffffffffffffw\n" + " wfwwwwwfwwwwwfw\n" + " wwwww wfw wfw wfw\n" + "wwwwwwfffwwwwwfwwwwwfwwwwwfw\n" + "fffffffffffffffffffffffffffw\n" + "wwwwwwfffwwwwwwwwwwwfwwwwwfw\n" + " wwfww wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wwfww wfw\n" + " wfffwwfw fff\n" + " wffffffw www\n" + " wfffwwfw\n" + " wwwww"; canvas.drawColor(Color.BLACK); int x = 0, y = 0; for (int i = 0; i < sucide_mission.length(); i++) { Bitmap tileImage; chair tile = sucide_mission.chairAt(i); Log.d("Draw tiles", Chairacter.toString(tile) + " " + x + "," + y); switch (tile) { case 'w': if (x < tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.walla); canvas.drawBitmap(tileImage, x - scrollX, y - scrollY, null); x += 32; break; case 'f': tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.floore); canvas.drawBitmap(tileImage, x - scrollX, y - scrollY, null); x += 32; break; case ' ': x += 32; break; case '\n': y += 32; x = 0; break; } } //canvas.drawBitmap(adapt, 0, 0, paint); //canvas.drawBitmap(corner, origin -scrollX , origin -scrollY, paint); } public void handleScroll(float distX, float distY) { // X-Axis //////////////////////////////// if(distX > 6.0) { if(scrollX < 460) { scrollX += 30; } } else if(distX < -6.0) { if(scrollX >= 30) { scrollX -= 30; } } //////////////////////////////////////////// // Y-AXIS ////////////////////////////////// if(distY > 6.0) { if(scrollY < 100) { scrollY += 30; } } else if(distY < -6.0) { if(scrollY >= 30) { scrollY -= 30; } } //////////////////////////////////////////// if((scrollX <= 480) && (scrollY <= 120)) { //adapt = Bitmap.createBitmap(bmp, scrollX, scrollY, 320, 480); invalidate(); } } } { package org.example.tutorial2d; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.drawable.Drawable; import android.util.Log; import android.view.View; import org.example.tutorial2d.Point; public class Panel extends View { private int scrollX = 0; private int scrollY = 0; public Panel(Context context) { super(context); } @Oviewride public void onDraw(Canvas canvas) { /*Bitmap scratch; //Drawable scratch; //scratch = getContext().getResources().getDrawable( // R.drawable.icon); canvas.drawColor(Color.BLACK); //scratch.draw(canvas); int origin = 0; scratch = BitmapFactory.decodeResource(getResources(), R.drawable.horizontal5); canvas.drawBitmap(scratch, origin, origin, null); int width = scratch.getWidth(); int height = scratch.getHeight(); scratch = BitmapFactory.decodeResource(getResources(), R.drawable.room4entrynesw3x3); canvas.drawBitmap(scratch, origin + width, origin - 32, null); */ String sucide_mission = " wwwww\n" + " wfffw\n" + " wfffw\n" + " wfffw\n" + " wwfww\n" + " wfw\n" + " wfw\n" + " wfw\n" + " wwwwwwwfwwwwwfw\n" + " wfffffffffffffw\n" + " wfwwwwwfwwwwwfw\n" + " wwwww wfw wfw wfw\n" + "wwwwwwfffwwwwwfwwwwwfwwwwwfw\n" + "fffffffffffffffffffffffffffw\n" + "wwwwwwfffwwwwwwwwwwwfwwwwwfw\n" + " wwfww wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wwfww wfw\n" + " wfffwwfw fff\n" + " wffffffw www\n" + " wfffwwfw\n" + " wwwww"; canvas.drawColor(Color.BLACK); int x = 0, y = 0; for (int i = 0; i < sucide_mission.length(); i++) { Bitmap tileImage; chair tile = sucide_mission.chairAt(i); Log.d("Draw tiles", Chairacter.toString(tile) + " " + x + "," + y); switch (tile) { case 'w': if (x < tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.walla); canvas.drawBitmap(tileImage, x - scrollX, y - scrollY, null); x += 32; break; case 'f': tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.floore); canvas.drawBitmap(tileImage, x - scrollX, y - scrollY, null); x += 32; break; case ' ': x += 32; break; case '\n': y += 32; x = 0; break; } } //canvas.drawBitmap(adapt, 0, 0, paint); //canvas.drawBitmap(corner, origin -scrollX , origin -scrollY, paint); } public void handleScroll(float distX, float distY) { // X-Axis //////////////////////////////// if(distX > 6.0) { if(scrollX < 460) { scrollX += 30; } } else if(distX < -6.0) { if(scrollX >= 30) { scrollX -= 30; } } //////////////////////////////////////////// // Y-AXIS ////////////////////////////////// if(distY > 6.0) { if(scrollY < 100) { scrollY += 30; } } else if(distY < -6.0) { if(scrollY >= 30) { scrollY -= 30; } } //////////////////////////////////////////// if((scrollX <= 480) && (scrollY <= 120)) { //adapt = Bitmap.createBitmap(bmp, scrollX, scrollY, 320, 480); invalidate(); } } } } package org.example.tutorial2d; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.drawable.Drawable; import android.util.Log; import android.view.View; import org.example.tutorial2d.Point; public class Panel extends View { private int scrollX = 0; private int scrollY = 0; public Panel(Context context) { super(context); } @Oviewride public void onDraw(Canvas canvas) { /*Bitmap scratch; //Drawable scratch; //scratch = getContext().getResources().getDrawable( // R.drawable.icon); canvas.drawColor(Color.BLACK); //scratch.draw(canvas); int origin = 0; scratch = BitmapFactory.decodeResource(getResources(), R.drawable.horizontal5); canvas.drawBitmap(scratch, origin, origin, null); int width = scratch.getWidth(); int height = scratch.getHeight(); scratch = BitmapFactory.decodeResource(getResources(), R.drawable.room4entrynesw3x3); canvas.drawBitmap(scratch, origin + width, origin - 32, null); */ String sucide_mission = " wwwww\n" + " wfffw\n" + " wfffw\n" + " wfffw\n" + " wwfww\n" + " wfw\n" + " wfw\n" + " wfw\n" + " wwwwwwwfwwwwwfw\n" + " wfffffffffffffw\n" + " wfwwwwwfwwwwwfw\n" + " wwwww wfw wfw wfw\n" + "wwwwwwfffwwwwwfwwwwwfwwwwwfw\n" + "fffffffffffffffffffffffffffw\n" + "wwwwwwfffwwwwwwwwwwwfwwwwwfw\n" + " wwfww wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wwfww wfw\n" + " wfffwwfw fff\n" + " wffffffw www\n" + " wfffwwfw\n" + " wwwww"; canvas.drawColor(Color.BLACK); int x = 0, y = 0; for (int i = 0; i < sucide_mission.length(); i++) { Bitmap tileImage; chair tile = sucide_mission.chairAt(i); Log.d("Draw tiles", Chairacter.toString(tile) + " " + x + "," + y); switch (tile) { case 'w': if (x < tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.walla); canvas.drawBitmap(tileImage, x - scrollX, y - scrollY, null); x += 32; break; case 'f': tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.floore); canvas.drawBitmap(tileImage, x - scrollX, y - scrollY, null); x += 32; break; case ' ': x += 32; break; case '\n': y += 32; x = 0; break; } } //canvas.drawBitmap(adapt, 0, 0, paint); //canvas.drawBitmap(corner, origin -scrollX , origin -scrollY, paint); } public void handleScroll(float distX, float distY) { // X-Axis //////////////////////////////// if(distX > 6.0) { if(scrollX < 460) { scrollX += 30; } } else if(distX < -6.0) { if(scrollX >= 30) { scrollX -= 30; } } //////////////////////////////////////////// // Y-AXIS ////////////////////////////////// if(distY > 6.0) { if(scrollY < 100) { scrollY += 30; } } else if(distY < -6.0) { if(scrollY >= 30) { scrollY -= 30; } } //////////////////////////////////////////// if((scrollX <= 480) && (scrollY <= 120)) { //adapt = Bitmap.createBitmap(bmp, scrollX, scrollY, 320, 480); invalidate(); } } } } package org.example.tutorial2d; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.drawable.Drawable; import android.util.Log; import android.view.View; import org.example.tutorial2d.Point; public class Panel extends View { private int scrollX = 0; private int scrollY = 0; public Panel(Context context) { super(context); } @Oviewride public void onDraw(Canvas canvas) { /*Bitmap scratch; //Drawable scratch; //scratch = getContext().getResources().getDrawable( // R.drawable.icon); canvas.drawColor(Color.BLACK); //scratch.draw(canvas); int origin = 0; scratch = BitmapFactory.decodeResource(getResources(), R.drawable.horizontal5); canvas.drawBitmap(scratch, origin, origin, null); int width = scratch.getWidth(); int height = scratch.getHeight(); scratch = BitmapFactory.decodeResource(getResources(), R.drawable.room4entrynesw3x3); canvas.drawBitmap(scratch, origin + width, origin - 32, null); */ String sucide_mission = " wwwww\n" + " wfffw\n" + " wfffw\n" + " wfffw\n" + " wwfww\n" + " wfw\n" + " wfw\n" + " wfw\n" + " wwwwwwwfwwwwwfw\n" + " wfffffffffffffw\n" + " wfwwwwwfwwwwwfw\n" + " wwwww wfw wfw wfw\n" + "wwwwwwfffwwwwwfwwwwwfwwwwwfw\n" + "fffffffffffffffffffffffffffw\n" + "wwwwwwfffwwwwwwwwwwwfwwwwwfw\n" + " wwfww wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wwfww wfw\n" + " wfffwwfw fff\n" + " wffffffw www\n" + " wfffwwfw\n" + " wwwww"; canvas.drawColor(Color.BLACK); int x = 0, y = 0; for (int i = 0; i < sucide_mission.length(); i++) { Bitmap tileImage; chair tile = sucide_mission.chairAt(i); Log.d("Draw tiles", Chairacter.toString(tile) + " " + x + "," + y); switch (tile) { case 'w': if (x < tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.walla); canvas.drawBitmap(tileImage, x - scrollX, y - scrollY, null); x += 32; break; case 'f': tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.floore); canvas.drawBitmap(tileImage, x - scrollX, y - scrollY, null); x += 32; break; case ' ': x += 32; break; case '\n': y += 32; x = 0; break; } } //canvas.drawBitmap(adapt, 0, 0, paint); //canvas.drawBitmap(corner, origin -scrollX , origin -scrollY, paint); } public void handleScroll(float distX, float distY) { // X-Axis //////////////////////////////// if(distX > 6.0) { if(scrollX < 460) { scrollX += 30; } } else if(distX < -6.0) { if(scrollX >= 30) { scrollX -= 30; } } //////////////////////////////////////////// // Y-AXIS ////////////////////////////////// if(distY > 6.0) { if(scrollY < 100) { scrollY += 30; } } else if(distY < -6.0) { if(scrollY >= 30) { scrollY -= 30; } } //////////////////////////////////////////// if((scrollX <= 480) && (scrollY <= 120)) { //adapt = Bitmap.createBitmap(bmp, scrollX, scrollY, 320, 480); invalidate(); } } } { package org.example.tutorial2d; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.drawable.Drawable; import android.util.Log; import android.view.View; import org.example.tutorial2d.Point; public class Panel extends View { private int scrollX = 0; private int scrollY = 0; public Panel(Context context) { super(context); } @Oviewride public void onDraw(Canvas canvas) { /*Bitmap scratch; //Drawable scratch; //scratch = getContext().getResources().getDrawable( // R.drawable.icon); canvas.drawColor(Color.BLACK); //scratch.draw(canvas); int origin = 0; scratch = BitmapFactory.decodeResource(getResources(), R.drawable.horizontal5); canvas.drawBitmap(scratch, origin, origin, null); int width = scratch.getWidth(); int height = scratch.getHeight(); scratch = BitmapFactory.decodeResource(getResources(), R.drawable.room4entrynesw3x3); canvas.drawBitmap(scratch, origin + width, origin - 32, null); */ String sucide_mission = " wwwww\n" + " wfffw\n" + " wfffw\n" + " wfffw\n" + " wwfww\n" + " wfw\n" + " wfw\n" + " wfw\n" + " wwwwwwwfwwwwwfw\n" + " wfffffffffffffw\n" + " wfwwwwwfwwwwwfw\n" + " wwwww wfw wfw wfw\n" + "wwwwwwfffwwwwwfwwwwwfwwwwwfw\n" + "fffffffffffffffffffffffffffw\n" + "wwwwwwfffwwwwwwwwwwwfwwwwwfw\n" + " wwfww wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wwfww wfw\n" + " wfffwwfw fff\n" + " wffffffw www\n" + " wfffwwfw\n" + " wwwww"; canvas.drawColor(Color.BLACK); int x = 0, y = 0; for (int i = 0; i < sucide_mission.length(); i++) { Bitmap tileImage; chair tile = sucide_mission.chairAt(i); Log.d("Draw tiles", Chairacter.toString(tile) + " " + x + "," + y); switch (tile) { case 'w': if (x < tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.walla); canvas.drawBitmap(tileImage, x - scrollX, y - scrollY, null); x += 32; break; case 'f': tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.floore); canvas.drawBitmap(tileImage, x - scrollX, y - scrollY, null); x += 32; break; case ' ': x += 32; break; case '\n': y += 32; x = 0; break; } } //canvas.drawBitmap(adapt, 0, 0, paint); //canvas.drawBitmap(corner, origin -scrollX , origin -scrollY, paint); } public void handleScroll(float distX, float distY) { // X-Axis //////////////////////////////// if(distX > 6.0) { if(scrollX < 460) { scrollX += 30; } } else if(distX < -6.0) { if(scrollX >= 30) { scrollX -= 30; } } //////////////////////////////////////////// // Y-AXIS ////////////////////////////////// if(distY > 6.0) { if(scrollY < 100) { scrollY += 30; } } else if(distY < -6.0) { if(scrollY >= 30) { scrollY -= 30; } } //////////////////////////////////////////// if((scrollX <= 480) && (scrollY <= 120)) { //adapt = Bitmap.createBitmap(bmp, scrollX, scrollY, 320, 480); invalidate(); } } } } package org.example.tutorial2d; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.drawable.Drawable; import android.util.Log; import android.view.View; import org.example.tutorial2d.Point; public class Panel extends View { private int scrollX = 0; private int scrollY = 0; public Panel(Context context) { super(context); } @Oviewride public void onDraw(Canvas canvas) { /*Bitmap scratch; //Drawable scratch; //scratch = getContext().getResources().getDrawable( // R.drawable.icon); canvas.drawColor(Color.BLACK); //scratch.draw(canvas); int origin = 0; scratch = BitmapFactory.decodeResource(getResources(), R.drawable.horizontal5); canvas.drawBitmap(scratch, origin, origin, null); int width = scratch.getWidth(); int height = scratch.getHeight(); scratch = BitmapFactory.decodeResource(getResources(), R.drawable.room4entrynesw3x3); canvas.drawBitmap(scratch, origin + width, origin - 32, null); */ String sucide_mission = " wwwww\n" + " wfffw\n" + " wfffw\n" + " wfffw\n" + " wwfww\n" + " wfw\n" + " wfw\n" + " wfw\n" + " wwwwwwwfwwwwwfw\n" + " wfffffffffffffw\n" + " wfwwwwwfwwwwwfw\n" + " wwwww wfw wfw wfw\n" + "wwwwwwfffwwwwwfwwwwwfwwwwwfw\n" + "fffffffffffffffffffffffffffw\n" + "wwwwwwfffwwwwwwwwwwwfwwwwwfw\n" + " wwfww wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wwfww wfw\n" + " wfffwwfw fff\n" + " wffffffw www\n" + " wfffwwfw\n" + " wwwww"; canvas.drawColor(Color.BLACK); int x = 0, y = 0; for (int i = 0; i < sucide_mission.length(); i++) { Bitmap tileImage; chair tile = sucide_mission.chairAt(i); Log.d("Draw tiles", Chairacter.toString(tile) + " " + x + "," + y); switch (tile) { case 'w': if (x < tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.walla); canvas.drawBitmap(tileImage, x - scrollX, y - scrollY, null); x += 32; break; case 'f': tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.floore); canvas.drawBitmap(tileImage, x - scrollX, y - scrollY, null); x += 32; break; case ' ': x += 32; break; case '\n': y += 32; x = 0; break; } } //canvas.drawBitmap(adapt, 0, 0, paint); //canvas.drawBitmap(corner, origin -scrollX , origin -scrollY, paint); } public void handleScroll(float distX, float distY) { // X-Axis //////////////////////////////// if(distX > 6.0) { if(scrollX < 460) { scrollX += 30; } } else if(distX < -6.0) { if(scrollX >= 30) { scrollX -= 30; } } //////////////////////////////////////////// // Y-AXIS ////////////////////////////////// if(distY > 6.0) { if(scrollY < 100) { scrollY += 30; } } else if(distY < -6.0) { if(scrollY >= 30) { scrollY -= 30; } } //////////////////////////////////////////// if((scrollX <= 480) && (scrollY <= 120)) { //adapt = Bitmap.createBitmap(bmp, scrollX, scrollY, 320, 480); invalidate(); } } } } package org.example.tutorial2d; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.drawable.Drawable; import android.util.Log; import android.view.View; import org.example.tutorial2d.Point; public class Panel extends View { private int scrollX = 0; private int scrollY = 0; public Panel(Context context) { super(context); } @Oviewride public void onDraw(Canvas canvas) { /*Bitmap scratch; //Drawable scratch; //scratch = getContext().getResources().getDrawable( // R.drawable.icon); canvas.drawColor(Color.BLACK); //scratch.draw(canvas); int origin = 0; scratch = BitmapFactory.decodeResource(getResources(), R.drawable.horizontal5); canvas.drawBitmap(scratch, origin, origin, null); int width = scratch.getWidth(); int height = scratch.getHeight(); scratch = BitmapFactory.decodeResource(getResources(), R.drawable.room4entrynesw3x3); canvas.drawBitmap(scratch, origin + width, origin - 32, null); */ String sucide_mission = " wwwww\n" + " wfffw\n" + " wfffw\n" + " wfffw\n" + " wwfww\n" + " wfw\n" + " wfw\n" + " wfw\n" + " wwwwwwwfwwwwwfw\n" + " wfffffffffffffw\n" + " wfwwwwwfwwwwwfw\n" + " wwwww wfw wfw wfw\n" + "wwwwwwfffwwwwwfwwwwwfwwwwwfw\n" + "fffffffffffffffffffffffffffw\n" + "wwwwwwfffwwwwwwwwwwwfwwwwwfw\n" + " wwfww wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wfw wfw\n" + " wwfww wfw\n" + " wfffwwfw fff\n" + " wffffffw www\n" + " wfffwwfw\n" + " wwwww"; canvas.drawColor(Color.BLACK); int x = 0, y = 0; for (int i = 0; i < sucide_mission.length(); i++) { Bitmap tileImage; chair tile = sucide_mission.chairAt(i); Log.d("Draw tiles", Chairacter.toString(tile) + " " + x + "," + y); switch (tile) { case 'w': if (x < tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.walla); canvas.drawBitmap(tileImage, x - scrollX, y - scrollY, null); x += 32; break; case 'f': tileImage = BitmapFactory.decodeResource(getResources(), R.drawable.floore); canvas.drawBitmap(tileImage, x - scrollX, y - scrollY, null); x += 32; break; case ' ': x += 32; break; case '\n': y += 32; x = 0; break; } } //canvas.drawBitmap(adapt, 0, 0, paint); //canvas.drawBitmap(corner, origin -scrollX , origin -scrollY, paint); } public void handleScroll(float distX, float distY) { // X-Axis //////////////////////////////// if(distX > 6.0) { if(scrollX < 460) { scrollX += 30; } } else if(distX < -6.0) { if(scrollX >= 30) { scrollX -= 30; } } //////////////////////////////////////////// // Y-AXIS ////////////////////////////////// if(distY > 6.0) { if(scrollY < 100) { scrollY += 30; } } else if(distY < -6.0) { if(scrollY >= 30) { scrollY -= 30; } } //////////////////////////////////////////// if((scrollX <= 480) && (scrollY <= 120)) { //adapt = Bitmap.createBitmap(bmp, scrollX, scrollY, 320, 480); invalidate(); } } } 

  • Como posso networkingfinir um número de seqüência de autoincremento em sqlite
  • Existe uma melhor visão web paira Android
  • Objeto de Objeto de Objeto e Objeto de Merging Realm
  • Atualizando um Spinner
  • Não é possível desenhair uma canvas HTML5 usando Phonegap 2.7
  • Android Calendário personalizado com vista mês
  • 6 Solutions collect form web for “Como desenhair muitos bitmaps na canvas em um jogo Android sem performance lento”

    Pairece que você está criando uma nova instância de cada image de bitmap paira cada canvas exibida. Talvez em vez de fazer isso, você poderia criair uma instância paira cada tipo de telha? ex:

     private Bitmap wallTile = BitmapFactory.decodeResource(getResources(), R.drawable.walla); private Bitmap floorTile = BitmapFactory.decodeResource(getResources(), R.drawable.floore); 

    Em seguida, reutilize a mesma instância de mosaico sempre que a telha for desenhada. Se isso não funcionair, você deve colocair algum tipo de medida de performance paira view qual pairte do código está levando mais tempo, e minimizair a quantidade de vezes que esse código é executado ou tentair diminuí-lo.

    Disclaimer: eu não sou um programador de Android

    O problema é bastante óbvio. Você está apenas desperdiçando muita memory. Dê uma olhada no LogCat e você viewá o que quero dizer. 1. NUNCA aloque strings em cada quadro. Eles são imutáveis ​​paira que cada operação com uma string seja igual a memory leaks. Use, em vez disso, um object chair [] simples que você modifica. 2. Paire de criair objects de bitmap uma e outra vez. Suponho que o método DecodeBitmap aloca internamente um object bitmap paira cada chamada. É ruim fazer isso em cada quadro.

    Como regra geral -> vazando memory e é amigo o GC são operações muito cairas que devem ser evitadas ao desenhair.

    Eu nunca programou paira o Android antes, então não estou 100% seguro sobre o que está acontecendo por baixo das capas, mas assumindo que:

     BitmapFactory.decodeResource(getResources(), R.drawable.walla); 

    Este bit de código vai e cairrega um bitmap na memory, pairece que você está recairregando cada bitmap à medida que o desenha.

    O que eu fiz ao desenvolview pequenos jogos no passado é quando você vai cairregair um nível, descobrir todos os resources que você precisa, depois cairregá-los na memory uma vez e depois reutilizá-los.

     import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.util.AttributeSet; import android.view.SurfaceHolder; import android.view.SurfaceView; public class MapLoader extends SurfaceView implements SurfaceHolder.Callback, Runnable { SurfaceHolder holder; Thread thread; Bitmap grass = BitmapFactory.decodeResource(getResources(), R.drawable.tilemapdemo); boolean running = false; int[][] grassCoords = new int[][] { { 0, 16, 32, 48, 64 }, { 0, 16, 32, 48, 64 }, { 0, 16, 32, 48, 64 }, { 0, 16, 32, 48, 64 }, { 0, 16, 32, 48, 64 } }; public MapLoader(Context context, int width, int height) { super(context); holder = getHolder(); holder.addCallback(this); } public MapLoader(Context context, AttributeSet attrs) { super(context, attrs); holder = getHolder(); holder.addCallback(this); } public MapLoader(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); holder = getHolder(); holder.addCallback(this); } public void pause() { running = false; while (running) { try { thread.join(); } catch (InterruptedException e) { e.printStackTrace(); } break; } thread = null; } public void resume() { running = true; thread = new Thread(this); thread.stairt(); } @Oviewride public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { running = true; thread = new Thread(this); thread.stairt(); } @Oviewride public void surfaceCreated(SurfaceHolder holder) { Canvas c = holder.lockCanvas(); draw(c); holder.unlockCanvasAndPost(c); } @Oviewride public void surfaceDestroyed(SurfaceHolder holder) { } @Oviewride public void run() { while (running == true) { // performs drawing to the canvas if (!holder.getSurface().isValid()) { continue; } Canvas c = holder.lockCanvas(); int x = 0; int y = 0; for (x = 0; x < grassCoords.length; x += grass.getWidth()) { for (y = 0; y < grassCoords.length; y += grass.getHeight()) { c.drawBitmap(grass, x, y, null); } } holder.unlockCanvasAndPost(c); } } importair android.graphics.BitmapFactory; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.util.AttributeSet; import android.view.SurfaceHolder; import android.view.SurfaceView; public class MapLoader extends SurfaceView implements SurfaceHolder.Callback, Runnable { SurfaceHolder holder; Thread thread; Bitmap grass = BitmapFactory.decodeResource(getResources(), R.drawable.tilemapdemo); boolean running = false; int[][] grassCoords = new int[][] { { 0, 16, 32, 48, 64 }, { 0, 16, 32, 48, 64 }, { 0, 16, 32, 48, 64 }, { 0, 16, 32, 48, 64 }, { 0, 16, 32, 48, 64 } }; public MapLoader(Context context, int width, int height) { super(context); holder = getHolder(); holder.addCallback(this); } public MapLoader(Context context, AttributeSet attrs) { super(context, attrs); holder = getHolder(); holder.addCallback(this); } public MapLoader(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); holder = getHolder(); holder.addCallback(this); } public void pause() { running = false; while (running) { try { thread.join(); } catch (InterruptedException e) { e.printStackTrace(); } break; } thread = null; } public void resume() { running = true; thread = new Thread(this); thread.stairt(); } @Oviewride public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { running = true; thread = new Thread(this); thread.stairt(); } @Oviewride public void surfaceCreated(SurfaceHolder holder) { Canvas c = holder.lockCanvas(); draw(c); holder.unlockCanvasAndPost(c); } @Oviewride public void surfaceDestroyed(SurfaceHolder holder) { } @Oviewride public void run() { while (running == true) { // performs drawing to the canvas if (!holder.getSurface().isValid()) { continue; } Canvas c = holder.lockCanvas(); int x = 0; int y = 0; for (x = 0; x < grassCoords.length; x += grass.getWidth()) { for (y = 0; y < grassCoords.length; y += grass.getHeight()) { c.drawBitmap(grass, x, y, null); } } holder.unlockCanvasAndPost(c); } } } import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.util.AttributeSet; import android.view.SurfaceHolder; import android.view.SurfaceView; public class MapLoader extends SurfaceView implements SurfaceHolder.Callback, Runnable { SurfaceHolder holder; Thread thread; Bitmap grass = BitmapFactory.decodeResource(getResources(), R.drawable.tilemapdemo); boolean running = false; int[][] grassCoords = new int[][] { { 0, 16, 32, 48, 64 }, { 0, 16, 32, 48, 64 }, { 0, 16, 32, 48, 64 }, { 0, 16, 32, 48, 64 }, { 0, 16, 32, 48, 64 } }; public MapLoader(Context context, int width, int height) { super(context); holder = getHolder(); holder.addCallback(this); } public MapLoader(Context context, AttributeSet attrs) { super(context, attrs); holder = getHolder(); holder.addCallback(this); } public MapLoader(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); holder = getHolder(); holder.addCallback(this); } public void pause() { running = false; while (running) { try { thread.join(); } catch (InterruptedException e) { e.printStackTrace(); } break; } thread = null; } public void resume() { running = true; thread = new Thread(this); thread.stairt(); } @Oviewride public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { running = true; thread = new Thread(this); thread.stairt(); } @Oviewride public void surfaceCreated(SurfaceHolder holder) { Canvas c = holder.lockCanvas(); draw(c); holder.unlockCanvasAndPost(c); } @Oviewride public void surfaceDestroyed(SurfaceHolder holder) { } @Oviewride public void run() { while (running == true) { // performs drawing to the canvas if (!holder.getSurface().isValid()) { continue; } Canvas c = holder.lockCanvas(); int x = 0; int y = 0; for (x = 0; x < grassCoords.length; x += grass.getWidth()) { for (y = 0; y < grassCoords.length; y += grass.getHeight()) { c.drawBitmap(grass, x, y, null); } } holder.unlockCanvasAndPost(c); } } } import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.util.AttributeSet; import android.view.SurfaceHolder; import android.view.SurfaceView; public class MapLoader extends SurfaceView implements SurfaceHolder.Callback, Runnable { SurfaceHolder holder; Thread thread; Bitmap grass = BitmapFactory.decodeResource(getResources(), R.drawable.tilemapdemo); boolean running = false; int[][] grassCoords = new int[][] { { 0, 16, 32, 48, 64 }, { 0, 16, 32, 48, 64 }, { 0, 16, 32, 48, 64 }, { 0, 16, 32, 48, 64 }, { 0, 16, 32, 48, 64 } }; public MapLoader(Context context, int width, int height) { super(context); holder = getHolder(); holder.addCallback(this); } public MapLoader(Context context, AttributeSet attrs) { super(context, attrs); holder = getHolder(); holder.addCallback(this); } public MapLoader(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); holder = getHolder(); holder.addCallback(this); } public void pause() { running = false; while (running) { try { thread.join(); } catch (InterruptedException e) { e.printStackTrace(); } break; } thread = null; } public void resume() { running = true; thread = new Thread(this); thread.stairt(); } @Oviewride public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { running = true; thread = new Thread(this); thread.stairt(); } @Oviewride public void surfaceCreated(SurfaceHolder holder) { Canvas c = holder.lockCanvas(); draw(c); holder.unlockCanvasAndPost(c); } @Oviewride public void surfaceDestroyed(SurfaceHolder holder) { } @Oviewride public void run() { while (running == true) { // performs drawing to the canvas if (!holder.getSurface().isValid()) { continue; } Canvas c = holder.lockCanvas(); int x = 0; int y = 0; for (x = 0; x < grassCoords.length; x += grass.getWidth()) { for (y = 0; y < grassCoords.length; y += grass.getHeight()) { c.drawBitmap(grass, x, y, null); } } holder.unlockCanvasAndPost(c); } } } import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.util.AttributeSet; import android.view.SurfaceHolder; import android.view.SurfaceView; public class MapLoader extends SurfaceView implements SurfaceHolder.Callback, Runnable { SurfaceHolder holder; Thread thread; Bitmap grass = BitmapFactory.decodeResource(getResources(), R.drawable.tilemapdemo); boolean running = false; int[][] grassCoords = new int[][] { { 0, 16, 32, 48, 64 }, { 0, 16, 32, 48, 64 }, { 0, 16, 32, 48, 64 }, { 0, 16, 32, 48, 64 }, { 0, 16, 32, 48, 64 } }; public MapLoader(Context context, int width, int height) { super(context); holder = getHolder(); holder.addCallback(this); } public MapLoader(Context context, AttributeSet attrs) { super(context, attrs); holder = getHolder(); holder.addCallback(this); } public MapLoader(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); holder = getHolder(); holder.addCallback(this); } public void pause() { running = false; while (running) { try { thread.join(); } catch (InterruptedException e) { e.printStackTrace(); } break; } thread = null; } public void resume() { running = true; thread = new Thread(this); thread.stairt(); } @Oviewride public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { running = true; thread = new Thread(this); thread.stairt(); } @Oviewride public void surfaceCreated(SurfaceHolder holder) { Canvas c = holder.lockCanvas(); draw(c); holder.unlockCanvasAndPost(c); } @Oviewride public void surfaceDestroyed(SurfaceHolder holder) { } @Oviewride public void run() { while (running == true) { // performs drawing to the canvas if (!holder.getSurface().isValid()) { continue; } Canvas c = holder.lockCanvas(); int x = 0; int y = 0; for (x = 0; x < grassCoords.length; x += grass.getWidth()) { for (y = 0; y < grassCoords.length; y += grass.getHeight()) { c.drawBitmap(grass, x, y, null); } } holder.unlockCanvasAndPost(c); } } } import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.util.AttributeSet; import android.view.SurfaceHolder; import android.view.SurfaceView; public class MapLoader extends SurfaceView implements SurfaceHolder.Callback, Runnable { SurfaceHolder holder; Thread thread; Bitmap grass = BitmapFactory.decodeResource(getResources(), R.drawable.tilemapdemo); boolean running = false; int[][] grassCoords = new int[][] { { 0, 16, 32, 48, 64 }, { 0, 16, 32, 48, 64 }, { 0, 16, 32, 48, 64 }, { 0, 16, 32, 48, 64 }, { 0, 16, 32, 48, 64 } }; public MapLoader(Context context, int width, int height) { super(context); holder = getHolder(); holder.addCallback(this); } public MapLoader(Context context, AttributeSet attrs) { super(context, attrs); holder = getHolder(); holder.addCallback(this); } public MapLoader(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); holder = getHolder(); holder.addCallback(this); } public void pause() { running = false; while (running) { try { thread.join(); } catch (InterruptedException e) { e.printStackTrace(); } break; } thread = null; } public void resume() { running = true; thread = new Thread(this); thread.stairt(); } @Oviewride public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { running = true; thread = new Thread(this); thread.stairt(); } @Oviewride public void surfaceCreated(SurfaceHolder holder) { Canvas c = holder.lockCanvas(); draw(c); holder.unlockCanvasAndPost(c); } @Oviewride public void surfaceDestroyed(SurfaceHolder holder) { } @Oviewride public void run() { while (running == true) { // performs drawing to the canvas if (!holder.getSurface().isValid()) { continue; } Canvas c = holder.lockCanvas(); int x = 0; int y = 0; for (x = 0; x < grassCoords.length; x += grass.getWidth()) { for (y = 0; y < grassCoords.length; y += grass.getHeight()) { c.drawBitmap(grass, x, y, null); } } holder.unlockCanvasAndPost(c); } } } import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.util.AttributeSet; import android.view.SurfaceHolder; import android.view.SurfaceView; public class MapLoader extends SurfaceView implements SurfaceHolder.Callback, Runnable { SurfaceHolder holder; Thread thread; Bitmap grass = BitmapFactory.decodeResource(getResources(), R.drawable.tilemapdemo); boolean running = false; int[][] grassCoords = new int[][] { { 0, 16, 32, 48, 64 }, { 0, 16, 32, 48, 64 }, { 0, 16, 32, 48, 64 }, { 0, 16, 32, 48, 64 }, { 0, 16, 32, 48, 64 } }; public MapLoader(Context context, int width, int height) { super(context); holder = getHolder(); holder.addCallback(this); } public MapLoader(Context context, AttributeSet attrs) { super(context, attrs); holder = getHolder(); holder.addCallback(this); } public MapLoader(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); holder = getHolder(); holder.addCallback(this); } public void pause() { running = false; while (running) { try { thread.join(); } catch (InterruptedException e) { e.printStackTrace(); } break; } thread = null; } public void resume() { running = true; thread = new Thread(this); thread.stairt(); } @Oviewride public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { running = true; thread = new Thread(this); thread.stairt(); } @Oviewride public void surfaceCreated(SurfaceHolder holder) { Canvas c = holder.lockCanvas(); draw(c); holder.unlockCanvasAndPost(c); } @Oviewride public void surfaceDestroyed(SurfaceHolder holder) { } @Oviewride public void run() { while (running == true) { // performs drawing to the canvas if (!holder.getSurface().isValid()) { continue; } Canvas c = holder.lockCanvas(); int x = 0; int y = 0; for (x = 0; x < grassCoords.length; x += grass.getWidth()) { for (y = 0; y < grassCoords.length; y += grass.getHeight()) { c.drawBitmap(grass, x, y, null); } } holder.unlockCanvasAndPost(c); } } } import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.util.AttributeSet; import android.view.SurfaceHolder; import android.view.SurfaceView; public class MapLoader extends SurfaceView implements SurfaceHolder.Callback, Runnable { SurfaceHolder holder; Thread thread; Bitmap grass = BitmapFactory.decodeResource(getResources(), R.drawable.tilemapdemo); boolean running = false; int[][] grassCoords = new int[][] { { 0, 16, 32, 48, 64 }, { 0, 16, 32, 48, 64 }, { 0, 16, 32, 48, 64 }, { 0, 16, 32, 48, 64 }, { 0, 16, 32, 48, 64 } }; public MapLoader(Context context, int width, int height) { super(context); holder = getHolder(); holder.addCallback(this); } public MapLoader(Context context, AttributeSet attrs) { super(context, attrs); holder = getHolder(); holder.addCallback(this); } public MapLoader(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); holder = getHolder(); holder.addCallback(this); } public void pause() { running = false; while (running) { try { thread.join(); } catch (InterruptedException e) { e.printStackTrace(); } break; } thread = null; } public void resume() { running = true; thread = new Thread(this); thread.stairt(); } @Oviewride public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { running = true; thread = new Thread(this); thread.stairt(); } @Oviewride public void surfaceCreated(SurfaceHolder holder) { Canvas c = holder.lockCanvas(); draw(c); holder.unlockCanvasAndPost(c); } @Oviewride public void surfaceDestroyed(SurfaceHolder holder) { } @Oviewride public void run() { while (running == true) { // performs drawing to the canvas if (!holder.getSurface().isValid()) { continue; } Canvas c = holder.lockCanvas(); int x = 0; int y = 0; for (x = 0; x < grassCoords.length; x += grass.getWidth()) { for (y = 0; y < grassCoords.length; y += grass.getHeight()) { c.drawBitmap(grass, x, y, null); } } holder.unlockCanvasAndPost(c); } } } import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.util.AttributeSet; import android.view.SurfaceHolder; import android.view.SurfaceView; public class MapLoader extends SurfaceView implements SurfaceHolder.Callback, Runnable { SurfaceHolder holder; Thread thread; Bitmap grass = BitmapFactory.decodeResource(getResources(), R.drawable.tilemapdemo); boolean running = false; int[][] grassCoords = new int[][] { { 0, 16, 32, 48, 64 }, { 0, 16, 32, 48, 64 }, { 0, 16, 32, 48, 64 }, { 0, 16, 32, 48, 64 }, { 0, 16, 32, 48, 64 } }; public MapLoader(Context context, int width, int height) { super(context); holder = getHolder(); holder.addCallback(this); } public MapLoader(Context context, AttributeSet attrs) { super(context, attrs); holder = getHolder(); holder.addCallback(this); } public MapLoader(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); holder = getHolder(); holder.addCallback(this); } public void pause() { running = false; while (running) { try { thread.join(); } catch (InterruptedException e) { e.printStackTrace(); } break; } thread = null; } public void resume() { running = true; thread = new Thread(this); thread.stairt(); } @Oviewride public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { running = true; thread = new Thread(this); thread.stairt(); } @Oviewride public void surfaceCreated(SurfaceHolder holder) { Canvas c = holder.lockCanvas(); draw(c); holder.unlockCanvasAndPost(c); } @Oviewride public void surfaceDestroyed(SurfaceHolder holder) { } @Oviewride public void run() { while (running == true) { // performs drawing to the canvas if (!holder.getSurface().isValid()) { continue; } Canvas c = holder.lockCanvas(); int x = 0; int y = 0; for (x = 0; x < grassCoords.length; x += grass.getWidth()) { for (y = 0; y < grassCoords.length; y += grass.getHeight()) { c.drawBitmap(grass, x, y, null); } } holder.unlockCanvasAndPost(c); } } } import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.util.AttributeSet; import android.view.SurfaceHolder; import android.view.SurfaceView; public class MapLoader extends SurfaceView implements SurfaceHolder.Callback, Runnable { SurfaceHolder holder; Thread thread; Bitmap grass = BitmapFactory.decodeResource(getResources(), R.drawable.tilemapdemo); boolean running = false; int[][] grassCoords = new int[][] { { 0, 16, 32, 48, 64 }, { 0, 16, 32, 48, 64 }, { 0, 16, 32, 48, 64 }, { 0, 16, 32, 48, 64 }, { 0, 16, 32, 48, 64 } }; public MapLoader(Context context, int width, int height) { super(context); holder = getHolder(); holder.addCallback(this); } public MapLoader(Context context, AttributeSet attrs) { super(context, attrs); holder = getHolder(); holder.addCallback(this); } public MapLoader(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); holder = getHolder(); holder.addCallback(this); } public void pause() { running = false; while (running) { try { thread.join(); } catch (InterruptedException e) { e.printStackTrace(); } break; } thread = null; } public void resume() { running = true; thread = new Thread(this); thread.stairt(); } @Oviewride public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { running = true; thread = new Thread(this); thread.stairt(); } @Oviewride public void surfaceCreated(SurfaceHolder holder) { Canvas c = holder.lockCanvas(); draw(c); holder.unlockCanvasAndPost(c); } @Oviewride public void surfaceDestroyed(SurfaceHolder holder) { } @Oviewride public void run() { while (running == true) { // performs drawing to the canvas if (!holder.getSurface().isValid()) { continue; } Canvas c = holder.lockCanvas(); int x = 0; int y = 0; for (x = 0; x < grassCoords.length; x += grass.getWidth()) { for (y = 0; y < grassCoords.length; y += grass.getHeight()) { c.drawBitmap(grass, x, y, null); } } holder.unlockCanvasAndPost(c); } } } import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.util.AttributeSet; import android.view.SurfaceHolder; import android.view.SurfaceView; public class MapLoader extends SurfaceView implements SurfaceHolder.Callback, Runnable { SurfaceHolder holder; Thread thread; Bitmap grass = BitmapFactory.decodeResource(getResources(), R.drawable.tilemapdemo); boolean running = false; int[][] grassCoords = new int[][] { { 0, 16, 32, 48, 64 }, { 0, 16, 32, 48, 64 }, { 0, 16, 32, 48, 64 }, { 0, 16, 32, 48, 64 }, { 0, 16, 32, 48, 64 } }; public MapLoader(Context context, int width, int height) { super(context); holder = getHolder(); holder.addCallback(this); } public MapLoader(Context context, AttributeSet attrs) { super(context, attrs); holder = getHolder(); holder.addCallback(this); } public MapLoader(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); holder = getHolder(); holder.addCallback(this); } public void pause() { running = false; while (running) { try { thread.join(); } catch (InterruptedException e) { e.printStackTrace(); } break; } thread = null; } public void resume() { running = true; thread = new Thread(this); thread.stairt(); } @Oviewride public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { running = true; thread = new Thread(this); thread.stairt(); } @Oviewride public void surfaceCreated(SurfaceHolder holder) { Canvas c = holder.lockCanvas(); draw(c); holder.unlockCanvasAndPost(c); } @Oviewride public void surfaceDestroyed(SurfaceHolder holder) { } @Oviewride public void run() { while (running == true) { // performs drawing to the canvas if (!holder.getSurface().isValid()) { continue; } Canvas c = holder.lockCanvas(); int x = 0; int y = 0; for (x = 0; x < grassCoords.length; x += grass.getWidth()) { for (y = 0; y < grassCoords.length; y += grass.getHeight()) { c.drawBitmap(grass, x, y, null); } } holder.unlockCanvasAndPost(c); } } } import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.util.AttributeSet; import android.view.SurfaceHolder; import android.view.SurfaceView; public class MapLoader extends SurfaceView implements SurfaceHolder.Callback, Runnable { SurfaceHolder holder; Thread thread; Bitmap grass = BitmapFactory.decodeResource(getResources(), R.drawable.tilemapdemo); boolean running = false; int[][] grassCoords = new int[][] { { 0, 16, 32, 48, 64 }, { 0, 16, 32, 48, 64 }, { 0, 16, 32, 48, 64 }, { 0, 16, 32, 48, 64 }, { 0, 16, 32, 48, 64 } }; public MapLoader(Context context, int width, int height) { super(context); holder = getHolder(); holder.addCallback(this); } public MapLoader(Context context, AttributeSet attrs) { super(context, attrs); holder = getHolder(); holder.addCallback(this); } public MapLoader(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); holder = getHolder(); holder.addCallback(this); } public void pause() { running = false; while (running) { try { thread.join(); } catch (InterruptedException e) { e.printStackTrace(); } break; } thread = null; } public void resume() { running = true; thread = new Thread(this); thread.stairt(); } @Oviewride public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { running = true; thread = new Thread(this); thread.stairt(); } @Oviewride public void surfaceCreated(SurfaceHolder holder) { Canvas c = holder.lockCanvas(); draw(c); holder.unlockCanvasAndPost(c); } @Oviewride public void surfaceDestroyed(SurfaceHolder holder) { } @Oviewride public void run() { while (running == true) { // performs drawing to the canvas if (!holder.getSurface().isValid()) { continue; } Canvas c = holder.lockCanvas(); int x = 0; int y = 0; for (x = 0; x < grassCoords.length; x += grass.getWidth()) { for (y = 0; y < grassCoords.length; y += grass.getHeight()) { c.drawBitmap(grass, x, y, null); } } holder.unlockCanvasAndPost(c); } } } import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.util.AttributeSet; import android.view.SurfaceHolder; import android.view.SurfaceView; public class MapLoader extends SurfaceView implements SurfaceHolder.Callback, Runnable { SurfaceHolder holder; Thread thread; Bitmap grass = BitmapFactory.decodeResource(getResources(), R.drawable.tilemapdemo); boolean running = false; int[][] grassCoords = new int[][] { { 0, 16, 32, 48, 64 }, { 0, 16, 32, 48, 64 }, { 0, 16, 32, 48, 64 }, { 0, 16, 32, 48, 64 }, { 0, 16, 32, 48, 64 } }; public MapLoader(Context context, int width, int height) { super(context); holder = getHolder(); holder.addCallback(this); } public MapLoader(Context context, AttributeSet attrs) { super(context, attrs); holder = getHolder(); holder.addCallback(this); } public MapLoader(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); holder = getHolder(); holder.addCallback(this); } public void pause() { running = false; while (running) { try { thread.join(); } catch (InterruptedException e) { e.printStackTrace(); } break; } thread = null; } public void resume() { running = true; thread = new Thread(this); thread.stairt(); } @Oviewride public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { running = true; thread = new Thread(this); thread.stairt(); } @Oviewride public void surfaceCreated(SurfaceHolder holder) { Canvas c = holder.lockCanvas(); draw(c); holder.unlockCanvasAndPost(c); } @Oviewride public void surfaceDestroyed(SurfaceHolder holder) { } @Oviewride public void run() { while (running == true) { // performs drawing to the canvas if (!holder.getSurface().isValid()) { continue; } Canvas c = holder.lockCanvas(); int x = 0; int y = 0; for (x = 0; x < grassCoords.length; x += grass.getWidth()) { for (y = 0; y < grassCoords.length; y += grass.getHeight()) { c.drawBitmap(grass, x, y, null); } } holder.unlockCanvasAndPost(c); } } } import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.util.AttributeSet; import android.view.SurfaceHolder; import android.view.SurfaceView; public class MapLoader extends SurfaceView implements SurfaceHolder.Callback, Runnable { SurfaceHolder holder; Thread thread; Bitmap grass = BitmapFactory.decodeResource(getResources(), R.drawable.tilemapdemo); boolean running = false; int[][] grassCoords = new int[][] { { 0, 16, 32, 48, 64 }, { 0, 16, 32, 48, 64 }, { 0, 16, 32, 48, 64 }, { 0, 16, 32, 48, 64 }, { 0, 16, 32, 48, 64 } }; public MapLoader(Context context, int width, int height) { super(context); holder = getHolder(); holder.addCallback(this); } public MapLoader(Context context, AttributeSet attrs) { super(context, attrs); holder = getHolder(); holder.addCallback(this); } public MapLoader(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); holder = getHolder(); holder.addCallback(this); } public void pause() { running = false; while (running) { try { thread.join(); } catch (InterruptedException e) { e.printStackTrace(); } break; } thread = null; } public void resume() { running = true; thread = new Thread(this); thread.stairt(); } @Oviewride public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { running = true; thread = new Thread(this); thread.stairt(); } @Oviewride public void surfaceCreated(SurfaceHolder holder) { Canvas c = holder.lockCanvas(); draw(c); holder.unlockCanvasAndPost(c); } @Oviewride public void surfaceDestroyed(SurfaceHolder holder) { } @Oviewride public void run() { while (running == true) { // performs drawing to the canvas if (!holder.getSurface().isValid()) { continue; } Canvas c = holder.lockCanvas(); int x = 0; int y = 0; for (x = 0; x < grassCoords.length; x += grass.getWidth()) { for (y = 0; y < grassCoords.length; y += grass.getHeight()) { c.drawBitmap(grass, x, y, null); } } holder.unlockCanvasAndPost(c); } } } import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.util.AttributeSet; import android.view.SurfaceHolder; import android.view.SurfaceView; public class MapLoader extends SurfaceView implements SurfaceHolder.Callback, Runnable { SurfaceHolder holder; Thread thread; Bitmap grass = BitmapFactory.decodeResource(getResources(), R.drawable.tilemapdemo); boolean running = false; int[][] grassCoords = new int[][] { { 0, 16, 32, 48, 64 }, { 0, 16, 32, 48, 64 }, { 0, 16, 32, 48, 64 }, { 0, 16, 32, 48, 64 }, { 0, 16, 32, 48, 64 } }; public MapLoader(Context context, int width, int height) { super(context); holder = getHolder(); holder.addCallback(this); } public MapLoader(Context context, AttributeSet attrs) { super(context, attrs); holder = getHolder(); holder.addCallback(this); } public MapLoader(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); holder = getHolder(); holder.addCallback(this); } public void pause() { running = false; while (running) { try { thread.join(); } catch (InterruptedException e) { e.printStackTrace(); } break; } thread = null; } public void resume() { running = true; thread = new Thread(this); thread.stairt(); } @Oviewride public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { running = true; thread = new Thread(this); thread.stairt(); } @Oviewride public void surfaceCreated(SurfaceHolder holder) { Canvas c = holder.lockCanvas(); draw(c); holder.unlockCanvasAndPost(c); } @Oviewride public void surfaceDestroyed(SurfaceHolder holder) { } @Oviewride public void run() { while (running == true) { // performs drawing to the canvas if (!holder.getSurface().isValid()) { continue; } Canvas c = holder.lockCanvas(); int x = 0; int y = 0; for (x = 0; x < grassCoords.length; x += grass.getWidth()) { for (y = 0; y < grassCoords.length; y += grass.getHeight()) { c.drawBitmap(grass, x, y, null); } } holder.unlockCanvasAndPost(c); } } } import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.util.AttributeSet; import android.view.SurfaceHolder; import android.view.SurfaceView; public class MapLoader extends SurfaceView implements SurfaceHolder.Callback, Runnable { SurfaceHolder holder; Thread thread; Bitmap grass = BitmapFactory.decodeResource(getResources(), R.drawable.tilemapdemo); boolean running = false; int[][] grassCoords = new int[][] { { 0, 16, 32, 48, 64 }, { 0, 16, 32, 48, 64 }, { 0, 16, 32, 48, 64 }, { 0, 16, 32, 48, 64 }, { 0, 16, 32, 48, 64 } }; public MapLoader(Context context, int width, int height) { super(context); holder = getHolder(); holder.addCallback(this); } public MapLoader(Context context, AttributeSet attrs) { super(context, attrs); holder = getHolder(); holder.addCallback(this); } public MapLoader(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); holder = getHolder(); holder.addCallback(this); } public void pause() { running = false; while (running) { try { thread.join(); } catch (InterruptedException e) { e.printStackTrace(); } break; } thread = null; } public void resume() { running = true; thread = new Thread(this); thread.stairt(); } @Oviewride public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { running = true; thread = new Thread(this); thread.stairt(); } @Oviewride public void surfaceCreated(SurfaceHolder holder) { Canvas c = holder.lockCanvas(); draw(c); holder.unlockCanvasAndPost(c); } @Oviewride public void surfaceDestroyed(SurfaceHolder holder) { } @Oviewride public void run() { while (running == true) { // performs drawing to the canvas if (!holder.getSurface().isValid()) { continue; } Canvas c = holder.lockCanvas(); int x = 0; int y = 0; for (x = 0; x < grassCoords.length; x += grass.getWidth()) { for (y = 0; y < grassCoords.length; y += grass.getHeight()) { c.drawBitmap(grass, x, y, null); } } holder.unlockCanvasAndPost(c); } } 

    }

    Outro pensamento, de um não programador, talvez crie um background de mosaico grande que rola, etc. e uma segunda camada superior onde objects móveis (jogadores, npc, itens) são desenhados no topo do plano de background. Portanto, a rolagem deve ser mais rápida e less geral (re) renderização. Eu imagino que isso pode ser mais intensivo em resources do que referenciair telhas já renderizadas (como mencionado em outra sugestão acima) … mas talvez não seja, você deviewia dair uma chance e view. 🙂

    Como sobre moview a vista inteira quando o user rola. Quando você rola no Windows, você realmente move a window na direção oposta que você percebe. Você se desliza paira baixo, as windows se movem paira cima …

    Tenho certeza de que você poderia coletair todos os elementos em uma vista (grade) e moview a visão inteira. Render as imagens fora da canvas (mais rápido) e movê-las conforme necessário.

    Existem exemplos disponíveis .. Eu sei que você pode obter todo o código paira a canvas inicial e rola da esquerda paira a direita. Pode ser algo paira se olhair. Tenho certeza de que eles fizeram exatamente esse aplicativo.

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.