找回密码
 点一下
查看: 4509|回复: 18

基礎觸發教程 - 持續更新

[复制链接]
发表于 2010-11-8 19:25:49 | 显示全部楼层 |阅读模式
教程一 : 基礎dialog 應用
-------------------------------------
無論做任何事都好,周詳的計畫是必須的。沒有計畫,做任何事都會一塌糊塗。 
-------------------------------------
今次我們要弄一個dialog,配合上一些按鈕來發揮其功效。
-------------------------------------
1.打開觸發器


2.把自己的資料分類好( 我這裡的分法 就是dialog - tutorial 1 - variable
  - action
  - trigger
1.JPG
3.在variable欄,創建一個變數(如下圖) : 
Dialog:Dialog:DialogID ,種類設為dialog,第一個陣列設3 (3個種族) 第二個陣列 設2(一個用於建造單位,稍後會有其他)
2.JPG

4.暫時先弄這個variable,接下來於action下面創造一個新的action definition(快捷建:ctrl + alt + R)
名字設為dialog:Dialog:CreateDialog
用途為創建一個空白的dialog,並給予一個變數來代替。
接下來弄些parameters(參數),parameter作用是代替某些空白的參數。parameter與variable不同,parameter能夠於trigger subview等地方設置新的參數)   
 Parameters
&#160;&#160; &#160; &#160; &#160;Size X = 0 <Integer> 大小(x)
&#160;&#160; &#160; &#160; &#160;Size Y = 0 <Integer> 大小(y)
&#160;&#160; &#160; &#160; &#160;Offset X = 0 <Integer> 偏移(x)
&#160;&#160; &#160; &#160; &#160;Offset Y = 0 <Integer> 偏移(y)
&#160;&#160; &#160; &#160; &#160;Race = 0 <Integer> (種族)
&#160;&#160; &#160; &#160; &#160;Panel ID = 0 <Integer> (面板id)
&#160;&#160; &#160; &#160; &#160;Anchor = Bottom Left <Anchor> (與某個地方綁定)
&#160;&#160; &#160; &#160; &#160;Player ID = (Empty player group) <Player Group> (玩家的id)



5.有了parameters,接下來開始弄action(行動)
非常容易的。
&#160;&#160; &#160; &#160; &#160;Dialog - Create a Modal dialog of size (Size X(上面的parameter), Size Y(上面的parameter)) at (Offset X(上面的parameter), Offset Y(上面的parameter)) relative to Anchor(上面的parameter)&#160;of screen
4.JPG

&#160;&#160; &#160; &#160; &#160;Variable - Set Dialog:Dialog:DialogID[Race][Panel ID] = (Last created dialog)

如此設定後,便能讓用者自行設置dialog的大小,暫時來說因為action比較少,直接弄也可以,但當後來要設置dialog的各種參數時,有了action便能使你的生命變得更美好了…(至少不會被密麻麻的action弄得頭暈)
3.JPG

6.有dialog 沒有dialog item,那只是一個面板而已,一點作用都沒有,於是我們一起弄些新的按鈕吧。
一樣新的變數 :&#160;Dialog:DialogItem:ButtonID 用來記錄各個新按鈕的id,方便日後使用


7.新action 名叫:Dialog:DialogItem:CreateButtonWithImage 如其名,用來創造一個有圖片的按鈕
一樣的弄新的參數
&#160;&#160; &#160;Parameters
&#160;&#160; &#160; &#160; &#160;Dialog = No Dialog <Dialog> 指定綁於哪個dialog
&#160;&#160; &#160; &#160; &#160;Offset X = 0 <Integer>
&#160;&#160; &#160; &#160; &#160;Offset Y = 0 <Integer>
&#160;&#160; &#160; &#160; &#160;Image = No File <File - Image> (注意)
5.JPG

