-3

I am always wondering. If I want to design a Tile game (6 by 6 tiles) where a player can press on one tile and then the tile moves randomly around the screen untill it hits another specific tile. Then what would be the right way?

1-Create the Tiles as Imageviews and listen for clicks on them and so using the translate animation I can move the touched tile around randomly (not sure yet how I can detect collision)

2- listen for for the touch methods and checked that the touch coordinates is within the tile coordinate and animate the movement by "drawing" and checking corrdinates.

I am always confused which way to go with when designing games (like that). I know I can use Engines like AndEngine, but I want to avoid it (big learning curve for simple games like that)

Thank you

4

2 回答 2

0

You could use processing, it is a relatively simple graphics enviroment for java, the performance is not that great on android through, but it is really simple to get started, can be used in eclipse or with the processing IDE. http://processing.org/ . The processing IDE also contains alot of examples, it doesnt have any fancy features though so i think that you will prefer using eclipse: http://processing.org/tutorials/eclipse/

AndEngine is also relatively easy to use, when you first get the hang of it, plus there is a thriving community, but yeah if you are not that into java yet it can be a steep road to take.

I wouldnt recommend making games with Views, its meant for applications.

于 2013-07-20T23:27:50.077 回答
0

您也可以使用,ImageButton但也可以使用ImageView,对于碰撞,您可以使用 Rect 类的 intersect 方法,您只需为您的瓷砖创建一个矩形

 view.getLocationOnScreen(l);
    int x = l[0];
    int y = l[1];
    int w = view.getWidth();
    int h = view.getHeight();

Rect r=new Rect(x,y,w,h); 

然后检查碰撞

 if( r.intersect(r2))

intersect 还有其他重载版本,请参阅链接以获取有关重载版本的更多信息 http://developer.android.com/reference/android/graphics/Rect.html#intersect(android.graphics.Rect)

于 2013-07-20T23:36:17.790 回答