It looks like you're new here. If you want to get involved, click one of these buttons!
local screenW = application:getContentWidth() local screenH = application:getContentHeight() local bg = Bitmap.new(Texture.new("background.png")) bg:setPosition(0,0) bg:setScale(2) stage:addChild(bg) -- move the ship around with arrow keys local ship = Ship.new() ship:setPosition(10,10) bg:addChild(ship) local view = Viewport.new() view:setClip(0,0, screenW, screenH) view:setContent(bg) stage:addChild(view) -- how to follow the ship with the viewport!? possible? function update(ev) local dt = ev.deltaTime ship:update(dt) view:setTransform(ship:getMatrix()) -- this transforms the viewport position and rotation itself... <img class="emoji" src="https://forum.gideros.rocks/resources/emoji/anguished.png" title="D:" alt="D:" height="20" /> -- view:lookAt(aaaaaaaarrrrrrrgh!!!!) ??? end stage:addEventListener(Event.ENTER_FRAME, update) |
Comments
lookAt() is dedicated to 3D, it may not be easy to use for 2D. You are right in using setTransform(), but I don't get why you pass it ship:getMatrix()... maybe you meant passing the inverse matrix instead ?
Likes: stetso, koeosstudio, JuanZambrano, Yan
The attached example will create a bunch box objects and move them about a world at random speeds. Clicking the screen makes the camera track the next box in the list :bz
Likes: stetso
Likes: antix