How to make a platformer with a camera in solar 2d?

When moving the position of the group, the hitboxes of physical bodies do not move and objects collide incorrectly.

device = require('Plugins.device')

physics = require('physics')



local group = display.newGroup()

local player = display.newRect(cx, cy, 50, 50)

physics.addBody(player, "dynamic")

player.gravityScale = 10

--player.isSensor = true

local first

local pos = 0

for i = 1, 10 do

    local column = display.newRect(pos, 0, 52, dacth*2) group:insert(column)

    column.y = cy + player.height/2 + column.height/2

    physics.addBody(column, "static")

    pos = pos + math.random(100, 500)

    pos = pos + column.width

    if i == 1 then first = column end


local power = display.newRoundedRect(cx, originY + 100, dw - 200, 10, 25)

power.power, power.beganpower = dw - 200, dw - 200 power.mode = "left" power.speed = 20



    group.x = display.contentCenterX - player.x

    group.y = display.contentCenterY - player.y

    if power.mode == "left" then

        power.power = power.power - power.speed

        power.x = power.x - power.speed/2

        power.width = power.power

    elseif power.mode == "right" then

        power.power = power.power + power.speed

        power.x = power.x + power.speed/2

        power.width = power.power


    if power.power >= power.beganpower then power.mode = "left" end

    if power.power <= 0 then power.mode = "right" end

end, 0)

local jump = function(event)

    if event.phase == "ended" then

        player:applyForce(power.power/power.beganpower*30, -power.power/power.beganpower*70, player.x, player.y)



Runtime:addEventListener("touch", jump)

Sounds like it could be related to:


When working with Corona display groups and Box2D, it’s important to remember that Box2D expects all physics objects to share a global coordinate system. Both grouped and ungrouped display objects will work well since they will share the internal coordinates of that group. However, unexpected results will occur if physical objects are added to different display groups and those groups are moved, scaled, or rotated independently of each other. As a general rule, do not alter the position, scale, or rotation of display groups that contain physics objects. See Physics Notes/Limitations

Essentially, you would want the player object to be in the same group as your platforms.


Hi @C2G,

Maybe check Sticker Knight Platformer

Have a nice day:⁠-⁠),

1 Like

Thank you!!!

Thank you)