Game Development Community

Multiple scenes to make up a parallax view

by Eero Karvonen · in Torque 2D Beginner · 04/21/2014 (2:12 pm) · 9 replies

Hi,

I've read in the old docs that a parallax scrolling effect can be achieved through viewing multiple scenes simultaneously. Can someone point out where I should go to learn how to view multiple scenes?

Or, would moving composite tilemaps around be any less efficient?

Regards,
EK

#1
04/21/2014 (2:51 pm)
I've never tested using multiple SceneWindows to achieve a parallax effect, although I have read probably the same docs you did. So I can't give any tips on what method is better.

A good place to learn how to set up a game to use multiple SceneWindows/Scenes would be the MultiWindowToy. The toy is setup to use a 2nd window more like a minimap, but the concept and scripting is basically the same.
#2
04/21/2014 (3:12 pm)
Thank you! I will look into it.
#3
04/22/2014 (2:03 am)
Having multiple SceneWindows stacked on top of another works fine, just don't set a background on your top-most Scenewindow and the other scene will show through.

There are many ways to achieve the effect, though.

1 - use scrollers

In one scene, add many Scroller objects, set to scroll at different rates.
Linking their scroll rate with a behavior tied to the main scene's camera should let you achieve what you want.
This would be the simplest way imho to go about it.

2 - Multiple SceneWindows with Multiple Scenes

In this example, you would create a scene for your main action and one scene containing all the layers of the parallax effect. Each scene would be displayed in a separate scenewindow, positioned at the same coordinates.

You would need to create a schedule which would update the position of all cameras/Scenewindows, as the camera controls do not have a scroll feature). Since Scenes do not repeat either, you would need to find a way to detect when the camera reaches the end of its scene and reset its position to the beginning.

I think that you can set limits to the camera movement area and I think that there is a callback when the camera reaches these limits.
#4
04/27/2014 (5:19 pm)
Simon's idea of scrollers would do perfect. In fact, there's a toy in the sandbox to give you an idea called "ScrollerToy".
#5
05/18/2014 (4:06 pm)
My solution turned out to be a combination of Simon's suggestions.

First, I have a Master Window which itself is a dummy container for Parallax, Game, and HUD Windows. In Parallax Window I put scrollers and directly update their texture position through multiplying the Game Window's camera coordinates by respective "scrolling factors".

Thanks for the ideas!
#6
05/18/2014 (11:09 pm)
@Eero : Congrats! Any chance you can share a video of the effect?

If you don't have video capture software, https://obsproject.com/ does a decent job.
#7
05/20/2014 (9:02 am)
@Simon: Here you go. I quickly wrapped up some placeholder graphics to make the point.

(The gameplay-layer buildings were laid out in Tiled and imported through my custom importer.)
#8
05/20/2014 (9:19 am)
This works quite decently for a single-image parallax background. I'm, however, thinking of implementing another system with the cameras moving on each of the parallax scenes. It would reduce the overall file size, if I put together the subscenes from smaller elements - it would also mean some more room for interactivity in the parallax layers (like what was seen in the cancelled prototype of Rayman 2).
#9
05/20/2014 (11:00 am)
Looks wicked cool! Thanks for sharing!