Flash game development-RPG map implementation

Source: Internet
Author: User

I am dizzy when I use flash for RPG. Many may think so when I hear this. However, the powerful script and excellent animation functions of Flash provide flash with RPG games.
Good support. Today, I am going to teach you two basic models for RPG games. As Dayu is also a cainiao, please forgive me for the mistake.

Flash does not support 3D, so it is still difficult to make a real 3D engine in Flash games. However, it is relatively easy to make a 2.5D game, it not only gives people a real feeling close to 3D. You don't have to spend too much energy. The following describes how to implement a 45-degree map in Flash MX.

Before implementation, let's take a look at what is a 45-degree map (also called a 2.5D map)

It can be seen that this map is composed of many diamond with consistent and flat sizes,

The diamond that makes up a map is called a map element (for short, an element). The size is 60x30 pixels. You can determine the length and width ratio of the element, for example, 64x32. In this example, we will first use 60x30 for demonstration.

Then we arrange these elements,

Find some rules and find that the odd row elements are in the same order, while the even row moves 30 pixels relative to the odd row to the right, and the same row will move 15 elephants down than the previous row. In this way, we will know how to complete the map.

Procedure:

1. Open Flash MX or 2004, create a document, name it "map", and set the size to pixels.

2. Create a new component (select video clip), name it "dt1", click Advanced, and select output as Action Script

3. draw a square on the stage, rotate for 45 degrees, and set the width and height to 60 and 30 pixels respectively in the attribute.

4. Create a new component (or video clip, this time we want to create a pillar) named "dt2" and output it as an Action Script.

5. Draw a shape as shown on the dt2 stage

6. Return to the scenario, select the first sector, and open the action Panel (Press F9)

7. Add the following code to the action panel:

Dt = new array (21 );
// Create an array of 21 Elements
For (I = 0; I <21; I ++ ){

 


DT [I] = new array );
// Each array element is an array of 16 elements and is initialized.
}
DT [16] = new array );
Dt [17] = new array );
Dt [18] = new array );
Dt [19] = new array );
// For the elements of rows 12, 17, 18, and 19, the new value is defined.
For (I = 0; I <21; I ++ ){
If (I % 2 = 1 ){
D = 30; // when I is an odd number and I % 2 is 1, 30 pixels are staggered to the right.
} Else {
D = 0; // It is unnecessary if I is an even number.
}
For (j = 0; j <16; j ++ ){
If (_ root. dt [I] [j] = 1 ){
// When the dt [I] [j] value is 1, we connect dt1 from the library,
// Start a new name ("dt1" + I * 21) + j and assign it a unique depth I * 21 + j.
Attachmovie ("dt1", ("dt1" + I * 21) + j, I * 21 + j );
} Else if (_ root. dt [I] [j] = 2 ){
// When the dt [I] [j] value is 2, we connect dt2 from the library,
// Start a new name ("dt2" + I * 21) + j and assign it a unique depth I * 21 + j.
Attachmovie ("dt2", ("dt1" + I * 21) + j, I * 21 + j );
}
_ Root [("dt1" + I * 21) + j]. _ x = j * 60 + d;
_ Root [("dt1" + I * 21) + j]. _ y = I * 15;
// Set the X and Y coordinates of the newly connected elements.
}
}
 

8. Final Result

9. In summary, by setting more elements, we can make beautiful maps. Is it heart-warming? Try it now.

 

Go to: http://www.akooc.com/article.asp? Id = 81

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.