Simple meteor shower animation special effects code

Source: Internet
Author: User

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 ....

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.