-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMultiSprite.lua
More file actions
39 lines (36 loc) · 1.23 KB
/
MultiSprite.lua
File metadata and controls
39 lines (36 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
--Class
MultiSprite = Sprite:extend()
--Class Methods
function MultiSprite:init(X, Y, W, H, new_sprite_atlas, multi_sprite_poss)
Sprite.init(self, X, Y, W, H, new_sprite_atlas, multi_sprite_poss[1])
self.multi_sprite_poss = multi_sprite_poss
end
function MultiSprite:draw_self(overlay)
if not self.states.visible then return end
if self.sprite_pos.x ~= self.sprite_pos_copy.x or self.sprite_pos.y ~= self.sprite_pos_copy.y then
self:set_sprite_pos(self.sprite_pos)
end
prep_draw(self, 1)
love.graphics.scale(1/(self.scale.x/self.VT.w), 1/(self.scale.y/self.VT.h))
love.graphics.setColor(overlay or G.BRUTE_OVERLAY or G.C.WHITE)
for _, ps in pairs(self.multi_sprite_poss) do
local sprite = love.graphics.newQuad(
ps.x*self.atlas.px,
ps.y*self.atlas.py,
self.scale.x,
self.scale.y, self.atlas.image:getDimensions()
)
love.graphics.draw(
self.atlas.image,
sprite,
0 ,0,
0,
self.VT.w/(self.T.w),
self.VT.h/(self.T.h)
)
end
love.graphics.pop()
add_to_drawhash(self)
self:draw_boundingrect()
if self.shader_tab then love.graphics.setShader() end
end