Later update, or post update function (SOLVED)

I use GitHub - britzl/defold-orthographic: Orthographic camera functionality for the Defold game engine for my camera. And now need to setup parallax layers.

So as I see camera script handle position in update method. And i can not use another update method on another component which will place parallax layer to specific position.
So in this case i need something like post-update or later-update function.


Here I see the order of execution. that message dispatching happens after update cycle.
So do you think it’s ok to use following workaround. Every frame send message to self. and in on_message call post update function - so it will take the actual position from camera

here is an example

local ping=hash("ping")

function init(self)
    self.my_url = msg.url()
end

function update(self, dt)
    msg.post(self.my_url, ping, {dt=dt})
end

function post_update(self, dt)
  -- set paralax layers here
end


function on_message(self, message_id, message, sender)
    if message_id == ping then
      self:post_update(message.dt)
    end
end

1 Like

Yes, that should be ok.

2 Likes