0 Favourites

How do I transition an object from 100 parallax layer to 0

  • Hi!

    I'm attempting to recreate a game element similar to that in ClaDun x2, in which, when you pick up a coin, it spawns a sparkly thing on the playfield that floats slowly towards the coin bag in the UI.

    My problem is that my characters and everything are on a layer called Play, that has a parallax rate of 100, 100. And my UI is on a layer with a parallax rate of 0, 0.

    I'm not sure how to handle this sequence, because if I spawn the sparkle on Play, it'll spawn in the right place, but it won't be able to travel towards the UI correctly. But if I spawn it on UI, it won't spawn in the right place because of the parallax.

    Edit: I just tried placing an object with the Anchor behavior on the Play layer, directly over the UI. It /almost/ works but the Anchored object shifts a little. Okay a lot...

    You can see the effect I'm going for here:

    (watch carefully when the character picks up a coin, it's sort of subtle...)

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • There are system expressions "CanvasToLayerX", "CanvasToLayerY" and "LayerToCanvasX", "LayerToCanvasY" they will help you.

  • I'll look into that, thank you!

  • Update:

    I have tried this, and it did not work.

    Currently I spawn the object on the layer Play and then attempt to move it to the UI layer. I suspect it will also not work if I just try to spawn it on the UI layer...

    I have tried all sorts of combinations of the CanvasToLayer and LayerToCanvas expressions, not just the one in the screenshot. I wish there was a better tutorial for how to use them, I can't find one that doesn't just repeat what is in the manual (which was really unhelpful might I add...).

    I'll admit that I have ZERO idea what I am doing with those expressions. I've never used them before and I don't understand how they work at all.

  • I know bumping isn't really a polite thing here, but it's been like a day and it's not on the first page anymore and I still need help... ^^;;

  • You need to use the LayerToCanvas expressions to convert the "Play" layer coordinates to canvas coordinates and then use CanvasToLayer to convert those to "UI" coords.

  • hey, that worked perfectly!

    Thanks for explaining how those expressions worked! =D

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