high jump, background animation like camera

Hi there,

i’m tring the making first my game. but i need help on some issues. I would like the create high jump effect (camera follows the charecter like angry birds ) 

I found some examples. I added scene objects into to a group and fixed charecter’s max height. if charecter y equals max height i’m setting mygroup’s y to -1. but my physic of objects has broken here. my char not standing on static bar’s anymore. But it’s standing on the ground (bottom) still.

when i remove the framehandler, 2 bars and ground’s physic is working correctly. Group is the right way for this background effect or is another there a sample or technique for this effect?

thank you very much,

[lua]

local background = display.newImageRect( “world.jpg”, display.contentWidth ,display.contentHeight*2 )

local physics = require “physics”

–physics.setDrawMode( “hybrid” )

physics.start()

physics.setGravity( -1, 20 )

background.x =display.contentWidth/2

background.y =display.contentHeight/2

local ground = display.newImage( “ground.jpg”) 

ground:setReferencePoint( display.BottomLeftReferencePoint ) 

ground.x, ground.y = 0,display.contentHeight

ground.type=“ground”

local groundShape ={ -1280,-20, 1280, -20, 1280,20, -1280, 20 }

physics.addBody( ground, “static”, { friction =1.0, density=5.0, bounce=0.2} ) 

local bar = display.newImageRect( “bar.png”, 350,43)

bar.y =400 

bar.x = 200

bar.type = “bar”

local bar2 = display.newImageRect( “bar.png”, 350,43)

bar2.y =400 

bar2.x = 600

bar2.type = “bar”

local GrBgAndBars = display.newGroup()

GrBgAndBars:setReferencePoint(display.BottomLeftReferencePoint)

GrBgAndBars.y=-20

local sheep = display.newImageRect( “sheep.png”, 100,74)

sheep.y =100

sheep.type=“mainsheep”

sheep.x = 200

physics.addBody( sheep , { friction =1.0, density=0.5, bounce=0.1, radius=35 } ) 

GrBgAndBars:insert( background ) 

GrBgAndBars:insert( ground )

GrBgAndBars:insert( bar )

GrBgAndBars:insert( bar2 ) 

sheep.isFixedRotation=true

function frameHandler( e )

local maxY = 500

if sheep.y < maxY then

if GrBgAndBars.y < 720 then
GrBgAndBars.y = GrBgAndBars.y + maxY - sheep.y
end

sheep.y = maxY

else
if GrBgAndBars.y > 0 then
GrBgAndBars.y = GrBgAndBars.y - 5
end
end
end

Runtime:addEventListener( “enterFrame”, frameHandler )

–and this part works on touch event.

local function onScreenTouch(event)

sheep:applyForce(350*sheep.xScale ,-2100, sheep.x, sheep.y)

end

Runtime:addEventListener(“touch”, onScreenTouch)

[/lua]