Skip navigation
Currently Being Moderated

Creating puzzle pieces help

Sep 7, 2011 5:33 AM

hello

I'm trying to created iregular puzzle pieces from a picture(in flash cs5.5) can anyone sugest some ways of doing this?maybe a usefull link.I know how to make rectangular shapes,but i'm looking in creating iregular pieces.


tks in advance

this is how my make puzzle pieces function looks like

the shapes are rectangular

        private function makePuzzlePieces(bitmapData:BitmapData)
        {
            puzzleObjects = new Array();
            for (var x:uint = 0; x < numPiecesHoriz; x++)
            {
                for (var y:uint = 0; y< numPiecesVert; y ++)
                {
                    //create new puzzle piece and sprite
                    var newPuzzlePieceBitmap:Bitmap = new Bitmap(new BitmapData(pieceWidth,pieceHeight));
                    newPuzzlePieceBitmap.bitmapData.copyPixels(bitmapData,new Rectangle(x*pieceWidth,y*pieceHeight,pieceWidth,pieceHeight),new Point(0,0));
                    var newPuzzlePiece:Sprite = new Sprite();
                    newPuzzlePiece.addChild(newPuzzlePieceBitmap);

 

                    //place in bottom sprite;
                    otherPieces.addChild(newPuzzlePiece);
                    //create object to store in array;
                    var newPuzzleObject:Object = new Object();
                    newPuzzleObject.loc = new Point(x,y);// location in puzzle
                    newPuzzleObject.dragOffset = null;//offset from cursor
                    newPuzzleObject.piece = new PuzzlePiece  ;
                    newPuzzlePiece.addEventListener(MouseEvent.MOUSE_DOWN, clickPuzzlePiece);
                    puzzleObjects.push(newPuzzleObject);
                }
            }
            //randomize location of puzzle pieces
            shufflePieces();
        }

 
Replies

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points