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<=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>=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<=STAGE.WIDTH/2) {
Curpoint._x + = speed;
} else {
map._x-= speed;
}
}
}
};