parallax zooming like Angry Birds

Hi,

I need some serious help with zooming in and out of my game world. I haven’t been able to find out how to properly do this and any help would be appreciated.

I am able to scale my group with group:scale(sx, sy), however when I do this, this also seems to shift the y values of the image up and I end up with more ground then sky in the level and my character starts shifting to the top of the screen. I need to do some focal point type scaling as well, any tips would be appreciated. [import]uid: 44767 topic_id: 14728 reply_id: 314728[/import]

Have you tried setting the “reference point” of the group to the center. They might be set to top left by default, which would mess up the scaling. [import]uid: 12540 topic_id: 14728 reply_id: 54483[/import]

The reference point is set to the center as the scaling doesn’t impact the physics. I think I need to move the y of the group down as I’m scaling. [import]uid: 44767 topic_id: 14728 reply_id: 54488[/import]

has anybody been able to duplicate this effect, that is willing to share?

thanks, [import]uid: 44767 topic_id: 14728 reply_id: 54643[/import]

SebLeeDeslie has posted a good example of parallax in his presentation “Angry Birds in 30 minutes”

http://sebleedelisle.com/2011/09/angry-birds-in-30-minutes-at-update-2011/

the background elements don’t zoom/scale but the foreground items do. might get you started
[import]uid: 6645 topic_id: 14728 reply_id: 56679[/import]

ps change this line:
[lua]game.y = 650[/lua]
to
[lua]game.y = display.contentHeight[/lua]

and it should fit right.

also i changed this line in the main game loop
[lua]local targetx = (- exorcist.x + 700) * game.xScale[/lua]
to
[lua]local targetx = (- exorcist.x + display.contentWidth/2) * game.xScale[/lua]

to make the main character stay more central [import]uid: 6645 topic_id: 14728 reply_id: 56680[/import]

Groups inside of groups, think inception…

Have 1 main group for all the game objects.

Insert that into a group so you can move that group left and right, so it moves the world

Insert that group into another group with its reference in the centre, this is the group to zoom / scale.

I tend to think of the 2 outer groups, move and scale as a camera if that helps. [import]uid: 5354 topic_id: 14728 reply_id: 57620[/import]