O.K
Random Isent hard i did it before.But one thing i forgot is to remember the code.And Understand it.
I want it so when my Player MC hits the Coin MC it goes to another spot randomly.
Code
this._x = random(250);
this._y = random(150);
Thats what i have.
But o dont want it to go off the screen
so i started experimenting dident have any sucess.
Experiment
this._x = random(10,250);
this._y = random(10,150);
So it should randomly go to a number from 10 to 250 dident have any sucess please please please help me.
system
March 12, 2003, 4:45am
2
try this
xRan = Math.round(Math.random()*Stage.width);
yRan = Math.round(Math.random()*Stage.width);
this._x = xRan - this._width;
this._y = yRan - this._height;
code is pretty self explanitory…
system
March 12, 2003, 4:48am
3
I dont thknk that code would work.
I want it so it goes from like 10,250 on the stage.
Even though it dont work it would go all over the place.
I need it to go between 10 and lke 250.
Anyone else
system
March 12, 2003, 4:50am
4
xRan = Math.round(Math.random()*240);
yRan = Math.round(Math.random()*240);
this._x = 10 + xRan;
this._y = 10 + yRan;
there ya go.
system
March 12, 2003, 4:53am
5
O>K seems alot easier than mine.
But to top it off.
What does Mathround mean.
Im not good with that type of stuff
system
March 12, 2003, 4:55am
6
its rounds the number.
Math.random()*240 gives you a number between 0 and 240 but it gives you 4 decimal points, so you would get 202.3489 or 12.9063
Math.round() rounds the number to the nearest whole number. Just use that to make sure your movieclip will be on a whole number because the lines work better and show up better when you use whole numbers.
system
March 12, 2003, 4:58am
7
Thanks alot Jubba.
Now all i have to do is my counter and im finished my Engine.Then ill fix up the graphics thanks alot again.