It looks like you're new here. If you want to get involved, click one of these buttons!
function Level1:onEnterFrame(e) self.world:step(1/60, 1, 1) -- camera follow player local playerposx, playerposy = self.player.body:getPosition() local offsetX = -(playerposx - 128) * self.gamelayer:getScaleX() self.gamelayer:setX(offsetX) -- local offsetY = -(playerposy - myappheight / 2 + 0) * self.gamelayer:getScaleY() -- too much camera movements local offsetY = -myappheight -- fixed camera ok but doesn't follow player when too low or too high self.gamelayer:setY(offsetY) end
I want my camera to follow the player but not when he jumps only when he goes up/down a hill/platform... I have read that you should reposition the camera only when the player lands on a platform by putting triggers on those platforms.
I don't really know how to handle this
I have seen this page for camera in 2d games and it's just too much for me!
A compilation of camera scripts would be awesome so we could choose the one appropriate to our game genre. They would also go straight to the wiki
and one that also looks awesome but for love2d:
@hgy29 do you think you can translate one of corona camera code above with your tool?
Thank you very much for your help
How do you want to call your camera class? that's for the wiki
A few suggestions (camera is to vague):
-cameraCL (for Clamp and Lerp)?
Using liquidfun, tiled.
PS: liquidfun doesn't work the same on html5 (some collisions bug). The same code works fine on pc and android
I suspect this line of code:
local myleftshape = b2.PolygonShape.new()
myleftshape:setAsBox(0.1, h / 3, 0 + w / 4 - 1, h / 2, 0) -- half w, half h, centerx, centery, angle
Html5 may convert it to either 0 or 1 instead of keeping it 0.1!?