Android : It is possible to move a tiled background? (infinite scroll with TileMode.REPEAT)

on Saturday, January 31, 2015


I am developing a game


First of all my game will be very simple, so i would prefer not to use libraries or opengl or canvas, i would prefer to achieve this with simple imageviews or normal views, or at least by the simplest way possible. For example with android bitmap tile mode:



public static void setBackground(Bitmap bmp, ViewGroup layout){
BitmapDrawable bitmapDrawable = new BitmapDrawable(bmp);
bitmapDrawable.setTileModeXY(Shader.TileMode.REPEAT, Shader.TileMode.REPEAT);
layout.setBackgroundDrawable(bitmapDrawable);
}


I want to develop a simple 2D/3D hybrid spaceship game. The screen will be the vision from the spaceship cockpit, and you will move the spaceship touching a joystick that i have allready done. So the background will be a universe background, i mean a huge black image with stars, and this image must be moved to all directions with the joystick simulating that the spaceship is changing it's direction, and when you move a lot to the right for example, the background image must start from the begining to simulate that the space ship is still moving to the right without any limitation


As i have mentioned, i have the joystick now, and i know how to move a imageview with the joystick, the problem is that i dont know how to create a infinite imageview with tiles correctly, because when i move the background containing the tile imagedrawable then the image dissapears from the screen.


This is an example of an image for using with the infinite background:


enter image description here


0 comments:

Post a Comment