@@ -130,7 +130,7 @@ protected boolean lastDragMovedAtLeastHalfWay() {
130130 }
131131
132132 protected void moveDraggedTilesByMotionEventDelta (MotionEvent event ) {
133- boolean impossibleMove ;
133+ boolean impossibleMove = true ;
134134 float dxTile , dyTile ;
135135 float dxEvent = event .getRawX () - lastDragPoint .x ;
136136 float dyEvent = event .getRawY () - lastDragPoint .y ;
@@ -142,13 +142,19 @@ protected void moveDraggedTilesByMotionEventDelta(MotionEvent event) {
142142
143143 RectF candidateRect = new RectF (dxTile , dyTile , dxTile + tile .getWidth (), dyTile + tile .getHeight ());
144144 boolean candidateRectInGameboard = (gameboardRect .contains (candidateRect ));
145- //Ln.d("In gameboard? %b", candidateRectInGameboard);
146- impossibleMove = (candidateRectForTileCollidesWithAnyOtherTile (tile , candidateRect ) || !candidateRectInGameboard );
147- if (!impossibleMove ) {
148- if (tile .coordinate .row == emptyTile .coordinate .row ) {
149- tile .setX (dxTile );
150- } else if (tile .coordinate .column == emptyTile .coordinate .column ) {
151- tile .setY (dyTile );
145+ impossibleMove = impossibleMove && (!candidateRectInGameboard || candidateRectForTileCollidesWithAnyOtherTile (tile , candidateRect ));
146+ }
147+ if (!impossibleMove ) {
148+ for (GameTileMotionDescriptor gameTileMotionDescriptor : currentMotionDescriptors ) {
149+ tile = gameTileMotionDescriptor .tile ;
150+ dxTile = tile .getX () + dxEvent ;
151+ dyTile = tile .getY () + dyEvent ;
152+ if (!impossibleMove ) {
153+ if (tile .coordinate .row == emptyTile .coordinate .row ) {
154+ tile .setX (dxTile );
155+ } else if (tile .coordinate .column == emptyTile .coordinate .column ) {
156+ tile .setY (dyTile );
157+ }
152158 }
153159 }
154160 }
0 commit comments