(tmxURL string, imgs []tmx.Image, x, y float32)
| 340 | } |
| 341 | |
| 342 | func (l *Level) imageTiles(tmxURL string, imgs []tmx.Image, x, y float32) ([]*Tile, error) { |
| 343 | ret := make([]*Tile, 0) |
| 344 | for _, i := range imgs { |
| 345 | if i.Source != "" { |
| 346 | tex, err := LoadedSprite(path.Join(path.Dir(tmxURL), i.Source)) |
| 347 | if err != nil { |
| 348 | if strings.HasPrefix(err.Error(), "resource not loaded") { |
| 349 | err = engo.Files.Load(path.Join(path.Dir(tmxURL), i.Source)) |
| 350 | if err != nil { |
| 351 | return nil, err |
| 352 | } |
| 353 | tex, err = LoadedSprite(path.Join(path.Dir(tmxURL), i.Source)) |
| 354 | } else { |
| 355 | return nil, err |
| 356 | } |
| 357 | } |
| 358 | tile := &Tile{ |
| 359 | Image: tex, |
| 360 | Point: engo.Point{ |
| 361 | X: x, |
| 362 | Y: y, |
| 363 | }, |
| 364 | } |
| 365 | ret = append(ret, tile) |
| 366 | } |
| 367 | // TODO: handle image data (not supported by Tiled, but some Java versions do have it) |
| 368 | } |
| 369 | return ret, nil |
| 370 | } |
| 371 | |
| 372 | func (l *Level) tileFromGID(gid uint32, pt engo.Point) *Tile { |
| 373 | ret := &Tile{} |
no test coverage detected