FLASH網游通過XMLSocket與VB后臺通信_Flash教程
教程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教程:
- 相關鏈接:
- 教程說明:
Flash教程-FLASH網游通過XMLSocket與VB后臺通信
。