Thursday 15 March 2012

android - How to draw a 5*5 array and move images on it -


I have a project for which I need to develop an Android game that is 5 * 5 tables for every player and image Which each of them can move the image inside the 5 * 5 table.

ex:

An example of a game where each player has 5 stones and they can take them one step each time.

Note: I can save the situation in the array so I can have accurate coordinates (or some relative) and at that new place Move the image (ex: recreate it to a new location)

Any thoughts?

Thanks in advance.

After the text "itemprop =" text ">

use a RelativeLayout (not set to visible) with just 5x5 ImageViews. And on images that the user can go to the location, use drag and drop. On drag you set the visibility of the image in the gun. All ImageView (5x5 table), then you can set on-drag Listnr, the overwrite method Odrop, you have to show what document that can receive and determine whether you can remove that scene.

Edit:

Oh well, in this case I said in the GridView comment and use drag and drop to attach a drag-listener to each image is not needed. You can just listen to GridView drop events and determine where x and y are dropped.

Little example (just a hint as)

  gameStoneView.setOnTouchListener (New OnTouchListener () {@Override see public boolean onTouch (V, MotionEvent event) {switch (event.getAction ()) {case MotionEvent.ACTION_DOWN: DragShadowBuilder shadowBuilder = new DragShadowBuilder (gameStoneView); gameStoneView.startDrag (zero, shadowBuilder,! gameStoneView, 0); (dragListener = nULL) {dragListener.onDragStart ();} if Break; default: LOG.v ("Motion event reorder Icon: default - no action below");} return true;}  

});

  gridView.setOnDragListener (New OnDragListener () {@Override public boolean onDrag (see v, DragEvent event) {switch (event.getAction ()) {case Dragavent .CTION_DRAG_LOCATION: currentY = event. getY (); CurrentX = event.getX (); break; case Dragavent. Akshn_ DROP: endpoint status = getPositionOfItem (current X, Y current); dropItemAt (position); break; case Dragavent. Akshn_ DRAG_EXITED: // border Drejvent: ACTION_DRAG_EXITED viewDraggedOutSide = true; break; case DragEvent.ACTION_DRAG_ENDED: // border DRAGEVENT: ACTION_DRAG_ENDED if (viewDraggedOutSideList) {reinsertDraggedItem (); update ();} ViewDraggedOutSideList = false; Apas true; default: return true;}}});  

No comments:

Post a Comment