首先我们找来一幅图片并将它导入到Flash
//以角色为中心的场景移动
//角色移动的速度
var speed:Number = 3;
this.onEnterFrame = function() {
if (Key.isDown(Key.UP)) {
if (map._y>=0) {
//达到上边界
map._y = 0;
curPoint._y -= speed;
} else {
//未到达上边界,地图下移
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)) {
//达到下边界
map._y = -(map._height-Stage.height);
curPoint._y += speed;
} else {
//未到达下边界,地图上移
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;
}
}
}
};
评论 {{userinfo.comments}}
{{child.content}}
{{question.question}}
提交