Hello All.
I have a question about this script. I have a mc of a little beetle, and found this script to get it to move around randomly. The trouble is when it rotates it does not actualy show the mc rotating. Example: if beetle is facing the 12 oclock position and the next randomly chosen position is rotated to the 6 oclock, it just appears there with no steps in between. I have very little knowledge of actionscript, but what I’m after is having the beetle walk a little, pause briefly slowly turn to another direction (either clockwise, or counterclockwise, pause briefly, and walk forward. All with some randomness. Random lengths of walking, pausing, and rotating. Is there a simple way to modify this code to actualy show the process of it rotating?
Any help would be gratly appreciated.
-Sinjun
code below:
var dice;
var speed;
var rotation;
var x;
var y;
var angle;
var intervalID;
//
function rollDice() {
dice = Math.random()*100;
trace(dice);
if (dice<5) {
moveInsect();
}
}
function moveInsect() {
rotation = Math.random()*360;
speed = 5;
//random length of time to move 1 to 2 seconds
intervalID = setInterval(stopInsect, Math.random()2000+1000);
}
function stopInsect() {
speed = 0;
clearInterval(intervalID);
}
insect.onEnterFrame = function() {
rollDice();
this._rotation = rotation;speed = 5;
this._x += Math.sin(this._rotation(Math.PI/180))speed;
this._y += Math.cos(this._rotation(Math.PI/180))speed-1;
};
PS a demo of a similar effect I am trying to achieve can be seen at the top of this page (ladybug).
http://www.myflashxml.us/xmlswf/v12b3/index.html