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