How do I detect parallax positions (if obj is out of view)

0 favourites
  • 9 posts
From the Asset Store
Easily generate many levels from a set of pre-built scenes (Construct 3 template for top-down view games)
  • Hi there,

    I'm building a game with 3 layers of parallaxed background objects. They generate on the fly, out of the viewscreen, but I can't seem to determine how to check if they are out of screen from the spaceship which is always in the middle of the screen.

    The parallax values get twisted each time a certain object is created in one of the paralax layers.

    if Parallax is say 50,50 does that mean X and Y is X/2 and Y/2 ? If I compensated for the rest like that, would that theoretically work?

    This is a space iphone game, and background moves and everything moves, while spaceship doesn't.

  • If everything moves but the spaceship, maybe you don't even need parallax in different layers.

    Can't you simply move each background at different speeds ?

  • Zed2100 I have a intuitive feeling that parallax is optimized better than moving something with code. I'm trying to keep the game really light because of mobile platform final destination.

  • You can implement both in separate projects and profile each of them using the development tools in chrome or firefox, then choose what to use in your specific case based on performance.

    Personally I don't think there is any difference in performance between setting a x coordinate and trying to compute the exact position of an object in a layer with parallax. What I would be worried about is the delay in development such a feature may cause. You have to know the formula of parallax that C2 is using and adapt it to your game, then test to see if everything works. Sometimes you just have to do it in the most stupid way possible as long as it looks good, then move on to more important features.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Zed2100 I can't argue with that

    I'll try to find a solution and add it here because this forum is like a searchable massive manual

  • There are expressions for dealing with this: LayerToCanvasX, LayerToCanvasY...

  • blackhornet wow cool. I thought they could be what I needed but I abandoned the search. Thank you!!

    Having some trouble applying this. How do I for an example move a sprite over my spaceship (my spaceship is not on a parallax, but the cube is on a 50,50 parallax) ?

  • You convert from Layer Y to Canvas, then from Canvas to Layer X.

  • blackhornet Thanks man <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile"> a .capx and everything. That should cure my stupid brain.

    Here's another example where they transfer back and forth from parallax ... er-example

    for anyone needing this. <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

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