8

i need to tilt a layout in android about 45 degree anticlockwise. i want to implement a game in android as stackopolis .is there any method to align tiles as in the game.I have the tile image,and now i use canvas to align this.but there i cannot get the click event and it is difficult to align tiles.is grid view is compatable.any new idea. i have these images with me.this is the main background

main background grid

tile

i want to align this tile in grid.and need click event as in the stackopolis

KIRAN K J
  • 632
  • 5
  • 28
  • 57
  • you can have a look in http://stackoverflow.com/questions/3444764/rotate-view-hierarchy-90-degrees it might help u – Sumant Jul 24 '11 at 09:13

5 Answers5

9

For creating a game like this you really don't want to use layouts. You would create a tile engine using bitmap blitting or OpenGL.

Will Kru
  • 5,164
  • 3
  • 28
  • 41
5

You can use the following methods, for rotation of view,

Note: All the above are Since: API Level 11

Labeeb Panampullan
  • 34,521
  • 28
  • 94
  • 112
1

If you dont know much about making a game the read this book

http://www.amazon.com/dp/1430230428/?tag=stackoverfl08-20

It will teach you EVERYTHING you should need to know to do what you want. It also sets up OpenGL ES for you so your app will be nice and smooth

I really would suggest OpenGL, using the Canvas class will not only be slower but it is going to be limited as well

Chris
  • 1,766
  • 1
  • 21
  • 36
1

For a game like this, you should really implement your own graphics code instead of relying on the standard Android layout components. There is no way to rotate an Android layout by 45 degrees. There are essentially two ways you can go about this: you can either use Canvas and draw your graphics using primitives and bitmaps, or you can go with the more powerful OpenGL implementation which has a steeper learning curve but may have better results.

You can read more about 2D graphics on Android here: http://developer.android.com/guide/topics/graphics/2d-graphics.html

And more about 3D graphics here: http://developer.android.com/guide/topics/graphics/opengl.html

Bear in mind that OpenGL is more suited to real-time games, where the game needs to keep up a good frame rate. If your game is a strategy or turn-based game, you could probably get away with a simpler Canvas-based implementation. I'd advise you to check out the following classes in the framework:

Canvas http://developer.android.com/reference/android/graphics/Canvas.html

SurfaceHolder http://developer.android.com/reference/android/view/SurfaceHolder.html

GLSurfaceView http://developer.android.com/reference/android/opengl/GLSurfaceView.html

Bruno Oliveira
  • 5,056
  • 18
  • 24
1

Have you checked out this Android Game Engine? It's called AndEngine - while I have not got to play with it much - it has the functionality to have a "topview" type game as in say Diablo II.

Jack
  • 9,156
  • 4
  • 50
  • 75