View Full Version : Dice game help
I've never met actionscript untill last week, and now I have to make a full game...school assignment with a deadline in two weeks from now! What I need is a code for a die witch on the first roll goes to another frame, according to the number indicated by the die, and on the second roll it is supposed to open a movie clip from the library.:confused:
Help!! Please!:eek:
sunlis
12-04-2007, 03:48 AM
If this is a school assignment, I don't think anyone is going to hand you the code or anything, but what you're talking about shouldn't be too hard.
First, you'll need to look into random(), it's quite simple.
Next, gotoAndStop() or gotoAndPlay(), also simple.
Finally, attachMovie(), again, simple.
Trigger it with a button and an onRelease, throw in a few if statements and you should be fine.
If you've done coding before then it shouldn't be too difficult, because the structure of many languages tends to be fairly similar. Actionscript, I find, is pretty similar to Java.
I think I've given enough hints already... so good luck! ;)
Thanks a lot for the tips, though I tried that before asking and it didn't work... annyway, this is what I came up with:
on (press) {
i = Math.floor(Math.random()*6 + 1);
// t = getTimer();
//c = c + 1;
trace("floor: " + i + "name of obj:" + test._name);
}
on (release) {
if(i==1){
gotoAndStop(4);
}
else if(i==2){
gotoAndStop(5);
}
else if(i==3){
gotoAndStop(6);
}
else if(i==4){
gotoAndStop(7);
}
else if(i==5){
gotoAndStop(8);
}
else if(i==6){
gotoAndStop(9);
}
}
...i'ts probably not the most proffesional solution, but it does the job...
P.S. I've studyed fillology untill now, so the only code I used was phonetics:p
Welcome aboard radu,
Why don't you try to really impress the teacher and do this right. Coding on symbols in an outdated method for one thing, and you also have a lot of needless code in there as well.
Give your button an instance name (here I'm calling it "myButton"), and place your script right on the timeline itself rather then on the object.
You also don't need all those ifs since you always want to go to 3 frames beyond i:
this.myButton.onRelease = function() {
i = Math.floor(Math.random()*7);
gotoAndStop(i+3);
};
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.