public static Node Create(string fileName) { var cmp = new MyTiledMap (); var tiledMap = new TiledMapComposer (); var node = new Node ("TiledMap"); node.Attach (tiledMap); node.Attach (cmp); tiledMap.LoadFromFile (fileName); var halfWidth = tiledMap.TileWidth / 2; var halfHeight = tiledMap.TileHeight / 2; // コリジョンなどのゲームロジックはすべて // 仮想の2D直交座標系で作成する // 表示だけアイソメトリック var colMap = node.Find("CollisionMap"); foreach (var tile in colMap.Downwards.Skip(1)) { var col = new CollisionObject(); col.Shape = new BoxShape (halfWidth, halfHeight, 1); col.SetOffset (halfWidth, halfHeight, 1); tile.Attach (col); } return node; }
public static Node Create(string fileName) { var cmp = new MyTiledMap (); var map = new TiledMapComposer (); var node = new Node ("TiledMap"); node.Attach (cmp); node.Attach (map); map.LoadFromFile (fileName); var halfTileWidth = map.TileWidth / 2; var halfTileHeight = map.TileHeight / 2; var colMap = node.Find ("CollisionMap"); foreach (var x in colMap.Downwards.Skip(1)) { var col = new CollisionObject (); col.Shape = new BoxShape (halfTileWidth, halfTileHeight, 1); col.SetOffset (halfTileWidth, halfTileHeight, 1); x.Attach (col); } var cabMap = node.Find ("CabbageMap"); foreach (var nod in cabMap.Downwards.Skip (1)) { var comp = new MyCabbage (); var col = new CollisionObject (); col.Shape = new BoxShape (halfTileWidth, halfTileHeight, 1); col.SetOffset (halfTileWidth, halfTileHeight, 1); nod.Attach (comp); nod.Attach (col); //n.GroupID = 0xffffffffu; } var bgMap = node.Find ("BackgroundMap"); //bgMap.GroupID = 0xffffffffu; return node; }