I tried to understand the new Viewport but failed miserably. I want it to follow an entity around (like a camera) but I am not sure how to do that or even if the Viewport is the right thing for it.
Of course, an alternative would be to just not use a Viewport and move the sprite hierarchy around but if possible I would rather use the new Viewport (also because splitscreens are much easier, I hope...) and it kind of... seems cleaner.
Anyway, I could not make much out of the documentation unfortunately. I think :lookAt() is the correct thing to use but I do not understand the parameters.
Any help would be appreciated :)
Here is some code that uses :setTransform() but this moves the viewport itself around, not the view inside the sprite hierarchy (well, at least the effect is kind of psychedelic...) @-)
local screenW = application:getContentWidth()
local screenH = application:getContentHeight()
local bg = Bitmap.new(Texture.new("background.png"))
-- move the ship around with arrow keys
local ship = Ship.new()
local view = Viewport.new()
view:setClip(0,0, screenW, screenH)
-- how to follow the ship with the viewport!? possible?
local dt = ev.deltaTime
view:setTransform(ship:getMatrix()) -- this transforms the viewport position and rotation itself... D:
-- view:lookAt(aaaaaaaarrrrrrrgh!!!!) ???
I also add the whole project.
Thanks for your help!