Hi,
I have a porblem with my code, I am creating a snakes and ladders game, I have so far created the board, using a for statement, which looks like this;
var sqX:Number = 100;
var sqY:Number = 600;
var sqNum:Number = 1;
for (j=1; j<=10; j++) {
for (i=1; i<=10; i++) {
duplicateMovieClip("square", "square"+j+i, 100+sqNum);
_root["square"+j+i].gotoAndStop(boardArray[sqNum-1]);
_root["square"+j+i].sqNum.text = sqNum;
_root["square"+j+i]._x = sqX;
_root["square"+j+i]._y = sqY;
if ((int(j/2)*2) == j) {
if (i != 10) {
sqX -= 60;
}
} else {
if (i != 10) {
sqX += 60;
}
}
sqNum++;
}
sqY -= 60;
}
- var sqX:Number = 100;
- var sqY:Number = 600;
- var sqNum:Number = 1;
- for (j=1; j<=10; j++) {
- for (i=1; i<=10; i++) {
- duplicateMovieClip("square", "square"+j+i, 100+sqNum);
- _root["square"+j+i].gotoAndStop(boardArray[sqNum-1]);
- _root["square"+j+i].sqNum.text = sqNum;
- _root["square"+j+i]._x = sqX;
- _root["square"+j+i]._y = sqY;
- if ((int(j/2)*2) == j) {
- if (i != 10) {
- sqX -= 60;
- }
- } else {
- if (i != 10) {
- sqX += 60;
- }
- }
- sqNum++;
- }
- sqY -= 60;
- }
Now the porblem that I am having is that I cannot think how to make it so that, when I roll a dice it will move the player along the board the number that was generated from the dice. I have created a dice function that generates a random number, but as I said I cannot think how to make it move a character piece that many squares along the board. Any help would be much appreciated.
oh and here is the code for my dice funciton;
function randomNum() {
diceNum = Math.round(Math.random()*5)+1;
_root.dice.gotoAndStop(diceNum);
}
rollBtn.onRelease = randomNum;
- function randomNum() {
- diceNum = Math.round(Math.random()*5)+1;
- _root.dice.gotoAndStop(diceNum);
- }
- rollBtn.onRelease = randomNum;
I can put up the fla if needed.
thanks