Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions flixel/addons/display/FlxGridOverlay.hx
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ class FlxGridOverlay
* If false each row will be the same colour, creating a striped-pattern effect.
* So to create an 8x8 grid you'd call create(8,8)
*
* @param CellWidth The grid cell width
* @param CellHeight The grid cell height
* @param Width The width of the FlxSprite. If -1 it will be the size of the game (FlxG.width)
* @param Height The height of the FlxSprite. If -1 it will be the size of the game (FlxG.height)
* @param CellWidth The grid cell width. Must be greater than 0.
* @param CellHeight The grid cell height. Must be greater than 0.
* @param Width The width of the FlxSprite. If -1 it will be the size of the game (FlxG.width). This value cannot be smaller than the `CellWidth`
* @param Height The height of the FlxSprite. If -1 it will be the size of the game (FlxG.height). This value cannot be smaller than the `CellHeight`
* @param Alternate Should the pattern alternate on each new row? Default true = checkerboard effect. False = vertical stripes
* @param Color1 The first fill colour in 0xAARRGGBB format
* @param Color2 The second fill colour in 0xAARRGGBB format
Expand All @@ -45,9 +45,10 @@ class FlxGridOverlay
}

if (Width < CellWidth || Height < CellHeight)
{
return null;
}
throw "The width and height of a grid cannot be smaller than the cell's width and height!";

if (CellWidth <= 0 || CellHeight <= 0)
throw "Grid cell width/height cannot be less or equal to 0";

var grid:BitmapData = createGrid(CellWidth, CellHeight, Width, Height, Alternate, Color1, Color2);

Expand All @@ -67,10 +68,10 @@ class FlxGridOverlay
* So to create an 8x8 grid you'd call create(8,8,
*
* @param Sprite The FlxSprite you wish to draw the grid on-top of. This updates its pixels value, not just the current frame (don't use animated sprites!)
* @param CellWidth The grid cell width
* @param CellHeight The grid cell height
* @param Width The width of the FlxSprite. If -1 it will be the size of the game (FlxG.width)
* @param Height The height of the FlxSprite. If -1 it will be the size of the game (FlxG.height)
* @param CellWidth The grid cell width. Must be greater than 0.
* @param CellHeight The grid cell height. Must be greater than 0.
* @param Width The width of the FlxSprite. If -1 it will be the size of the game (FlxG.width). This value cannot be smaller than the `CellWidth`
* @param Height The height of the FlxSprite. If -1 it will be the size of the game (FlxG.height). This value cannot be smaller than the `CellHeight`
* @param Alternate Should the pattern alternate on each new row? Default true = checkerboard effect. False = vertical stripes
* @param Color1 The first fill colour in 0xAARRGGBB format
* @param Color2 The second fill colour in 0xAARRGGBB format
Expand All @@ -90,9 +91,10 @@ class FlxGridOverlay
}

if (Width < CellWidth || Height < CellHeight)
{
return null;
}
throw "The width and height of a grid cannot be smaller than the cell's width and height!";

if (CellWidth <= 0 || CellHeight <= 0)
throw "Grid cell width/height cannot be less or equal to 0";

var grid:BitmapData = createGrid(CellWidth, CellHeight, Width, Height, Alternate, Color1, Color2);
Sprite.pixels.copyPixels(grid, new Rectangle(0, 0, Width, Height), new Point(0, 0), null, null, true);
Expand Down