parallax zooming like Angry Birds

6 replies [Last post]
marqshaw
User offline. Last seen 8 years 44 weeks ago. Offline
Joined: 12 Mar 2011

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.

Replies

jeffgreenback
User offline. Last seen 4 years 32 weeks ago. Offline
Joined: 13 Dec 2010

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.

marqshaw
User offline. Last seen 8 years 44 weeks ago. Offline
Joined: 12 Mar 2011

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.

marqshaw
User offline. Last seen 8 years 44 weeks ago. Offline
Joined: 12 Mar 2011

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

thanks,

jmp909
User offline. Last seen 4 years 1 week ago. Offline
Joined: 14 May 2010

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

jmp909
User offline. Last seen 4 years 1 week ago. Offline
Joined: 14 May 2010

ps change this line:
game.y = 650
to
game.y = display.contentHeight

and it should fit right.

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

to make the main character stay more central

Matthew Pringle
User offline. Last seen 47 weeks 4 days ago. Offline
Joined: 23 Feb 2010

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.

Viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.