Flash about game making research in the scene move (i)

Source: Internet
Author: User
The scene is an important element in the game, especially for RPG games, the number of scenes is more, so now I am for some beginners who want to do the game to explain how the role of the game in the scene to achieve movement. What we are going to talk about today is the way the scene moves with the role of the game.

The game-centric scene is moved in such a way that, in addition to reaching the end of the scene, the role of the game always moves in the center of the scene. Now we can also separate to consider the problem, we can be divided into: not reached the end of the scene and reached the end of the scene two situations. At the end of the scene, the game character is at the center of the scene, and when it reaches the end of the scene, the role of the game moves toward the end. The point to be explained is that in many cases, the illusion of vision, many people think that the role of the movement caused the scene to move, so focus on the role, in fact, in writing in the scene to move the attention should focus on the scene, when the arrow keys when the scene began to move, Makes us think that the character is moving. So we have to analyze the most essential things in order to make us more effective, then we start talking about how to make it ...

First we find a picture and import it into flash. Then create a new MC, drag the picture in and let it align with the original point, this step is for our future programming convenience to do. And this MC is our scene. Then we drag the MC to the main scene and name it the map. Then we create a new MC, which is used to represent the characters in the game, and we just draw a dot to it. We also dragged this MC into the scene named Curpoint. Next we start writing the script, clicking on the first frame of the main scene and writing the following code:

Role-centric scene movement
The speed at which the role moves
var speed:number = 3;
This.onenterframe = function () {
if (Key.isdown (key.up)) {
if (map._y>=0) {
Reach the upper boundary
map._y = 0;
Curpoint._y-= speed;
} else {
The map moves down without reaching the upper boundary
if (CURPOINT._Y>=STAGE.HEIGHT/2) {
Curpoint._y-= speed;
} else {
Map._y + = speed;
}
}
}
if (Key.isdown (Key.down)) {
if (map._y<=-(map._height-stage.height)) {
Reach the lower boundary
map._y =-(map._height-stage.height);
Curpoint._y + = speed;
} else {
The map moved up without reaching the lower boundary
if (CURPOINT._Y&LT;=STAGE.HEIGHT/2) {
Curpoint._y + = speed;
} else {
Map._y-= speed;
}
}
}
if (Key.isdown (Key.left)) {
if (map._x>=0) {
map._x = 0;
curpoint._x-= speed;
} else {
if (CURPOINT._X&GT;=STAGE.WIDTH/2) {
curpoint._x-= speed;
} else {
Map._x + = speed;
}
}
}
if (Key.isdown (key.right)) {
if (map._x<=-(map._width-stage.width)) {
map._x =-(map._width-stage.width);
Curpoint._x + = speed;
} else {
if (CURPOINT._X&LT;=STAGE.WIDTH/2) {
Curpoint._x + = speed;
} else {
map._x-= speed;
}
}
}
};

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.