&#160;&#160; &#160; &#160; &#160;Tooltip = No Text <Text>
&#160;&#160; &#160; &#160; &#160;Race = 0 <Integer>
&#160;&#160; &#160; &#160; &#160;Unit ID = 0 <Integer>
&#160;&#160; &#160; &#160; &#160;Anchor = Bottom Left <Anchor> 一樣,綁定於dialog的哪個方向

有了參數,少不得action了
&#160;&#160; &#160;Actions
&#160;&#160; &#160; &#160; &#160;Dialog - Create a button for dialog Dialog with the dimensions (76, 76) anchored to Anchore with an offset of (Offset X, Offset Y) setting the tooltip to Tooltip with button text " " and the hover image set to "" 創造一個空白的按鈕,不需要給他任何東西,更不要給他圖片。原因是我們見到的button其實是從一張dds裡慢慢抽出button的各個部份拼湊而成。假若你在按鈕中使用圖片,系統會利用該圖片來拼湊按鈕,弄成一個像屎一樣的東西。


&#160;&#160; &#160; &#160; &#160;Variable - Set Dialog:DialogItem:ButtonID[Race][Unit ID] = (Last created dialog item) 設定變數為上面弄的按鈕,方便日後用途


&#160;&#160; &#160; &#160; &#160;Dialog - Create an image for dialog Dialog with the dimensions (76, 76) anchored to Anchore with an offset of (Offset X, Offset Y) setting the tooltip to "" using the image Image as a Normal type with tiled set to true tint color White and blend mode Normal 這個圖片的作用是放在button 之上,使別人還是能看得見一張圖片。



8.於是2個新的action 弄好了(但未能發揮我們的功效),現在於trigger底下新建一個觸發 名叫:dialog ini.


jn事件少不了就是
&#160;&#160; &#160;Events
&#160;&#160; &#160; &#160; &#160;Game - Map initialization (地圖初始化)



行動 , 由於我們上面弄了2個新的action 不用繁瑣的再弄一次,直接在 -General [ 注意有2個general 我們要的是最上面的那個 ]找尋我們的2個action,先加入dialog:Dialog:CreateDialog,並指定參數
6.JPG



考慮到不同的種族,不可能建同一樣的單位吧,因為我們加上一個新的action - pick each player in player group and do (action) (這次在 player group的底下) [ 中文大概是挑選在玩家群組的各個玩家]
&#160;&#160; &#160; &#160; &#160;Player Group - Pick each player in (All players) and do (Actions)



然後於action 下面加if-then-else(在大約中間的general處可以找到)
if (假如)
&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;If
&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;(Race of player (Picked player)) == Zerg

假如被挑起的玩家是zerg(蟲)
then (便)
&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;Dialog:Dialog:CreateDialog(300, 400, 50, 0, 1, 1, Left)


創造一個dialog 300*400,x偏移50個單位,並綁定至屏幕的左方。
&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;Dialog:DialogItem:CreateButtonWithImage((Last created dialog), 25, 25, Assets\Textures\btn-unit-zerg-zergling.dds, "Create a zergling at the point you ...", 1, 1, Top Left)

創造一個有圖片的按鈕,圖片設為zergling(小狗)的圖標,tooltip隨意打…沒關係的
else(否則)
General - If (Conditions) then do (Actions) else do (Actions)                            If                                (Race of player (Picked player)) == Protoss
&#160;判定其是不是神族,然後再跟著上面弄,直至三族都弄完。(假如沒弄新action,你可以想像得到那些密鋪的trigger多半會令你發狂)其實你也不必這樣,也可以直接爆出幾個dialog而不用if-then-else,因為後面會有判定的語句。
簡單的dialog 弄完了(但沒有任何的功效) 以下是根據上面弄得出的成果。你會發現沒有顯示出來,那是正常的,以後我們會有方法把他弄出來。
7.JPG

---------------------------------------------------------
章節 二 給予按鈕一個功能
1.一樣新的variable:
Dialog:DialogItem:CheckButtonIsClickedOrNot type : boolean(真假二值 - 布爾數學邏輯)


2.新action : Dialolg:DialogItem:EnableCreateUnit
parameter:
  Parameters        Race = 0 <Integer>        Unit ID = 0 <Integer>        Dialog Item Check = No Dialog Item <Dialog Item> 判定是哪個按鈕被按


action:
    Actions        General - If (Conditions) then do (Actions) else do (Actions)            If                Dialog Item Check == Dialog:DialogItem:ButtonID[Race][Unit ID] 判定按的按鈕究竟是什麼            Then                Variable - Set Dialog:DialogItem:CheckButtonIsClickedOrNot[Race][Unit ID] = true 把相對應的 boolean 設為真,日後作用
            Else


3.新action: Dialog:DialogItem:CreateUnit
    Parameters        Race = 0 <Integer>        Unit ID = 0 <Integer>        Unit Type = No Game Link <Game Link - Unit>        Point X = 0.0 <Real>        Point Y = 0.0 <Real>        Player ID = 0 <Integer>


action:
&#160;&#160; &#160;Actions
&#160;&#160; &#160; &#160; &#160;General - If (Conditions) then do (Actions) else do (Actions)
&#160;&#160; &#160; &#160; &#160; &#160; &#160;If
&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;Dialog:DialogItem:CheckButtonIsClickedOrNot[Race][Unit ID] == true 判定該變數是否"真",假若是真,便於指定地點創造一個單位
&#160;&#160; &#160; &#160; &#160; &#160; &#160;Then
&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;Unit - Create 1 Unit Type for player Player ID at (Point(Point X, Point Y)) using default facing (No Options)
&#160;&#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160;Variable - Set Dialog:DialogItem:CheckButtonIsClickedOrNot[Race][Unit ID] = false
&#160;&#160; &#160; &#160; &#160; &#160; &#160;Else

4.新trigger : Dialog:EnableCreateUnit


event :&#160;
&#160;&#160; &#160; &#160; &#160;Dialog - Any Dialog Item is used by Player Any Player with event type Clicked 任何一個 物品 被使用

action 運用上面的&#160;Dialolg:DialogItem:EnableCreateUnit 並根據參數 填空位,大約如下,切記把dialog check 設為used dialog item(被使用的物品)。
8.JPG



5.這樣子,上面弄的variable只要在按鈕被按時,就會變成真,之後弄新trigger :Dialog:CreateUnit
    Events        UI - Player Any Player clicks Left mouse button Down..
這個事件,作用為任何玩家按下了 左鍵。
接下來action 用回上面的
        Dialog:DialogItem:CreateUnit(1, 1, Zergling, (Mouse X position clicked in the world), (Mouse Y position clicked in the world), (Triggering player))
[因為上面的action 包括了判定字句,因此不需特別再弄]
有了(Mouse X position clicked in the world)和(Mouse Y position clicked in the world)可以追踪點擊的位置,並於該處創造一個對應的單位。
9.JPG



於是一個完整的按鈕便出來了,但這遠遠不夠,因為我們必須要令dialog出來能按到。於是,在dialog ini的末加上一句代碼:
        Dialog - Display button 1 of size (200, 60) with text "Unit Panel" at Right of screen with offset (50, 0)  (run No Trigger when button is clicked)
需要注意的是,這裡的button是指screen button (營幕按鈕) 它是永遠存在的,不需要特別的show hide…除非你有其他用途,例如cinematic需要隱藏掉按鈕。


新action definition : Dialog:OpenDialog
parameter :
    Parameters        race = No Game Link <Game Link - Race>        RaceID = 0 <Integer>        PanelID = 0 <Integer>        PlayerID = 0 <Integer>
action:
        General - If (Conditions) then do (Actions) else do (Actions)            If                (Race of player (Triggering player)) == race 如果玩家是指定的種族 便開啟指定的dialog            Then                Dialog - Show Dialog:Dialog:DialogID[RaceID][PanelID] for (Player group(PlayerID))            Else




然後新的trigger - Dialog:OpenDialog
event :
  Dialog - (Screen button 1) is used by Player Any Player with event type Clicked
