首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式碼之家 >> 編程語言 >  >> C語言 >> 關於C語言

WPF/Silverlight 遊戲開發教程(十八之二):裝備合成核心方法 EquipPart 詳解

     編輯:關於C語言

EquipPart() 方法將角色身體大圖(5100×1200)與同尺寸武器大圖合成,組裝成帶武器的角色圖,最後按 150×150 尺寸切割儲存進 PartImage 交錯陣列:

精靈控件必要屬性

public BitmapSource[,] Source { get; set; }
public int DirectionNum { get; set; }
public Actions Action { get; set; }
public Actions OldAction { get; set; }
public int[] EachActionFrameRange { get; set; }
public int DirectionFrameNum { get; set; }
public int CurrentStartFrame { get; set; }
public int CurrentEndFrame { get; set; }
public int TotalWidth { get; set; }
public int TotalHeight { get; set; }
public int SingleWidth { get; set; }
public int SingleHeight { get; set; }
public int[] Equipment { get; set; } // [0]衣服 [1]武器 [2]頭盔 ...

動作枚舉定義

public enum Actions
{
    Stop = 0,    // 停止
    Run = 1,     // 跑動
    Attack = 2,  // 戰鬥
    Magic = 3,   // 施法
    Death = 9,   // 死亡
}

BitmapSource[,] Source 為 EquipPart() 回傳的圖片源,生命執行緒中呼叫顯示對應幀;Action、OldAction 為動作狀態枚舉。這些屬性奠定了八方向精靈系統的基礎。

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式碼之家 All Rights Reserved