What I need help on is on the "drop" side of my design. When a touch ACTION_UP occurs, I need to recognize where on my canvas, a.k.a game board, i dropped the piece. Right now my background is drawn first as bitmap and all pieces on are drawn subsequently.
Using java Syntax Highlighting
- canvas.drawBitmap(BitmapFactory.decodeResource(
- getResources(), R.drawable.table), 0, 0, null);
- canvas.drawBitmap(chipsHolder[0].getBitmap(), chipsHolder[0].getX(),chipsHolder[0].getY(), null);
- canvas.drawBitmap(chipsHolder[1].getBitmap(), chipsHolder[1].getX(),chipsHolder[1].getY(), null);
Parsed in 0.031 seconds, using GeSHi 1.0.8.4
...and so on.
I have the touch events working as well. They detect placement by matching x-values of the "piece" and a specific location, but I cannot get the inside if loop to work correctly. No matter what x-value on the canvas, the inside if loop always equates to true.
Using java Syntax Highlighting
- public void checkPlacement(Chip chip)
- {
- if(chip.getY() <= 180 && chip.getY() >= 150)
- {
- if(chip.getX() >= 25 && chip.getX() <= 100);
- {
- Toast.makeText(getContext(), "green", Toast.LENGTH_SHORT).show();
- }
- }
Parsed in 0.031 seconds, using GeSHi 1.0.8.4
I have read stuff on collision detection by coordinates, but my game board is comprised of many "areas" that a piece can land on. There has to be a more efficient way of detecting specific placement?
Thanks for the help.


