In this tutorial, you will learn how to create a horizontal menu.
(This everyone will do) the whole process is a frame code:
Xrandom = new Array ();
Yrandom = new Array ();
Salerandom = new Array ();
Get random speed
Speed = Math.floor (Math.random () *10) +5;
For (_global.i=0 i<=19; i++) {
Get Random Horizontal
Xrandom = Math.floor (Math.random () *700);
Get random ordinate
Yrandom = Math.floor (Math.random () *400);
Get a random size
Salerandom = Math.floor (Math.random () *20) +2;
Create 19 Comets
Duplicatemovieclip (Ball, "ball" +i, I);
_root["Ball" +i]._x = xrandom;
_root["Ball" +i]._y = yrandom;
_root["Ball" +i]._yscale = salerandom;
Meteor Angle is 20.
_root["Ball" +i]._rotation = 20;
The radian displacement of a meteor into 20°.
_root["ball" +i].onenterframe = function () {
var a = this._rotation;
var rad = a*math.pi/180;
var dx = Math.Cos (RAD) *speed;
var dy = Math.sin (rad) *speed;
this._x = + dx;
This._y + dy;
If the meteor exceeds the screen, the coordinates are restored.
if (this._x>=710) {
this._x =-math.floor (Math.random () *300);
this._y =-math.floor (Math.random () *300);
}
};
}
Get ASCII
Code = 174;
char = chr (code);
Author name
Mytext_txt.text = char+ "Huanbaiyiju";
*****************************************************
Okay, OK!
Special Note:
An array is an interesting thing to do, like to create thousands of enemies:
Enemys = new Array ();
for (i=0;i<500;k++) {
Enemys.names = "Zerg";
Enemys.blood = 200;
Enemys.equipment = "Sword";
}
All the attributes of the enemy are simply defined.
Debug it, see the effect ....