//以角色为中心的场景移动 //角色移动的速度 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; } } } }; |
Word教程网 | Excel教程网 | Dreamweaver教程网 | Fireworks教程网 | PPT教程网 | FLASH教程网 | PS教程网 |
HTML教程网 | DIV CSS教程网 | FLASH AS教程网 | ACCESS教程网 | SQL SERVER教程网 | C语言教程网 | JAVASCRIPT教程网 |
ASP教程网 | ASP.NET教程网 | CorelDraw教程网 |