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

Method Cell

common/spritesheet.go:121–144  ·  view source on GitHub ↗

Cell gets the region at the index i, updates and pulls from cache if need be

(index int)

Source from the content-addressed store, hash-verified

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 {
122 if r, ok := s.cache[index]; ok {
123 return r
124 }
125
126 cell := s.cells[index]
127 s.cache[index] = Texture{
128 id: s.texture,
129 width: float32(cell.Width),
130 height: float32(cell.Height),
131 viewport: engo.AABB{
132 Min: engo.Point{
133 X: cell.Position.X / s.width,
134 Y: cell.Position.Y / s.height,
135 },
136 Max: engo.Point{
137 X: (cell.Position.X + float32(cell.Width)) / s.width,
138 Y: (cell.Position.Y + float32(cell.Height)) / s.height,
139 },
140 },
141 }
142
143 return s.cache[index]
144}
145
146// Drawable returns the drawable for a given index
147func (s *Spritesheet) Drawable(index int) Drawable {

Callers 7

DrawableMethod · 0.95
CellsMethod · 0.95
WidthMethod · 0.95
HeightMethod · 0.95
CreateHeroMethod · 0.45
CreateEntityMethod · 0.45
SetupMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected