Flash games are counted at around 24 o'clock, with mine clearance development memo.

Source: Internet
Author: User
Tags addchild

A while ago, I developed a 24-point game called as3.0.

I didn't know much about flash and as3.0 before development, but I knew the simple syntax.

In flash, It is very convenient to create an animation object because movieclip can be used. Custom Controls in other languages are almost native in as3.

Supports classes and supports Code Organization of multiple files. It is easy to use simple projects.

Whether there is a solution. If a recursive algorithm is used, the efficiency is quite high.

Expression computation takes shortcuts and calls eval. Legality detection directly adds some code.

Trial address:

24 o'clock

Http://85xt.cn/vod_play.aspx? Indexid = 0 & _ id = 1448

Mine Clearance

Http://85xt.cn/vod_play.aspx? Indexid = 0 & _ id = 2261

The following is a clearance program.

Use MC as the basic component and use an array to save the generated Mc object. The code for banding object events is as follows.

For (var I: Int = 0; I <rows; I ++)
{
For (var j: Int = 0; j <Cols; j ++)
{
CRNT = I * Cols + J;
Btns [CRNT] = New BTN ();
Btns [CRNT]. x = J * 17 + 25;
Btns [CRNT]. Y = I * 17 + 50;
Btns [CRNT]. addeventlistener (mouseevent. Click, btnonmouseclick );
Btns [CRNT]. ismine = 0;
Btns [CRNT]. minearound = 0;
Btns [CRNT]. Tag = CRNT;
Addchild (btns [CRNT]);
}
}

 

MC has 12 frames, indicating 12 statuses, such as N class thunder.

When you click, several classes near the MC are determined.

Flash has a right-click, so click to mark, double-click to open. No question mark status.

Double-click to enable intelligent judgment, that is, if it is 0 thunder, open this blockbuster.

Flash itself does not support double-click. However, a simple code can solve this problem, specifically Google.

It is rare to open all eight of the surroundings if you open the white space. Here we will consider using recursion.

It is really troublesome to get stuck sometimes without right-clicking.

 

It is found that the gotoandplay code is very inefficient. There is a reset statement and the recursion that automatically opens the blank is very slow, and it is found that it is caused by gotoandstop. After tracing, each MC occupies 40 ms.

It seems that bitmapdate can solve this problem.

Each frame in MC is changed to a bitmap, and the speed is improved by about 20%.

If the 12 frames in MC are deleted and the remaining frame is deleted, the speed will soon be reached.

Use draw for gotoandstop.

I have a document on flash game optimization techniques, which is good.

 

The current idea is to put a bitmap in MC. Then draw the bitmap as needed.

How to access the child components in MC?

The final method is to generate bitmap, and then in an empty Mc, addchild.

The original image is not a bitmap and cannot be used in as3. External imported BMP files can be exported to as3.

The code for loading bitmap objects in the library is as follows:

VaR bb1: bitmap;

If (I = 0)
Bb1 = new Bitmap (New graybmp (0, 0 ));

MC. addchild (bb1 );

This speed is fast. If there are multiple frames, there are many judgments. It is easy to use as a function.

In addition, the stage object cannot be obtained in the main function. For more information, see Google.

I want to get a keyboard event with full screen response, so I can call Stage in the first frame.

The problem is that the Mouse shape is changed.

You can only use MC to follow the mouse.

The as3 compiler is not powerful enough, and the error prompt is uncomfortable.

The rest is the program logic.

The two programs are basically about 300 lines of code. It is really more interesting to write a small program than to create a large project. You don't need to consider complicated requirements ..

 

I want to create Tetris today

The first problem is collision detection of irregular shapes. The rule shape can be determined by distance, making it much harder to create irregular shapes.

In Google, as3 has its own method, bitmapdata, and hittest method. So we can use two bitmapdata.

Each block is a bitmap, and the background is a bitmap.

If a collision is detected, the system stops moving. Copy the content to the background.

Start.

 

 

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.