shaftbond
08-24-2004, 03:50 PM
Hey everyone, I am going to attempt to make a simple game and I am sure I will have multiple questions along the way, so I'll post them all in here to keep the forums tidy :).
Question 1:
In the first frame of the movie, I have:
function randyNum(){
ranX=Math.round(Math.random()*30);
ranNumX=ranX*16;
ranY=Math.round(Math.random()*17);
ranNumY=ranY*16;
}
//create random placement of pieces//
randyNum();
hero1._x=ranNumX;
hero1._y=ranNumY;
randyNum();
robot1._x=ranNumX;
robot1._y=ranNumY;
that places the hero and an evil robot randomly on a specified invisible grid. that part works. now, I want to be able to press "T" and have the hero teleport randomly somewhere else on the grid. So I created a movie clip and named it "script", placed it outside of the movie boundaries and inserted this code:
onClipEvent(keyDown){
_root.randyNum();
_root.hero1._x=ranNumX;
_root.hero1._y=ranNumY;
trace(ranNumX);
}
I know this isn't linked to "T" yet, but the number is returning undefined. Any help would be appreciated.
Question 1:
In the first frame of the movie, I have:
function randyNum(){
ranX=Math.round(Math.random()*30);
ranNumX=ranX*16;
ranY=Math.round(Math.random()*17);
ranNumY=ranY*16;
}
//create random placement of pieces//
randyNum();
hero1._x=ranNumX;
hero1._y=ranNumY;
randyNum();
robot1._x=ranNumX;
robot1._y=ranNumY;
that places the hero and an evil robot randomly on a specified invisible grid. that part works. now, I want to be able to press "T" and have the hero teleport randomly somewhere else on the grid. So I created a movie clip and named it "script", placed it outside of the movie boundaries and inserted this code:
onClipEvent(keyDown){
_root.randyNum();
_root.hero1._x=ranNumX;
_root.hero1._y=ranNumY;
trace(ranNumX);
}
I know this isn't linked to "T" yet, but the number is returning undefined. Any help would be appreciated.