The developing of this game took only two days. It has 280 lines of code. And I still didn't finish the work with a timer. I need to add the "Pause" button as well. The main problem was the lack of knowledge about .mouseChildren command (It works with events propagation).
puzzle.mouseEnabled = true;
puzzle.addEventListener(MouseEvent.MOUSE_DOWN, onDrag);
puzzle.addEventListener(MouseEvent.MOUSE_UP, onDrop);
puzzle.mouseChildren = false;
This application has 348 Kb size and uses 89% of CPU when you play a prize Game due to having 48 interactive animations.
I added the snapping with a precision equal to 5 pixels.
isPosition = (currentPuzzle.x <= (endX + precision)) &&
(currentPuzzle.x >= (endX - precision)) &&
(currentPuzzle.y <= (endY + precision)) &&
(currentPuzzle.y >= (endY - precision));
if (isPosition == true) {
currentPuzzle.x = endX;
currentPuzzle.y = endY;
stopDrag();
currentPuzzle.mouseEnabled = false;
puzzlesLeftCount--;
}
I used my own pictures and a Puzzles Die Cut Mock-Up from my previous work (10 years ago).
This application published for Flash Light 4. I wanna check how it looks on the smartphones.
Now I can say I applied the wrong approach in development of this game since I didn't used Bitmap and BitmapData classes as a result one picture was repeated many times (one picture for each puzzle piece).
ReplyDelete