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

Function NewSpritesheetWithBorderFromFile

common/spritesheet.go:104–118  ·  view source on GitHub ↗

NewSpritesheetWithBorderFromFile creates a new spritesheet from a file This sheet has sprites of a uniform width and height, but also have borders around each sprite to prevent bleeding over

(textureName string, cellWidth, cellHeight, borderWidth, borderHeight int)

Source from the content-addressed store, hash-verified

102// This sheet has sprites of a uniform width and height, but also have borders around
103// each sprite to prevent bleeding over
104func NewSpritesheetWithBorderFromFile(textureName string, cellWidth, cellHeight, borderWidth, borderHeight int) *Spritesheet {
105 res, err := engo.Files.Resource(textureName)
106 if err != nil {
107 log.Println("[WARNING] [NewSpritesheetWithBorderFromFile]: Received error:", err)
108 return nil
109 }
110
111 img, ok := res.(TextureResource)
112 if !ok {
113 log.Println("[WARNING] [NewSpritesheetWithBorderFromFile]: Resource not of type `TextureResource`:", textureName)
114 return nil
115 }
116
117 return NewSpritesheetWithBorderFromTexture(&img, cellWidth, cellHeight, borderWidth, borderHeight)
118}
119
120// Cell gets the region at the index i, updates and pulls from cache if need be
121func (s *Spritesheet) Cell(index int) Texture {

Callers 1

createLevelFromTmxFunction · 0.85

Calls 2

ResourceMethod · 0.65

Tested by

no test coverage detected