Skip to main content
pyrogirl8
Participant
January 27, 2019
Question

How can I add a border to a grid in game?

  • January 27, 2019
  • 1 reply
  • 250 views

I have a matching game that sets up a grid in code for the icons, and I want to add a border of some sort around the grid. How would I do so? Here is the code that sets up the grid:

public function startMatchThree() {

// create grid array

grid = new Array();

for(var gridrows:int=0;gridrows<8;gridrows++) {

grid.push(new Array());

}

setUpGrid();

isDropping = false;

isSwapping = false;

gameScore = 0;

addEventListener(Event.ENTER_FRAME,movePieces);

}

public function setUpGrid() {

// loop until valid starting grid

while (true) {

// create sprite

gameSprite = new Sprite();

// add 64 random pieces

for(var col:int=0;col<8;col++) {

for(var row:int=0;row<8;row++) {

addPiece(col,row);

}

}

This topic has been closed for replies.

1 reply

Ned Murphy
Legend
January 28, 2019

You can use the Rectangle class to draw a rectangle.  Check out the documentation and examples via the following link...

Rectangle - Adobe ActionScript® 3 (AS3 ) API Reference

Also, try looking thru Google searching AS3 Draw Border.  There are a few different approaches you might take, from drawing lines to adding a glow filter.

https://www.google.com/search?client=firefox-b-1&q=AS3+draw+border