- 檔案 / 開新檔案 / action script 3.0
- 修改 / 文件 / 設定尺寸 800 * 600 / 確定
- 檔案 / 匯入 / 匯入至舞台 / 找圖片檔案/ 確定
- 調整圖片大小 / 600 / 400 /置於放右下方
- 檢視 / 尺規 / 請建置輔助線 / 平均圖片6塊
- 選取圖片 / 按 CTRL + B / 打散
- 選取左上方圖 / 按 F8 / 選取影片 / 輸入P1 / 確定
- 建立其他5個影片元件,並分別命名P2,P3,P4,P5,P6。
- 請自行定義其實體名稱為P1_MC,P2_MC, P3_MC,P4_MC, P5_MC,P6_MC
- 將目前圖層名稱命名為原圖
- 請複製圖層 : 原圖的第一個影格 [右鍵 / 複製影格]
- 鎖定圖層 / 增加5個圖層 , 分別命名 計時 , 拼圖 , 指令 , 縮圖 , 範圍框 , 文字
- 選取圖層:範圍框 / 繪製一個矩形框 / 設定寬:400 高:600
- 置於右下角 / 請將圖層置於最下方
- 選取圖層:原圖 / 拖曳放好定位[拼好的圖片] / 設定其alpha值為0
- 選取圖層:原圖 / 複製影格
- 選取圖層:縮圖 / 貼上影格 / 取消設定alpha / 縮小所有影片元件 / 取消所有實體名稱 / 放置畫面左上方。
- 選取圖層:拼圖 / 貼上影格 / 取消設定alpha / 重新設定所有實體名稱 P1_SC, P2_SC, P3_SC, P4_SC, P5_SC, P6_SC 放置畫面左下方任意位置。
- CTRL +F8 / 新增影片元件 / 命名文字 / 內容為2個影格 , 第1個影格 : 開始拼圖 , 第2個影格 , 完成拼圖
- 選取圖層:文字 / 拖曳文字元件至場景右上方 / 命名實體名稱 : txt_mc
- 選取計時圖層 / 增加動態文字欄位 / 命名: time_txt
- 選取指令圖層 / 按F9 / 輸入下列指令
var test=0;
txt_mc.stop();
var i;
var waittime= Math.floor(getTimer()/1000);
function count(){
var runtime= Math.floor(getTimer()/1000);
var my = runtime- waittime;
time_txt.text=my;
}
var timeCount=setInterval(count,500);
p1_sc.addEventListener("mouseDown",mousedown);
p2_sc.addEventListener("mouseDown",mousedown);
p3_sc.addEventListener("mouseDown",mousedown);
p4_sc.addEventListener("mouseDown",mousedown);
p5_sc.addEventListener("mouseDown",mousedown);
p6_sc.addEventListener("mouseDown",mousedown);
function mousedown(me:MouseEvent){
me.currentTarget.startDrag(true);
}
p1_sc.addEventListener("mouseUp",mouseup);
p2_sc.addEventListener("mouseUp",mouseup);
p3_sc.addEventListener("mouseUp",mouseup);
p4_sc.addEventListener("mouseUp",mouseup);
p5_sc.addEventListener("mouseUp",mouseup);
p6_sc.addEventListener("mouseUp",mouseup);
function mouseup(me:MouseEvent){
me.currentTarget.stopDrag();
for(i=0;i<6;i++){
if ((me.currentTarget.x<=this.getChildAt(i).x+40)
&& (me.currentTarget.x>=this.getChildAt(i).x-40)
&& (me.currentTarget.y<=this.getChildAt(i).y+40)
&& (me.currentTarget.y>=this.getChildAt(i).y-40))
{
me.currentTarget.x =this.getChildAt(i).x;
me.currentTarget.y =this.getChildAt(i).y;
if ((this.getChildAt(i).name=="p1_mc") && (me.currentTarget.name=="p1_sc")) test++;
if ((this.getChildAt(i).name=="p2_mc") && (me.currentTarget.name=="p2_sc")) test++;
if ((this.getChildAt(i).name=="p3_mc") && (me.currentTarget.name=="p3_sc")) test++;
if ((this.getChildAt(i).name=="p4_mc") && (me.currentTarget.name=="p4_sc")) test++;
if ((this.getChildAt(i).name=="p5_mc") && (me.currentTarget.name=="p5_sc")) test++;
if ((this.getChildAt(i).name=="p6_mc") && (me.currentTarget.name=="p6_sc")) test++;
trace(test);
}
}
if (test==6) {
txt_mc.gotoAndStop(2);
clearInterval(timeCount);
}
}
1 评论:
你好
我剛學flash
也想做拼圖遊戲
但我看不懂第四部分的第二點
能不能解說一下@@
謝謝~
发表评论