LoadedSprite loads the texture-reference from `engo.Files`, and wraps it in a `*Texture`. This method is intended for image-files which represent entire sprites.
(url string)
| 167 | // LoadedSprite loads the texture-reference from `engo.Files`, and wraps it in a `*Texture`. |
| 168 | // This method is intended for image-files which represent entire sprites. |
| 169 | func LoadedSprite(url string) (*Texture, error) { |
| 170 | res, err := engo.Files.Resource(url) |
| 171 | if err != nil { |
| 172 | return nil, err |
| 173 | } |
| 174 | |
| 175 | img, ok := res.(TextureResource) |
| 176 | if !ok { |
| 177 | return nil, fmt.Errorf("resource not of type `TextureResource`: %s", url) |
| 178 | } |
| 179 | |
| 180 | viewport := engo.AABB{Max: engo.Point{X: 1.0, Y: 1.0}} |
| 181 | if img.Viewport != nil { |
| 182 | viewport = *img.Viewport |
| 183 | } |
| 184 | return &Texture{img.Texture, img.Width, img.Height, viewport}, nil |
| 185 | } |
| 186 | |
| 187 | // Texture represents a texture loaded in the GPU RAM (by using OpenGL), which defined dimensions and viewport |
| 188 | type Texture struct { |