fix(assets/gfx): more gfx fixes
This commit is contained in:
parent
9ad1e5c4f1
commit
553d7feab4
3 changed files with 12 additions and 9 deletions
|
@ -41,9 +41,9 @@ function GFX:new(world, position, spritename, is3D, useMiddle)
|
||||||
type = "gfx",
|
type = "gfx",
|
||||||
dimensions = dimensions,
|
dimensions = dimensions,
|
||||||
isSolid = false,
|
isSolid = false,
|
||||||
visual = {
|
visuals = {
|
||||||
type = "sprite",
|
mode = "sprite",
|
||||||
asset = spritename,
|
assetName = spritename,
|
||||||
clone = true,
|
clone = true,
|
||||||
withCallbacks = true
|
withCallbacks = true
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ function Visual:_initVisual(def)
|
||||||
if (self.visualMode == "box") then
|
if (self.visualMode == "box") then
|
||||||
self:_initBox(def.color or {r = 0, g = 0, b = 0})
|
self:_initBox(def.color or {r = 0, g = 0, b = 0})
|
||||||
elseif (self.visualMode == "sprite") then
|
elseif (self.visualMode == "sprite") then
|
||||||
self:_initSprite(def.assetName, def.clone == true, def.origin or {}, def.getHitboxes == true)
|
self:_initSprite(def.assetName, def.clone == true, def.origin or {}, def.withCallbacks == true, def.getHitboxes == true)
|
||||||
end
|
end
|
||||||
|
|
||||||
if (self.visual ~= nil) then
|
if (self.visual ~= nil) then
|
||||||
|
@ -75,8 +75,8 @@ end
|
||||||
-- SPRITE HANDLING
|
-- SPRITE HANDLING
|
||||||
-- Handle the sprite mode for visual
|
-- Handle the sprite mode for visual
|
||||||
|
|
||||||
function Visual:_initSprite(name, isClone, origin, getHitboxes)
|
function Visual:_initSprite(name, isClone, origin, withCallbacks, getHitboxes)
|
||||||
self.visual = Sprite(self, name, isClone, origin, getHitboxes)
|
self.visual = Sprite(self, name, isClone, origin, withCallbacks, getHitboxes)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- TILE HANDLING
|
-- TILE HANDLING
|
||||||
|
|
|
@ -4,7 +4,7 @@ local Vector3D = require "framework.libs.brinevector3D"
|
||||||
-- SPRITES FUNCTIONS
|
-- SPRITES FUNCTIONS
|
||||||
-- Handle the sprite of the actor
|
-- Handle the sprite of the actor
|
||||||
|
|
||||||
function Sprite:new(owner, name, isClone, origin, getHitboxes)
|
function Sprite:new(owner, name, isClone, origin, withCallbacks, getHitboxes)
|
||||||
self.owner = owner
|
self.owner = owner
|
||||||
self.animators = self.owner.world.animators
|
self.animators = self.owner.world.animators
|
||||||
self.name = name or nil
|
self.name = name or nil
|
||||||
|
@ -15,6 +15,9 @@ function Sprite:new(owner, name, isClone, origin, getHitboxes)
|
||||||
if (isClone) then
|
if (isClone) then
|
||||||
self:clone()
|
self:clone()
|
||||||
end
|
end
|
||||||
|
if (withCallbacks) then
|
||||||
|
self:activateCallbacks()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function Sprite:clone()
|
function Sprite:clone()
|
||||||
|
@ -89,9 +92,9 @@ function Sprite:draw(position)
|
||||||
local sx, sy = self.scale.x, self.scale.y
|
local sx, sy = self.scale.x, self.scale.y
|
||||||
|
|
||||||
if (self.spriteClone ~= nil) then
|
if (self.spriteClone ~= nil) then
|
||||||
self.spriteClone:draw(x, y, 0, sx, sy)
|
self.spriteClone:draw(math.floor(x), math.floor(y), 0, sx, sy)
|
||||||
else
|
else
|
||||||
self.animators:draw(self.name, x, y, 0, sx, sy)
|
self.animators:draw(self.name, math.floor(x), math.floor(y), 0, sx, sy)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue