這篇介紹遊戲的動畫

 

1. 你可以用連續的圖片來表示動畫
Loading Frames: 在Sprite內Load sprite可以一次選擇多張圖片
來取代單一圖片, 這樣系統會自動幫你處理當成動畫處理
Collision masks: 碰撞的遮罩可以手動調整
在按下modify mask之後即可進行

Playing The Animation: 在code裡面
image_speed 預設是1, 設成0則會停止撥放
with代表接下來的code會在特定對象執行
other代表其他instance
image_index代表現在秀的子圖片的索引
image_number代表所有子圖片的總數

01.png

 

2. Pro版和標準版的暫停Pause有不同的寫法
The Application Surface:
snapshot: 畫面的截圖
surface: 一個簡單的由系統繪製的表面
application_surface: 你遊戲在執行的表層

Creating A Sprite:
instance_deactivate_all(notme): 停用所有的instance,
如果notme為true, 則會保留之前istance的狀態
instance_activate_all(): 啟用所有的instance
sprite_exists(index): 判斷目標index的sprite是否存在
sprite_delete(index): 將目標index的sprite從記憶體刪除
sprite_create_from_surface(index, x, y, w, h, removeback, smooth, xorig, yorig):
從目標surface複製一塊面積建立一個sprite
index: 目標surface的索引
x: 從x座標開始的位置
y: 從y座標開始的位置
w: 從x座標開始要複製的畫面寬
h: 從x座標開始要複製的畫面高
removeback: 用來指示是否要對背景的像素做透明處理
smooth: 用來指示是否要對邊緣做smooth處理
xorig: 指示原本在sprite的原來x位置.
yorig: 指示原本在sprite的原來y位置.

Drawing:
draw_sprite(sprite, subimg, x, y): 在目標位置畫sprite
sprite: 要畫的sprite index
subimg: 要添加的子畫面索引
x: 從哪個x座標來畫製
y: 從哪個y座標來畫製

draw_set_alpha(alpha): 設定畫筆的透明度, 從0 ~ 1

draw_rectangle_colour(x1, y1, x2, y2, col1, col2, col3, col4, outline): 畫一個有顏色的長方形
x1 長方形的左邊x座標
y1 長方形的上方y座標
x2 長方形的右邊y做邊
y2 長方形的下方y座標
col1 左上角落的顏色
col2 右上角落的顏色
col3 右下角落的顏色
col4 左下角落的顏色
outline 用來指示是否要有邊框


Standard/Free Pausing: 如果不是Pro版則無法使用上述功能
ds_list_create: 建立一個List變回傳其id
ds_list_clear(id): 清除目標list的資料
ds_list_add(id, val1 [, val2, ... val15]): 將後面的值都加入目標list
ds_list_destroy(id): 銷毀目標list
ds_list_find_value(id, pos): 找到list內位置的值
draw_sprite_ext( sprite, subimg, x, y, xscale, yscale, rot, colour, alpha ):
繪製目標sprite, 並且可以客製化旋轉, 平移, 縮放
sprite The index of the sprite to draw.
subimg The subimg (frame) of the sprite to draw (image_index or -1 correlate to the current frame of animation in the object).
x The x coordinate of where to draw the sprite.
y The y coordinate of where to draw the sprite.
xscale The horizontal scaling of the sprite, as a multiplier: 1 = normal scaling, 0.5 is half etc...
yscale The vertical scaling of the sprite as a multiplier: 1 = normal scaling, 0.5 is half etc...
rot The rotation of the sprite. 0=right way up, 90=rotated 90 degrees counter-clockwise etc...
colour The colour with which to blend the sprite. c_white is to display it normally.
alpha The alpha of the sprite (from 0 to 1 where 0 is transparent and 1 opaque).

 

02.png

 

3. 問題集
Q1: 哪時候會使用手動遮罩?
A1: 當你想要把一些不需要計算的部分加入時會考慮用手動遮罩

Q2: other這參考在碰撞事件中代表甚麼?
A2: other代表除了自己本身之外的onstance

Q3: 甚麼是image_number和image_index的參照?
A3: 他們是所有instance都有的scope變數,
image_number會回傳sprite內sub-images的數量
image_index則是現在展示的sub-image索引

Q4: 甚麼是 application surface?
A4: application surface是一個特別的surface,
他代表遊戲內繪製你遊戲時的surface.

Q5: 什麼事情是你總是需要在surface創建sprites時候做的?
A5: 刪除它以避免memory leak.

03.png  

arrow
arrow
    文章標籤
    GameMaker Animation
    全站熱搜

    RX1226 發表在 痞客邦 留言(0) 人氣()