neils Posted January 4, 2021 Share Posted January 4, 2021 Folks I have been playing a little with Melon JS and I really like it. I started with the platformer tutorial which works fine. Now I would like to add a parallax effect to the tile layers as well but I'm stuck. Here's what I tried so far: 1. Add the property "ratio" to the layer - OK it didn't work, it works for image layers only. 2. I have tried to update the layer's position like this: var layer = me.game.world.getChildByName("Background1")[0]; layer.pos.x = layer.pos.x + 1; // move the layer by one pixel But it didn't work, the layer didn't move. Funny thing is, if I add a value, say 600, the layer disappears (I guess it's outside the viewport then). If I reset to 0 it appears back again. I can also flip it using layer.flipY(true); So something is working, but I cannot get it moving for some reason. Any suggestions are well apreciated. Quote Link to comment Share on other sites More sharing options...
obiot Posted January 11, 2021 Share Posted January 11, 2021 Hi, thanks for the feedback ! "Parallax" layer has been a long due/requested feature, but nobody never got to actually implement it : https://github.com/melonjs/melonJS/issues/734 this said, changing the layer position should work (I don't see right now why it should not), what version of melonJS are u using ? Quote Link to comment Share on other sites More sharing options...
neils Posted January 11, 2021 Author Share Posted January 11, 2021 Hi Thanks for the link, I had actually found it before and I tried the code in the answer, but no luck. I'm using v8.0.1. Don't worry, it must be a beginner's mistake that I'm making. I'm still in the beginning and I'm very far from understanding how the whole thing works. I'm sure I'll find it out when I learn more. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.