FLASH网游通过XMLSocket与VB后台通信_Flash教程

编辑Tag赚U币
教程Tag:暂无Tag,欢迎添加,赚取U币!

推荐:Flash游戏中导弹追踪的算法
先看下效果吧:代码如下:/*请教大家一个关于势函数用到追踪和拦截的算法有研究过的能不能指点一下!PoweredBySundayEmail:happyclub@163.com*/varst

前段时间用Flash做了个网游的Demo,通讯用的是Socket。曾承诺写个教程,现在有空就把它写写吧。
先从FLASH说起。我要达到的效果是点击地面,人物就走到点击的地点。思路:一个鼠标监听器监听鼠标的点击事件,把X座标和Y座标传到角色,做为角色的目的地。角色每一帧都向这个目的地移动一点点。
role_mc为场景里的一个MovieClip
role_mc.x = role_mc._x;
role_mc.y = role_mc._y;
var mouseListener:Object = new Object();
mouseListener.onMouseDown = function() {
moveRole(role_mc, _xmouse, _ymouse);
};
Mouse.addListener(mouseListener);
function moveRole(role:MovieClip, x:Number, y:Number) {
role.x = x;
role.y = y;
role.onEnterFrame = function() {
if (this.x != this._x) {
this._x = this.x-this._x>0 ? 1 : -1;
}
if (this.y != this._y) {
this._y = this.y-this._y>0 ? 1 : -1;
}
if (this.x == this._x && this.y == this._y) {
delete this.onEnterFrame;
}
};
}

分享:有关Flash AS3编程的一些总结
最近用AS3写一些项目,在编程过程中,碰到不少问题,同时也有一些收获和心得。现在贴出来希望对大家在AS3编程有一些帮助。假如你发现有说得不对的地方,你可以

/所属分类:Flash教程/更新时间:2008-03-05
相关Flash教程