MCPcopy
hub / github.com/EngoEngine/engo / imageTiles

Method imageTiles

common/tmx_level.go:342–370  ·  view source on GitHub ↗
(tmxURL string, imgs []tmx.Image, x, y float32)

Source from the content-addressed store, hash-verified

340}
341
342func (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
372func (l *Level) tileFromGID(gid uint32, pt engo.Point) *Tile {
373 ret := &Tile{}

Callers 1

createLevelFromTmxFunction · 0.95

Calls 3

LoadedSpriteFunction · 0.85
LoadMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected