How to get layered scrollView instances to respond to swipes, to achieve parallax effect?

I’ve got widget.scrollView working nicely to let users horizontally scroll through scenery for a game. But I’d like to use more than one layer in the scenery, to achieve a parallax effect. The sample parallax code here works fine but it doesn’t build on widget.scrollView, so it’s not as powerful.
 
To do this, I created two instances of widget.scrollView, one for clouds and one for trees, superimposed over each other. And when creating the two instances, I added a 0 in fourth position inside the table assigned to backgroundColor, so that the background’s alpha property gets set to 0, making it transparent. This worked fine: I can see the clouds and the trees.
 
However, only the trees layer scrolls, not the clouds layer. It appears that although the trees layer is receiving and responding to swipe gestures, the clouds layer is not. I suspect this is because the touch events that make up the swipe gesture are being handled by the trees layer, which is returning true, and therefore the events are not being propagated to the clouds layer.
 
So how can I fix that, to ensure that the clouds layer receives those same touch events, so it can respond, too?
 
Thanks.

To clarify one thing: I do also insert cloud images in the clouds layer, and tree images in the trees layer, of course, so that even though their backgrounds are transparent, you can see the layers’ horizontal scrolling motion.

Hi @hexagram,

I believe the scroll view always returns true, so to build in this kind of functionality, you may need to access the Widget source:

http://forums.coronalabs.com/topic/34183-widgets-20-open-source/

Or, you may consider making a transparent “overlay” that handles all touch response (whether there’s visual content at that point or not), and then using that to control all of the parallax layers.

Best regards,

Brent Sorrentino

I’m not sure a scrollView is the right data object for this.  I would just use a display.newGroup and a “camera” type scene tracking and use the camera’s update code to control movement of the background layers in side the group.

To clarify one thing: I do also insert cloud images in the clouds layer, and tree images in the trees layer, of course, so that even though their backgrounds are transparent, you can see the layers’ horizontal scrolling motion.

Hi @hexagram,

I believe the scroll view always returns true, so to build in this kind of functionality, you may need to access the Widget source:

http://forums.coronalabs.com/topic/34183-widgets-20-open-source/

Or, you may consider making a transparent “overlay” that handles all touch response (whether there’s visual content at that point or not), and then using that to control all of the parallax layers.

Best regards,

Brent Sorrentino

I’m not sure a scrollView is the right data object for this.  I would just use a display.newGroup and a “camera” type scene tracking and use the camera’s update code to control movement of the background layers in side the group.