注意screen button亦屬dialog item的一種。
&#160;action:              Dialog:OpenDialog(Zerg, 1, 1, (Triggering player))判定不同種族,來開啟不同的視窗。
於是一個基礎的單位建造面板成功了,當然你可以加上更多更多的action來豐富你的new action definition但有鑑於這是基礎觸發,我就不寫那麼多了(我的另一個練習包括了資源是否足夠,如果不足夠便隱藏;此外亦有建築和科技判定。亦有一個科技樹)
效果圖:
-----------------------------------------
如果這能夠幫助得到大家,那麼我便滿足。 假若大家有其他的需求可以問,我會盡量幫你的忙。[其實本來我想拍片的,拍片方便得多,但有鑑於我的聲音比較 那個 就算了]
我會持續更新教程…假若有人支持的話...(沒支持一切都是浮雲,畢竟沒推動力去弄。)



评分

参与人数 1威望 +4 收起 理由
Renee + 4 好~~

查看全部评分

发表于 2010-11-8 21:02:05 | 显示全部楼层
支持~~~另外,可以用变声器
回复

使用道具 举报

 楼主| 发表于 2010-11-8 21:09:26 | 显示全部楼层
變聲器QQ?
回复

使用道具 举报

发表于 2010-11-8 21:16:24 | 显示全部楼层
用什么变声软件也许有?反正,录制好的片子也可以用一些专业软件处理一下音频,变成完全不是你的声音~
回复

使用道具 举报

发表于 2010-11-8 22:16:42 | 显示全部楼层
支持~! 正好可以学习下~
回复

使用道具 举报

发表于 2010-11-9 00:07:49 | 显示全部楼层
支持好的教程! 加油!

建議可以給個教程的地圖給新手下來研究.

另外怎麼我看到教程的字體一時大一時小?
回复

使用道具 举报

发表于 2010-11-9 10:41:18 | 显示全部楼层
支持~~不过为啥有些字体非常的小?~~
回复

使用道具 举报

发表于 2010-11-9 11:09:36 | 显示全部楼层
支持啊,楼主要努力!
回复

使用道具 举报

 楼主| 发表于 2010-11-9 16:58:20 | 显示全部楼层
啊…字體大小…啊…我用的都是默認大小,沒有調過…我等會把字都調大些吧…至於地圖嘛…我等會上傳…
回复

使用道具 举报

发表于 2010-11-14 11:29:59 | 显示全部楼层
好的教程應該加一個連結到置頂帖吧!
回复

使用道具 举报

发表于 2010-11-14 12:09:41 | 显示全部楼层
hmmm~~说起来置顶确实好久没更新了~~
回复

使用道具 举报

发表于 2010-11-15 09:23:45 | 显示全部楼层
顶下...
回复

使用道具 举报

发表于 2011-1-12 14:08:16 | 显示全部楼层
我用的是中文的,这个看不懂啊,,,晕
回复

使用道具 举报

发表于 2011-2-3 15:54:01 | 显示全部楼层
果断要更新,无敌顶,支持你!
回复

使用道具 举报

发表于 2011-2-9 23:12:59 | 显示全部楼层
置顶好久没更新了.
谢谢楼主的讲解
回复

使用道具 举报

发表于 2011-5-2 13:42:30 | 显示全部楼层
请问  
Anchor  在中文编辑器里面[具体是哪个类型呢-。-
回复

使用道具 举报

发表于 2011-5-10 02:06:57 | 显示全部楼层
英文不好 看的很郁闷~·~~
回复

使用道具 举报

发表于 2011-5-10 02:29:55 | 显示全部楼层
同问同问 Anchor应该指的是锚点吧    但是好像类型里面没有这个啊
回复

使用道具 举报

发表于 2011-5-10 13:55:20 | 显示全部楼层
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 点一下

本版积分规则

Archiver|移动端|小黑屋|地精研究院

GMT+8, 2024-9-28 08:20 , Processed in 0.160837 second(s), 23 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表