I've a created a Bejewled style match 3 game of my own for mobile devices. I've added multiple levels, color changing screens, sound, background music... pretty much made it a complete game.
Here's my problem.
I've tried to add swipe functionality to the game (since it's mobile) using the gesture example on republic of code site, so that if they swipe a "jewel" up, down, left or right, it will try to swap places with the jewel in that direction.
It...SORTA... works. Meaning, it works only some of the times and the rest of the time, it's picking up the wrong gem or not working at all.
Anyone have any experience with this?
Here's the code for the event handler... added right after the mouseevent handler...
newPiece.addEventListener(MouseEvent.CLICK,clickPi ece);
newPiece.addEventListener(TransformGestureEvent.GE STURE_SWIPE , swipePiece);
And here's the handler.
// player clicks on a piece
public function swipePiece(e:TransformGestureEvent)
{
var piece1iece = Piece(e.currentTarget);
piece1.select.visible = true;
var piece2iece;
if (e.offsetX == 1)
{
//User swiped towards right
if (piece1.col < 7)
{
piece2 = grid[piece1.col + 1][piece1.row];
makeSwap(piece1,piece2);
firstPiece = null;
piece1.select.visible = false;
piece1 = null;
piece2 = null;
}
else
{
FXSoundChannel = bongSnd.play();
}
}
if (e.offsetX == -1)
{
//User swiped towards left
if (piece1.col > 0)
{
piece2 = grid[piece1.col - 1][piece1.row];
makeSwap(piece1,piece2);
firstPiece = null;
piece1.select.visible = false;
piece1 = null;
piece2 = null;
}
else
{
FXSoundChannel = bongSnd.play();
}
}
if (e.offsetY == 1)
{
if (piece1.row < 7)
{
piece2 = grid[piece1.col][piece1.row + 1];
makeSwap(piece1,piece2);
firstPiece = null;
piece1.select.visible = false;
piece1 = null;
piece2 = null;
}
else
{
FXSoundChannel = bongSnd.play();
}
}
if (e.offsetY == -1)
{
if (piece1.row > 0)
{
piece2 = grid[piece1.col][piece1.row - 1];
makeSwap(piece1,piece2);
firstPiece = null;
piece1.select.visible = false;
piece1 = null;
piece2 = null;
}
else
{
FXSoundChannel = bongSnd.play();
}
}
}
Any help would be greatly appreciated. I'm so close to having this
ready to go.
North America
Europe, Middle East and Africa
Asia Pacific