fix(actors/gfx): make gfx work
This commit is contained in:
parent
a88fb44f07
commit
9ad1e5c4f1
3 changed files with 17 additions and 11 deletions
|
@ -25,17 +25,15 @@ local GFX = extend("framework.scenes.world.actors")
|
||||||
|
|
||||||
local physics = require "framework.scenes.world.actors.physics.utils"
|
local physics = require "framework.scenes.world.actors.physics.utils"
|
||||||
|
|
||||||
function GFX:new(world, position, spritename, is3D)
|
function GFX:new(world, position, spritename, is3D, useMiddle)
|
||||||
local width, height = world.scene.animators:get(spritename):getDimensions()
|
local width, height = world.animators:get(spritename):getDimensions()
|
||||||
|
|
||||||
|
|
||||||
local dimensions
|
local dimensions
|
||||||
if (is3D) then
|
if (is3D) then
|
||||||
dimensions = {w = width, h = height, d = 1}
|
|
||||||
else
|
|
||||||
dimensions = {w = width, h = width, d = height}
|
dimensions = {w = width, h = width, d = height}
|
||||||
|
else
|
||||||
|
dimensions = {w = width, h = height, d = 1}
|
||||||
end
|
end
|
||||||
local dimVector = physics.dimensionsToVector(dimensions)
|
|
||||||
|
|
||||||
-- !HACK!
|
-- !HACK!
|
||||||
-- Cheat by creating at runtime the definition
|
-- Cheat by creating at runtime the definition
|
||||||
|
@ -51,9 +49,12 @@ function GFX:new(world, position, spritename, is3D)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GFX.super.new(self, world, position + (dimVector / 2))
|
if (useMiddle) then
|
||||||
self:setSprite(spritename, true)
|
local dimVector = physics.dimensionsToVector(dimensions)
|
||||||
self.sprite:activateCallbacks()
|
position = position + (dimVector / 2)
|
||||||
|
end
|
||||||
|
|
||||||
|
GFX.super.new(self, world, position)
|
||||||
end
|
end
|
||||||
|
|
||||||
function GFX:animationEnded(animation)
|
function GFX:animationEnded(animation)
|
||||||
|
|
|
@ -56,6 +56,7 @@ end
|
||||||
function Actor:updateActor(dt)
|
function Actor:updateActor(dt)
|
||||||
self.timers:update(dt)
|
self.timers:update(dt)
|
||||||
self:update(dt)
|
self:update(dt)
|
||||||
|
self:_updateVisual(dt)
|
||||||
self:applyMovement(dt)
|
self:applyMovement(dt)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,8 @@ local Camera = require("framework.scenes.world.camera.minimal")
|
||||||
|
|
||||||
local Vector3D = require "framework.libs.brinevector3D"
|
local Vector3D = require "framework.libs.brinevector3D"
|
||||||
|
|
||||||
|
local GFX = require "framework.scenes.world.actors.gfx"
|
||||||
|
|
||||||
local function _tryFunction(toUpdate, dt, func)
|
local function _tryFunction(toUpdate, dt, func)
|
||||||
if (toUpdate ~= nil) then
|
if (toUpdate ~= nil) then
|
||||||
func(dt)
|
func(dt)
|
||||||
|
@ -148,8 +150,6 @@ function World:_initActorList(actorPath)
|
||||||
self.obj = {}
|
self.obj = {}
|
||||||
|
|
||||||
self:_indexActors()
|
self:_indexActors()
|
||||||
|
|
||||||
self:_prepareActorObject("gfx")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function World:_prepareActorObject(name)
|
function World:_prepareActorObject(name)
|
||||||
|
@ -214,6 +214,10 @@ function World:newActor(name, x, y, z, properties, mapname)
|
||||||
return self:addActor(name, { x = x, y = y, z = z })
|
return self:addActor(name, { x = x, y = y, z = z })
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function World:showGFX(effect, position, useMiddle)
|
||||||
|
table.insert(self.actors, GFX(self, position, effect, false, (useMiddle == true)))
|
||||||
|
end
|
||||||
|
|
||||||
function World:addActor(name, position)
|
function World:addActor(name, position)
|
||||||
local Actor = self:_getActorObject(name)
|
local Actor = self:_getActorObject(name)
|
||||||
if (name == "player") then
|
if (name == "player") then
|
||||||
|
|
Loading…
Add table
Reference in a new issue