Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to limit a line scroll to a certain part of the world?
#1
Hello, I'm having trouble figuring out how to go about limiting a raster effect line scroll to a certain part of the world.  I understand the way raster effects work is screen based. But how would I go about having the effect only appear on screen when the world is at a certain position? Example: https://i.gyazo.com/8c9cb92f7c9108795c7f...5cac6a.mp4

As you can see in the example the effect on the grass looks fine when the camera is low to the ground, however once you move up the raster effect is ruined as it is no longer covering the part of the background that it was once scrolling. Currently the code for this effect is pretty simple 
Code:
void GrassLineScroll(int line)
   {
       float pos = -1;
       
       if (line == 0 ) {
           TLN_SetLayerParallaxFactor(2, 0.50, 1.0);
       }
       if (line == 167 ) {
           TLN_SetLayerParallaxFactor(2, 0.80, 1.0);
       }
       if (line == 180 ) {
           TLN_SetLayerParallaxFactor(2, 0.90, 1.0);
       }
       if (line == 192 ) {
           TLN_SetLayerParallaxFactor(2, 0.95, 1.0);
       }
   }

Any help with this would be much appreciated. Thank you once again.

Cheers,

RBK
Reply
#2
Hi!
Cool effectyou did with the grass.
Solving the issue is easy. You just have to compensate for the y offset. For example, if you scroll the world 10 pixels positive -so the layer moves upwards from bottom to top-, you have to compensate by substracting the same amount of pixels to the raster effect lines:

Code:
void GrassLineScroll(int line)
{
       if (line == 0 - y_world) {
           TLN_SetLayerParallaxFactor(2, 0.50, 1.0);
       }
       if (line == 167 - y_world) {
           TLN_SetLayerParallaxFactor(2, 0.80, 1.0);
       }
       if (line == 180 - y_world) {
           TLN_SetLayerParallaxFactor(2, 0.90, 1.0);
       }
       if (line == 192 - y_world) {
           TLN_SetLayerParallaxFactor(2, 0.95, 1.0);
       }
   }

This works assuming that the raster lines in your code work when y_world = 0, if not, you have to include the value y_world has when it is "grounded".

Happy Christmas!
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)