Create image scrolling area

0 favourites
  • 8 posts
From the Asset Store
All popular touch mechanics - scrolling, zooming, swiping
  • I need to create an area (a simple transparent square of 150x150 pixels) inside my game screen where I can insert images that the player can scroll. Anything that exceeds the edges of the area must be cut off.

    To make you understand better what I'm talking about, I leave you a simple example of a CodePen (it's not an example of a real game, but the scrolling and cutting effect is what I would like to obtain): https://codepen.io/shadeed/pen/jOMrxYO

    Initially I thought of inserting a check inside the images, where I checked if the image was > or < of the upper and lower y points of the area. If the image was outside the area I set an opacity equal to 0 (so no longer visible and hidden).

    But this method created two problems:

    - The image didn't get a cut effect (i.e. it wasn't shown halfway when it was in a position halfway between an edge of the area)

    - I use the same object also for instances that are outside the area. If I make a control on the same object I risk that any instances present in the scene would be hidden if not inside the area

    Can anyone give me some advice on how to properly set up a scrolling area like this?

  • Yeah, this is one of hurdles when doing gui in C3 as there's no simple way to do it.

    The standard method is to use blend modes with destination out giving a mask effect.

    You move the objects over the area and the mask cuts off the parts outside of it.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Yeah, this is one of hurdles when doing gui in C3 as there's no simple way to do it.

    The standard method is to use blend modes with destination out giving a mask effect.

    You move the objects over the area and the mask cuts off the parts outside of it.

    Thank you for your response.

    I am just learning C3, so I have never used the effects and blend mode.

    Do you have any examples or guidance for recreating the effect you suggested?

  • This is about as simple as it can get. dropbox.com/s/mey5ydzh0ksiw03/blendmask.c3p

    Note that the layer its on is set to "force own texture"

  • Thank you so much for the example!

    Is there a specific reason why you recommended that I enable the "force own texture" option for this effect?

  • you can fake that effect, by having the items in grid pattern like in the website example, covered by a boundary "sprite object" and make the items scrollable by pinning them to a tile background object that u drag left and right. there was a tutorial on this in the old "tutorial area" of website. not sure if still around. was called something drag scrolling object "mobile"

  • Force own texture on a layer will prevent blend modes from affecting anything on other layers below it.

  • Thank you all for your responses and advice.

    I was able to solve it by following newt's advice.^^

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)