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 |
Comments
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!
https://www.gamasutra.com/blogs/ItayKeren/20150511/243083/Scroll_Back_The_Theory_and_P ractice_of_Cameras_in_SideScrollers.php
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
Likes: MoKaLux
corona cameras:
https://github.com/Zetosoft/dynacam
https://github.com/roaminggamer/RGCamera
https://gist.github.com/GymbylCoding/8675733
and one that also looks awesome but for love2d:
https://github.com/adnzzzzZ/STALKER-X
@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):
-rrraptorCamera ?
-cameraCL (for Clamp and Lerp)?
Likes: keszegh
https://mokalux.itch.io/gideros-platformer-lf
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!?