Here some advice you can use:
First for each cell you can create an object that represents the state of that cell:
class Cell {
char mChar;
int row,column;
boolean isSelected;
}
then you can create a 2D array of your cells
Cell[][] mTable = ...
For views you have a lot of options:
for cells:
-
CheckableImageView ( I think this one is more suitable)
and for the viewgroup for your entire table you can choose any of the below:
-
Nested LinearLayout(not recommended)
-
Custom View ( you can create a
viewgroup
for your specific needs)
For detecting swipe gesture set OnSwipeTouchListener(from which answers you like) as a TouchListener
of your cell views. This listener gives callbacks on these events:
- onSwipeRight()
- onSwipeLeft()
- onSwipeTop()
- onSwipeBottom()
Game Architecture
You can use MVC architecture for this one. You need another class call it GameController
. When you detect a swipe
you have to pass it to the GameController
with the index of that cell. GameController
has to check if that swipe is valid or not for example diagonal swipe may not valid or… the rules are applied here. Then if the swipe is valid GameController
updates the mTable
(set isSelected
to true
for example) and then you have to update your ui
from mTable
data.
I think the whole idea is now a bit clearer to you, look forward to playing it 🙂
solved Android slide over letters to create a word [closed]