Tiling images is relatively simple, but can be made even simpler and more efficient by adding this snippet into your Starling source.

Open starling\src\starling\display\Image.as

Beneath the getTexCoords function, paste this:

//Tiles texture, give number of horizontal and vertical tiles
public function tile(horizontally:int,vertically:int):void{
	setTexCoords(1,new Point(horizontally,0));
	setTexCoords(2,new Point(0,vertically));
        setTexCoords(3,new Point(horizontally,vertically));

Then in your own game's class, call the tile function on your image. For example, if I want my image to tile 5 times sideways:


or 5 times vertically


or both, and make a 5×5 square


Remember, the texture you apply to your image must have its repeat property set to true.

Also remember that this function does not adjust the size of your image, only its tiling property. If you want your image's size to also adjust according to your tiling, simply extend its width accordingly:

//x and y are your horizontal and vertical tiling values
myImage.width *= x;
myImage.height*= y;
  tutorials/image_tiling.txt · Last modified: 2012/06/16 21:29 by rayne
Powered by DokuWiki