"Zoom-In" effect

Well, my problem is pretty simple, but I haven’t found anything after a long time searching.

I’m working on a turn-based RPG style game, and what I need is that when your character gets close to hit an enemy the “camera” has to zoom-in on them. After the attack ends, things go back to normal.

I don’t really know how to achieve this. Any tips or examples are appreciated. [import]uid: 136402 topic_id: 34157 reply_id: 334157[/import]

Make sure all of the items you want to ‘zoom’ are in the same display group and then just adjust the display group scale. Below is an example assuming ‘levelGroup’ is the display group with all of your objects.

[lua] levelGroup.scale(2, 2) – zooms in 200 percent[/lua]

The above example zooms in 200 percent instantly. In your scenario it seems like you would want to use a transition to zoom in to the 200 percent over time, making actually seem like you are zooming in instead of just enlarging the objects.

[lua] transition.to( levelGroup, { time=300, transition=easing.inOutQuad, xScale=2, yScale=2} )[/lua]

If your game objects are in separate groups you could also run the code on each group, i guess.
[import]uid: 147305 topic_id: 34157 reply_id: 135829[/import]

Thanks! that transition seems to be what I was looking for.

However, when you do that the zoom is focused on the center. Is it possible to focus on the left side, or the right side, or wherever the action is? [import]uid: 136402 topic_id: 34157 reply_id: 135844[/import]

Well, it doesn’t really ‘focus’ anywhere it’s just enlarging the scale which means, by default, it looks like it’s just zooming on the center of the screen. Adding some x/y coordinates to zoom into on the transition thing should help. It might take some playing to get the results you want but the basic logic would be:

[lua] transition.to( levelGroup, { time=300, transition=easing.inOutQuad, xScale=2, yScale=2, x=myCharacter.x, y=myChracter.y} )[/lua]

where the x/y is the coords you want to zoom in on and in this case I just used a display object called myCharacter.

I don’t really use this but I think you may run into an issue with relative x/y values to your group x/y position so it may take some playing to figure out exactly how to zoom in exactly where you want… or it may just work. Either way it should at least get you to the point where you can tinker with the logic of getting the correct target x/y values. [import]uid: 147305 topic_id: 34157 reply_id: 135848[/import]

Make sure all of the items you want to ‘zoom’ are in the same display group and then just adjust the display group scale. Below is an example assuming ‘levelGroup’ is the display group with all of your objects.

[lua] levelGroup.scale(2, 2) – zooms in 200 percent[/lua]

The above example zooms in 200 percent instantly. In your scenario it seems like you would want to use a transition to zoom in to the 200 percent over time, making actually seem like you are zooming in instead of just enlarging the objects.

[lua] transition.to( levelGroup, { time=300, transition=easing.inOutQuad, xScale=2, yScale=2} )[/lua]

If your game objects are in separate groups you could also run the code on each group, i guess.
[import]uid: 147305 topic_id: 34157 reply_id: 135829[/import]

Thanks! that transition seems to be what I was looking for.

However, when you do that the zoom is focused on the center. Is it possible to focus on the left side, or the right side, or wherever the action is? [import]uid: 136402 topic_id: 34157 reply_id: 135844[/import]

Well, it doesn’t really ‘focus’ anywhere it’s just enlarging the scale which means, by default, it looks like it’s just zooming on the center of the screen. Adding some x/y coordinates to zoom into on the transition thing should help. It might take some playing to get the results you want but the basic logic would be:

[lua] transition.to( levelGroup, { time=300, transition=easing.inOutQuad, xScale=2, yScale=2, x=myCharacter.x, y=myChracter.y} )[/lua]

where the x/y is the coords you want to zoom in on and in this case I just used a display object called myCharacter.

I don’t really use this but I think you may run into an issue with relative x/y values to your group x/y position so it may take some playing to figure out exactly how to zoom in exactly where you want… or it may just work. Either way it should at least get you to the point where you can tinker with the logic of getting the correct target x/y values. [import]uid: 147305 topic_id: 34157 reply_id: 135848[/import]