How do I visually offset layers of different parallax values

0 favourites
  • 11 posts
From the Asset Store
Adjusting the game screen for different resolutions (Letterbox scale)
  • I thought I'd done this once and knew how to make it work. Unfortunately I think I'm missing something about this problem.

    In the example, I have 2 layers.

    Layer 1 has a parallax of 100

    Layer 0 has a parallax of 50

    Each layer has a simple sprite placed at x:500 and y:500.

    What I'm trying to do is (on layout start) offset the position of sprite_50 so that it appears to line up visually with sprite_100 at the start of the layout.

    Ultimately, I intend to offset numerous objects on various background layers each with different parallax values. I'm not sure, but I think what I'm trying to do involves parallax origin. I've done some searching but wasn't able to find anything that helped.

  • Parallaxing layers can be very frustrating with the current workflow. Since there isn't a "look trough camera" option and no 2.5 z depth, the only thing you can do in order to set up your scene is the following;

    1) In the editor, make sure that the zoom level is at 100% (this option can be found on the view tab).

    2) Then, click on the layers in order to access their properties and on the editor properties field set "Parallax in editor" to Yes.

    After that you should be able to align your sprites in the editor and their relative positions should be the same upon run-time.

  • Maybe there is a fancy equation that will allow you to offset individual objects by an amount based off the parallax values of the layer and the window size. I would be interested in seeing it done.

    It might not help much but I have always set up mine in the editor.

  • eli0s Normally I would do that, the problem is that I'm generating my background objects randomly at the start of the layout.

    GenkiGenga Yeah, the "fancy equation" idea was what I originally thought of.

    My camera starts out in the middle of my layout, but my layout is somewhat large 10k and if the camera is scrolled to 5000, 5000 many of the background layers are totally missing.

    This is just a visual effect I'm going for. I won't need these background objects to do anything except look correct when my camera starts out in the center of the layout.

    I'll keep working on it. I have a strong feeling that I'm just being stupid about this and missing something simple.

  • I think I've come across something of a fix, though sadly I think this will probably only help me and not others with similar problems relating to the fixed parallax origin issue.

    What I've been trying to do is generate an asteroid field in the background of my game.

    So what I do is basically create a few thousand objects at random(layoutsize). Then I scaled each object based on the parallax value of the layer it was on. This caused more "distant" asteroids to scale down and look appropriate far away.

    After searching through other older threads about similar issues I came across

    By using buddy40's method of setting the background layers to a different scale, I've achieved the parallax effect that I wanted, while mostly maintaining the correct visual positions of asteroids.

    This does mean that I might need to use a wider range of coordinates for my background layers to compensate, but otherwise the problem (for me) is largely solved.

  • Hi WarpedOldMan Any chance you have a copy of 's capx? Thanks!

  • I had a look around, but I can't find it anymore, sorry. Are you having a similar issue? I might remember some of what I was doing at the time, and how I (sort of) fixed it.

  • Yes, I am working on an infinite scroller and I have this sky layer with parallax(80,100) that I can't seem to nail down to a separate ground layer(100,100). I was hoping offsetting it would solve it.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Could you post a screenshot or video demonstrating what is happening? Also maybe show us a screenshot of the event sheet or even post the project.

  • WarpedOldMan

    Here's a link to my capx. I guess what I am really looking for, is a better way to loop my tiledsky object (perhaps by offsetting) so it loops properly when I finally move it to the Sky Layer.

  • I'm not very familiar with infinite scrollers. I'm not sure how well it will perform, but you could just implement your own scrolling (with respect to the sky texture). So set the Sky layer's horizontal parallax to 0, and then get the player movement and set the sky texture's position to the amount the player moved * 0.2 etc.

    I don't remember for sure, but I believe that C2 doesn't exactly allow you to distinguish between world coordinates and draw coordinates of an object. The way the parallax is implemented means that you need to do some translation to get an objects "world coordinates" or position with respect to your main layer in this case.

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