John,

Doesn't work. It works for one number and repeats that number 10 x 15 times.
But what I am trying to do is see the numbers, in this case 0 to 7 repeated
10 x 15 times.

I can also get this to work with one column repeating and at the same time
one row repeating. But not the correct numeric order repeating.

I think you set of files are different from what I have. It is not material
but your bitmap (tiles.gif not spacemap.gif because if you use tiles.gif you
can see the results better) seems to be 64 x 48 and mine is 64 x 32. I
imported my tiles.gif into FlashPro and did the "Info" bit to see the size.
The reason I mention it is: if that is different what else is?

I had already traced out numTilesH/numTilesV to see the results: 4 by 2. Up
to this point we are in agreement (other than your bitmap being a different
size).

One thing that is going to be extremely confusing to anyone reading this
thread later is the fact that Glen seems to think that numRows should be
used "April 10th: setTile(j, i, (i * numRows) + j); and you seem to think
numCols should be used (April 17th: setTile(j, i, (i * numCols) + j);".

My reading of Moock's book seems to say the byteArray will be from left to
right column first. That would seem to indicate we need numCols in there? Is
that something we can agree on?

After that can I ask you or Glenn: Have you (no matter the size bitmap) got
the code to set the tiles so they are in correct numeric order and repeated
10 x 15? If you have and you have randomize correctly changed to do what I
am trying to do then it is time I downloaded a new set of files.

Silly question but if you go to Colin Moock site and send him an email will
he answer it?

Thanks,
Terry





-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of John
McCormack
Sent: Friday, April 18, 2008 10:17 AM
To: Flash Coders List
Subject: Re: [Flashcoders] byteArray x/y


Terry,

I think I know what might be going wrong for you.
You might be expecting something different.

Try this...
Instead of setTile(j, i, (i * numCols) + j);
Let's use tile 1 or tile 9...

Change that line to setTile(j, i, 1) or setTile(j, i, 9)
You see a 16x16 pattern repeated.

The 12 tiles are extracted from spacetiles.gif, which is  64x48 pixels

In SpaceMap.as the size of the square is 16x16...
tiles.loadTiles("spacetiles.gif", 16);

So in TileSet.as the size is 16 and the data from spacetiles.gif, is 64x48
and numTilesH become 64/16 =4 across and
numTilesV becomes 48/16 =3 down
giving 12 tiles in the set

TileSet.as, line 73...
public function convertBitmapToTiles (size:int,
                                          data:BitmapData):Array {
      var newTileSet:Array = new Array();
      var numTilesH:int = data.width/size;
      var numTilesV:int = data.height/size;

      for (var i:int = 0; i < numTilesV; i++) {
        for (var j:int = 0; j < numTilesH; j++) {
          newTileSet.push(data.getPixels(new Rectangle(j*size, i*size,
                                                       size, size)));
        }
      }
      return newTileSet; // 12 tiles in the set
    }

The tiles are the 16x16 and these make the star field.
The drag field is separate to that.

I have benefited from looking at this code, and other code,
and I am pleased to be able to give something back
Moock did a great job. Hope that helps.

John


_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to