feat: scissor player when under the ground height
This commit is contained in:
parent
15973e491a
commit
b16665a2b0
2 changed files with 20 additions and 5 deletions
|
@ -31,6 +31,8 @@ function Parent:initCharset()
|
|||
self.isFast = false
|
||||
self.largeAnim = false
|
||||
self.alwaysWalk = false
|
||||
self.scissorSprite = false
|
||||
self.groundHeight = 0
|
||||
end
|
||||
|
||||
function Parent:setCharset(charset, charId, cantWalk)
|
||||
|
@ -45,8 +47,17 @@ function Parent:drawCharset(charset, charId)
|
|||
local z = math.floor(self.z)
|
||||
|
||||
love.graphics.setColor(1,1,1,0.5)
|
||||
if (self.groundHeight == 0) then
|
||||
self.assets.images["shadow"]:draw(x + 1, y + 11)
|
||||
end
|
||||
utils.graphics.resetColor()
|
||||
|
||||
if (self.scissorSprite) then
|
||||
local _, camy = self.world.cameras:getViewCoordinate(1)
|
||||
local viewy = math.floor((self.y + self.h - self.groundHeight) - camy)
|
||||
love.graphics.setScissor(0, 0, 424, viewy)
|
||||
end
|
||||
|
||||
if (self.largeAnim) then
|
||||
self.charsetManager:drawLargeAnim(self.charset, self.charId, self.charDir, x, y - z, self.isFast)
|
||||
else
|
||||
|
@ -60,15 +71,18 @@ function Parent:drawCharset(charset, charId)
|
|||
self.charsetManager:drawTurning(self.charset, self.charId, x, y - z, self.isFast)
|
||||
end
|
||||
end
|
||||
|
||||
if (self.scissorSprite) then
|
||||
love.graphics.setScissor()
|
||||
end
|
||||
end
|
||||
|
||||
function Parent:draw()
|
||||
if (self.charset ~= nil) then
|
||||
self:drawCharset()
|
||||
else
|
||||
if (self.drawDebugBox) then
|
||||
love.graphics.rectangle("line", math.floor(self.x), math.floor(self.y), self.w, self.h)
|
||||
end
|
||||
if (self.charset ~= nil) then
|
||||
self:drawCharset()
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ local ACTIONS_ISFAST = {"jump", "fly", "run", "jumpdash"}
|
|||
local ACTIONS_ALWAYSWALK = {"fly"}
|
||||
|
||||
function PlayerCharset:initPlayerCharset()
|
||||
self.scissorSprite = true
|
||||
self:updateCurrentCharset()
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue