?第一步:導入資料圖片
首先在flash中導入人物走路的圖片,如下圖:

第二步:制作向前后左右走路的影片剪輯
把剛才導入的圖片,分別制作成4個影片剪輯a,d,s,w,用來描述走路的過程,如下圖

第三步:制作Walk影片剪輯,
在主場景中建立一個walk影片剪輯,在walk中建立8個關鍵幀,幀標簽分別是: Right , Left , Down , Up ,
Right2 , Left2 , Down2 , Up2 前4個關鍵幀分別放置影片剪輯d,a,s,w ,后面4個關鍵幀放置相應的靜態圖片,
用來顯示
人物靜止時候的狀態.

第四步:加上影子
新建圖層yingzi,里面放置一個橢圓形陰影影片剪輯yingzi如下圖

第五步:添加AS,讓人物走動.
1、 在walk的第一幀加入stop();
2、 對walk加上 ClipEvent如下:
CODE:
onClipEvent (keyDown) {
//定義速度
var v = 2;
if (Key.isDown(Key.LEFT)) {
if (this._currentframe != "Left") {
this.gotoAndStop("Left");
}
this._x -= v;
}
if (Key.isDown(Key.RIGHT)) {
if (this._currentframe != "Right") {
this.gotoAndStop("Right");
}
this._x += v;
}
if (Key.isDown(Key.DOWN)) {
if (this._currentframe != "Down") {
this.gotoAndStop("Down");
}
this._y += v;
}
if (Key.isDown(Key.UP)) {
if (this._currentframe != "Up") {
this.gotoAndStop("Up");
}
this._y -= v;
}
}
onClipEvent (keyUp) {
if (Key.getCode() == 38) {
this.gotoAndStop("UP2");
}
if (Key.getCode() == 39) {
this.gotoAndStop("RIGHT2");
}
if (Key.getCode() == 40) {
this.gotoAndStop("DOWN2");
}
if (Key.getCode() == 37) {
this.gotoAndStop("LEFT2");
}
}
最終效果如下:

當然,這個家伙會滿屏跑,在傳統的RPG游戲當中,人物應該在屏幕的中央才對,
下節我們將講解如何實現人物在場景中行走。
最終效果如下:當然,這個家伙會滿屏跑,在傳統的RPG游戲當中,
人物應該在屏幕的中央才對,
下節我們將講解如何實現人物在場景中行走。
CODE:
[url=http://space.flash8.net/bbs/thread-307060-1-1.html###]
[Copy to clipboard]
[/url]
onClipEvent (keyDown) {
//定義速度
var v = 2;
if (Key.isDown(Key.LEFT)) {
if (this._currentframe != "Left") {
this.gotoAndStop("Left");
}
this._x -= v;
}
if (Key.isDown(Key.RIGHT)) {
if (this._currentframe != "Right") {
this.gotoAndStop("Right");
}
this._x += v;
}
if (Key.isDown(Key.DOWN)) {
if (this._currentframe != "Down") {
this.gotoAndStop("Down");
}
this._y += v;
}
if (Key.isDown(Key.UP)) {
if (this._currentframe != "Up") {
this.gotoAndStop("Up");
}
this._y -= v;
}
}
onClipEvent (keyUp) {
if (Key.getCode() == 38) {
this.gotoAndStop("UP2");
}
if (Key.getCode() == 39) {
this.gotoAndStop("RIGHT2");
}
if (Key.getCode() == 40) {
this.gotoAndStop("DOWN2");
}
if (Key.getCode() == 37) {
this.gotoAndStop("LEFT2");
}
}
最終效果如下:

當然,這個家伙會滿屏跑,在傳統的RPG游戲當中,人物應該在屏幕的中央才對,
下節我們將講解如何實現人物在場景中行走。
本文轉自:http://www.5uflash.com/flashjiaocheng/Flashyingyongkaifa/991.html
更多文章、技術交流、商務合作、聯系博主
微信掃碼或搜索:z360901061

微信掃一掃加我為好友
QQ號聯系: 360901061
您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對您有幫助就好】元
