fix(actors): replace deprecated functions after the sprite transition
This commit is contained in:
parent
8b3a5f1f0c
commit
92cbda69a1
9 changed files with 40 additions and 58 deletions
|
@ -130,7 +130,7 @@ end
|
|||
-- Functions related to actor hitboxes
|
||||
|
||||
function Actor2D:addHitboxFromFrameData(framedata, animationID, frameID, hitboxID)
|
||||
local sx, sy = self:getSpriteScalling()
|
||||
local sx, sy = self.sprite:getScalling()
|
||||
local type = framedata[1]
|
||||
local ox = framedata[2]
|
||||
local oy = framedata[3]
|
||||
|
|
|
@ -152,7 +152,7 @@ end
|
|||
-- Functions related to actor hitboxes
|
||||
|
||||
function Actor3D:addHitboxFromFrameData(framedata, animationID, frameID, hitboxID)
|
||||
local sx, sy = self:getSpriteScalling()
|
||||
local sx, sy = self.sprite:getScalling()
|
||||
local type = framedata[1]
|
||||
local ox = framedata[2]
|
||||
local oy = framedata[3]
|
||||
|
|
|
@ -292,8 +292,8 @@ function BaseActor:updateHitboxes()
|
|||
if (self.hitboxList ~= nil) then
|
||||
self:purgeHitbox()
|
||||
local animation, frame
|
||||
animation = self:getCurrentAnimation()
|
||||
frame = self:getRelativeFrame()
|
||||
animation = self.sprite:getCurrentAnimation()
|
||||
frame = self.sprite:getRelativeFrame()
|
||||
local hitboxList = self:getHitboxList(animation, frame)
|
||||
|
||||
if (hitboxList ~= nil) then
|
||||
|
@ -364,13 +364,9 @@ end
|
|||
-- SPRITES FUNCTIONS
|
||||
-- Handle the sprite of the actor
|
||||
|
||||
function BaseActor:setSprite(spritename, ox, oy)
|
||||
function BaseActor:setSprite(spritename, isClone, ox, oy)
|
||||
self.sprite = Sprite(self, spritename, ox, oy)
|
||||
end
|
||||
|
||||
function BaseActor:cloneSprite()
|
||||
if self.sprite ~= nil then
|
||||
core.debug:warning("actor", "the function BaseActor:cloneSprite is deprecated, prefer BaseActor.sprite:clone()")
|
||||
if (isClone) then
|
||||
self.sprite:clone()
|
||||
end
|
||||
end
|
||||
|
@ -399,16 +395,6 @@ function BaseActor:updateSprite(dt)
|
|||
end
|
||||
end
|
||||
|
||||
function BaseActor:setSpriteScallingX(sx)
|
||||
core.debug:warning("actor", "the function BaseActor:setSpriteScallingX is deprecated, prefer BaseActor.sprite:setSpriteScallingX()")
|
||||
self.sprite:setScallingX(sx)
|
||||
end
|
||||
|
||||
function BaseActor:setSpriteScallingY(sy)
|
||||
core.debug:warning("actor", "the function BaseActor:setSpriteScallingY is deprecated, prefer BaseActor.sprite:setSpriteScallingY()")
|
||||
self.sprite:setScallingY(sY)
|
||||
end
|
||||
|
||||
function BaseActor:getCurrentAnimation()
|
||||
if (self.sprite ~= nil) then
|
||||
core.debug:warning("actor", "the function BaseActor:getCurrentAnimation is deprecated, prefer BaseActor.sprite:getCurrentAnimation()")
|
||||
|
@ -416,25 +402,28 @@ function BaseActor:getCurrentAnimation()
|
|||
end
|
||||
end
|
||||
|
||||
|
||||
function BaseActor:getSpriteScalling()
|
||||
core.debug:warning("actor", "the function BaseActor:getSpriteScalling is deprecated, prefer BaseActor.sprite:getScalling()")
|
||||
return self.sprite:getScalling()
|
||||
end
|
||||
|
||||
function BaseActor:getFrame()
|
||||
if (self.sprite ~= nil) then
|
||||
core.debug:warning("actor", "the function BaseActor:getFrame is deprecated, prefer BaseActor.sprite:getFrame()")
|
||||
return self.sprite:getFrame()
|
||||
end
|
||||
end
|
||||
|
||||
function BaseActor:getRelativeFrame()
|
||||
if (self.sprite ~= nil) then
|
||||
core.debug:warning("actor", "the function BaseActor:getRelativeFrame is deprecated, prefer BaseActor.sprite:getRelativeFrame()")
|
||||
return self.sprite:getRelativeFrame()
|
||||
end
|
||||
end
|
||||
|
||||
function BaseActor:getAnimationDuration()
|
||||
if (self.sprite ~= nil) then
|
||||
core.debug:warning("actor", "the function BaseActor:getAnimationDuration is deprecated, prefer BaseActor.sprite:getAnimationDuration()")
|
||||
return self.sprite:getAnimationDuration()
|
||||
end
|
||||
end
|
||||
|
|
|
@ -29,8 +29,7 @@ function GFX:new(world, x, y, spritename)
|
|||
local width, height = world.scene.assets.sprites[spritename]:getDimensions()
|
||||
|
||||
GFX.super.new(self, world, "gfx", x - (width/2), y - (height/2), width, height)
|
||||
self:setSprite(spritename)
|
||||
self:cloneSprite()
|
||||
self:setSprite(spritename, true)
|
||||
end
|
||||
|
||||
function GFX:animationEnded(animation)
|
||||
|
|
|
@ -29,8 +29,7 @@ function GFX:new(world, x, y, z, spritename)
|
|||
local width, height = world.scene.assets.sprites[spritename]:getDimensions()
|
||||
|
||||
GFX.super.new(self, world, "gfx", x - (width/2), y - (width/2), z - (height/2), width, width, height)
|
||||
self:setSprite(spritename)
|
||||
self:cloneSprite()
|
||||
self:setSprite(spritename, true)
|
||||
end
|
||||
|
||||
function GFX:animationEnded(animation)
|
||||
|
|
|
@ -48,17 +48,15 @@ function Sprite:update(dt)
|
|||
end
|
||||
end
|
||||
|
||||
function Sprite:setScallingX(sx)
|
||||
local sx = sx or 1
|
||||
|
||||
function Sprite:setScalling(sx, sy)
|
||||
if (sx ~= nil) then
|
||||
self.sx = sx
|
||||
end
|
||||
|
||||
function Sprite:setScallingY(sy)
|
||||
local sy = sy or 1
|
||||
|
||||
if (sy ~= nil) then
|
||||
self.sy = sy
|
||||
end
|
||||
end
|
||||
|
||||
function Sprite:getCurrentAnimation()
|
||||
if (self:isCloned()) then
|
||||
|
|
|
@ -6,8 +6,7 @@ function Player:new(world, x, y, z, id)
|
|||
Player.super.new(self, world, "player", x, y, 0, 16, 16, 24, true)
|
||||
self:setGravity(480)
|
||||
|
||||
self:setSprite("player", 8, 12)
|
||||
self:cloneSprite()
|
||||
self:setSprite("player", true, 8, 12)
|
||||
self:setHitboxFile("scenes.gameplay.action3D.actors.hitboxes.player")
|
||||
end
|
||||
|
||||
|
@ -49,19 +48,19 @@ end
|
|||
|
||||
function Player:setAnimation()
|
||||
local gsp = utils.math.pointDistance(0, 0, self.xsp, self.ysp)
|
||||
self:setCustomSpeed(math.abs(gsp) / 12)
|
||||
self.sprite:setCustomSpeed(math.abs(gsp) / 12)
|
||||
self:setDirection(self.xsp)
|
||||
if (self.isPunching) then
|
||||
self:changeAnimation("punch", false)
|
||||
self.sprite:changeAnimation("punch", false)
|
||||
else
|
||||
if (self.onGround) then
|
||||
if (math.abs(self.xsp) > 0) or (math.abs(self.ysp) > 0) then
|
||||
self:changeAnimation("walk", false)
|
||||
self.sprite:changeAnimation("walk", false)
|
||||
else
|
||||
self:changeAnimation("idle", true)
|
||||
self.sprite:changeAnimation("idle", true)
|
||||
end
|
||||
else
|
||||
self:changeAnimation("jump", true)
|
||||
self.sprite:changeAnimation("jump", true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -71,7 +70,7 @@ function Player:setDirection(direction)
|
|||
if direction ~= 0 then
|
||||
direction = utils.math.sign(direction)
|
||||
self.direction = direction
|
||||
self:setSpriteScallingX(direction)
|
||||
self.sprite:setScalling(direction, nil)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -6,8 +6,7 @@ function Player:new(world, x, y, z, id)
|
|||
Player.super.new(self, world, "player", x, y, 0, 16, 16, 24, true)
|
||||
self:setGravity(480)
|
||||
|
||||
self:setSprite("player", 8, 12)
|
||||
self:cloneSprite()
|
||||
self:setSprite("player", true, 8, 12)
|
||||
end
|
||||
|
||||
function Player:updateStart(dt)
|
||||
|
@ -37,19 +36,19 @@ end
|
|||
|
||||
function Player:setAnimation()
|
||||
local gsp = utils.math.pointDistance(0, 0, self.xsp, self.ysp)
|
||||
self:setCustomSpeed(math.abs(gsp) / 12)
|
||||
self.sprite:setCustomSpeed(math.abs(gsp) / 12)
|
||||
self:setDirection(self.xsp)
|
||||
if (self.isPunching) then
|
||||
self:changeAnimation("punch", false)
|
||||
self.sprite:changeAnimation("punch", false)
|
||||
else
|
||||
if (self.onGround) then
|
||||
if (math.abs(self.xsp) > 0) or (math.abs(self.ysp) > 0) then
|
||||
self:changeAnimation("walk", false)
|
||||
self.sprite:changeAnimation("walk", false)
|
||||
else
|
||||
self:changeAnimation("idle", true)
|
||||
self.sprite:changeAnimation("idle", true)
|
||||
end
|
||||
else
|
||||
self:changeAnimation("jump", true)
|
||||
self.sprite:changeAnimation("jump", true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -59,7 +58,7 @@ function Player:setDirection(direction)
|
|||
if direction ~= 0 then
|
||||
direction = utils.math.sign(direction)
|
||||
self.direction = direction
|
||||
self:setSpriteScallingX(direction)
|
||||
self.sprite:setScalling(direction, nil)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -3,8 +3,7 @@ local Player = Base:extend()
|
|||
|
||||
function Player:new(world, x, y, id)
|
||||
Player.super.new(self, world, "player", x, y, 16, 24, true)
|
||||
self:setSprite("player", 8, 12)
|
||||
self:cloneSprite()
|
||||
self:setSprite("player", true, 8, 12)
|
||||
self:setGravity(480)
|
||||
|
||||
self.isPunching = false
|
||||
|
@ -67,18 +66,18 @@ function Player:updateEnd(dt)
|
|||
end
|
||||
|
||||
function Player:setAnimation()
|
||||
self:setCustomSpeed(math.abs(self.xsp) / 12)
|
||||
self.sprite:setCustomSpeed(math.abs(self.xsp) / 12)
|
||||
if (self.isPunching) then
|
||||
self:changeAnimation("punch", false)
|
||||
self.sprite:changeAnimation("punch", false)
|
||||
else
|
||||
if (self.onGround) then
|
||||
if math.abs(self.xsp) > 0 then
|
||||
self:changeAnimation("walk", false)
|
||||
self.sprite:changeAnimation("walk", false)
|
||||
else
|
||||
self:changeAnimation("idle", true)
|
||||
self.sprite:changeAnimation("idle", true)
|
||||
end
|
||||
else
|
||||
self:changeAnimation("jump", true)
|
||||
self.sprite:changeAnimation("jump", true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -88,7 +87,7 @@ function Player:setDirection(direction)
|
|||
if direction ~= 0 then
|
||||
direction = utils.math.sign(direction)
|
||||
self.direction = direction
|
||||
self:setSpriteScallingX(direction)
|
||||
self.sprite:setScalling(direction, nil)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue