FLASH網(wǎng)游通過XMLSocket與VB后臺通信_Flash教程
教程Tag:暫無Tag,歡迎添加,賺取U幣!
推薦:Flash游戲中導(dǎo)彈追蹤的算法先看下效果吧:代碼如下:/*請教大家一個(gè)關(guān)于勢函數(shù)用到追蹤和攔截的算法有研究過的能不能指點(diǎn)一下!PoweredBySundayEmail:[email protected]*/varst
前段時(shí)間用Flash做了個(gè)網(wǎng)游的Demo,通訊用的是Socket。曾承諾寫個(gè)教程,現(xiàn)在有空就把它寫寫吧。先從FLASH說起。我要達(dá)到的效果是點(diǎn)擊地面,人物就走到點(diǎn)擊的地點(diǎn)。思路:一個(gè)鼠標(biāo)監(jiān)聽器監(jiān)聽鼠標(biāo)的點(diǎn)擊事件,把X座標(biāo)和Y座標(biāo)傳到角色,做為角色的目的地。角色每一幀都向這個(gè)目的地移動一點(diǎn)點(diǎn)。
role_mc為場景里的一個(gè)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;
}
};
}
分享:有關(guān)Flash AS3編程的一些總結(jié)最近用AS3寫一些項(xiàng)目,在編程過程中,碰到不少問題,同時(shí)也有一些收獲和心得�,F(xiàn)在貼出來希望對大家在AS3編程有一些幫助。假如你發(fā)現(xiàn)有說得不對的地方,你可以
/所屬分類:Flash教程/更新時(shí)間:2008-03-05
相關(guān)Flash教程:
- 相關(guān)鏈接:
- 教程說明:
Flash教程-FLASH網(wǎng)游通過XMLSocket與VB后臺通信
。