Group Sprite Ordering / Layering Problems

Welcome to our brand new Clickteam Community Hub! We hope you will enjoy using the new features, which we will be further expanding in the coming months.

A few features including Passport are unavailable initially whilst we monitor stability of the new platform, we hope to bring these online very soon. Small issues will crop up following the import from our old system, including some message formatting, translation accuracy and other things.

Thank you for your patience whilst we've worked on this and we look forward to more exciting community developments soon!

Clickteam.
  • Hello again folks, I need to ask for some more advice regarding a scrolling brawler I'm in the process of developing.

    I'm having issues regarding layering multiple instances of the same group. At the moment I've got separate ones allocated to the Player, Enemies and Background Objects, and it's a simple process of calling a fast loop whenever the Player overlaps either of the other two, where I check the Player's Y Coordinate which I've set to a variable (I've called 'floor_position', more on that in a moment), if the Player's floor_position is lower than the other Object's the Player moves behind them, if it's greater the Player moves in front, it's pretty straightforward.

    The reason I'm using a variable rather than the Y coordinate, is because in games like this you'll often jump or be knocked down, and as you'll be moving up and down the screen a lot this is of course going to change where the floor is at any given time, and so I have the floor_position variable update whenever the player is on the ground, then lock it when they're in the air, this keeps track of where they should be landing.

    Now then, the issue I'm having is with the Enemies, they use the same variable to keep track of where they are on the floor, but this is causing issues when they overlap. If you check the attached image, you can see one of the thugs has his bat up over his head as he goes for a jumping attack on the scorpion guy (the player), his shadow is parallel to the player and shrunk slightly because he's airborne, but as you can see, he's overlapped by the other enemies when he should be in front of them.

    I've tried using the layering object to solve this, using the Y_Descending ordering command, but whilst that works fine when everyone's on the ground (my guess is that it checks each object's Y coordinate?), if doesn't work when they're airborne.

    I've tried several methods of rectifying this, specifying that it only use this layering approach when they're on the ground, moving objects to a higher layering when airborne etc but with no luck, I think I need to find a way to sort by their floor_position variables but don't know how to do it?

    Any help would be much appreciated.


    Please login to see this attachment.

  • Each enemy is storing their initial/ground Y coordinate as a variable? The layer object should let you sort by the stored variable rather than their actual Y coordinate

    Please login to see this picture.

    (apologies if I've misread your post and this is what you're already trying)

  • Thankyou, that seems to have done the trick, but I don't really understand how the Layering Object works?

    To get it to work for the issue I explained, I had to tweak a few things, putting all the layerable parts (Players/Enemies/Objects) into a new group, then had to move the floor_position variable so it was in the same Alterable Value for all of them, in this case (16) Q

    Would I be correct in my assumption, that when you sort by Alterable Values, the first question when the Layering Object asks you to choose one (in the screenshot), is the Alterable Values in the Layering Object itself, where the values of all the parts to be sorted are stored?

    Sorry if my wording is a bit tricky to understand, it's the best way I can phrase my question?


    Please login to see this attachment.

  • Thankyou, that seems to have done the trick, but I don't really understand how the Layering Object works?
    Would I be correct in my assumption, that when you sort by Alterable Values, the first question when the Layering Object asks you to choose one (in the screenshot), is the Alterable Values in the Layering Object itself, where the values of all the parts to be sorted are stored?
    Please login to see this attachment.

    Not quite - the layer objects is basically going through each individual active object, looking at that object's alterable value Q, and deciding whether to put that object in front/behind depending on the value you've set for that object

    So, if I tell the layer object to always sort by the value in an object, then I can change that value which should change the order
    Please login to see this picture.

  • Ah I *kinda* understand, I might have to make a small experiment like how you've shown to get a better idea of how it works. Are there any resources/tutorials online where it goes into more detail of how to use objects like this? There's so many of them, but without some idea of how to actually use them, it just feels like I'm always fumbling in the dark.

    Thanks for your help

  • I'd probably start with the help file (from the menu at the top). If it's an extension it might have its own separate help file in the 'help' folder that fusion is installed to. There's an examples folder there too, but otherwise searching the forums for what you're after will probably get you some examples or info too

  • Ah I *kinda* understand, I might have to make a small experiment like how you've shown to get a better idea of how it works.

    It might still seem vague to you, but you've basically nailed it.

    The layer object's "Sort by..." actions will sort every single thing that's on a particular layer. The "Sort by> Y Descending" option will sort each object by the Y position of its hotspot. As you found, this isn't always desirable, because a jumping enemy has a very high Y position, even though he 'belongs' further forward in the foreground. So, you sensibly created the floor_position alterable value, which keeps track of the 'real' Y position of each object. The task now was to make the Layer Object sort by floor_position, instead of by Y Descending. That's what the "Sort by> ALT Value (Decreasing)" is for.

    The Layer Object is unable to read the names of Alterable Values, so you can't tell it to sort by floor_position. But you know that the floor_position is the enemy's 16th alterable value (ie. it would have been called Alterable Value Q before you named it). So you tell the Layer Object to sort by Alterable value Q, which in your enemy's case corresponds to floor_position. So you've now gotten the Layer Object to sort by floor_position, even though only you know that this alterable value is actually called floor_position (the Layer Object only knows it by its generic name "Alterable Value Q").

    So that correctly sorted the enemies, based on their floor_position values. But the problem got more complicated, because there weren't just enemies on that layer, but other stuff (player, objects) too. You asked the Layer Object to sort everything on the layer, by using the 16th Alterable value (aka Alterable value Q). But there was a problem. Your player also has an alterable value called floor_position, and it's at 178. But it wasn't the 16th alterable value. Maybe it was in the 9th position (aka Alterable value H). And maybe the player's 16th alterable value was actually hit_points. And maybe when you ran the test, your player was close to death, and his hit_points were at 23.

    So along comes the Layer Object, which has been told to sort every object on the layer by their 16th Alterable value. The enemies' 16th alterable values (aka floor_position) are at 120, 100, 300, 150, 200. The player's 16th alterable value (aka hit_points) is 23. So the Layer object sorts everything like this:

    Player (23)
    Enemy (100)
    Enemy (120)
    Enemy (150)
    Enemy (200)
    Enemy (300)

    The enemies look properly sorted, but the player has been pushed all the way to the back. So this is why you've had to move the player's floor_position alterable value from the 9th slot to the 16th slot. The Layer Object will now sort the objects like this:

    Enemy (100)
    Enemy (120)
    Enemy (150)
    Player (178)
    Enemy (200)
    Enemy (300)

    Does that help?

    Please login to see this link.
    My Fusion Tools: Please login to see this link. | Please login to see this link. | Please login to see this link.

    Edited 2 times, last by Volnaiskra (March 1, 2023 at 10:54 PM).

  • Hello again folks, I need to ask for some more advice regarding a scrolling brawler I'm in the process of developing.
    Please login to see this attachment.

    One thing I do is use the Shadows as the Layer controller, sorta. This way it doesn't matter where the Enemies or the player are as they will always show in the proper layer, Thanks to the shadow staying at the proper position.
    Also the Shadow acts as a means to keep the Enemies from traveling through the Player Animation. I use the ENEMY SHADOW LINE and collision with the Player shadow to keep this from happening. Basically the Shadow for the Player is an Oval, so it works nicely for this.

    I.E. PLAYER Shadow LINE is at 700Y or a 720Y Frame
    Player Animation Jumps and is at max 250Y of the 720Y Frame.
    Player Shadow LINE forces the Animation of the Player to the front as the Shadow is still 700Y

    Obviously, linking the enemies the same way works as well.

    How I do it is with 3 objects
    1) Player Shadow Line 1 pixel tall and the width of the Player Shadow ( Invisible )
    2) Player Shadow = Position to Player Line ( Not Overlapping Foreground Objects ).
    3) Player Animation = X Position linked to Player Shadow Line.

    Player Animation is a Platform or Physics object that when it collides with the player line. It stops. This allows for when you Jump and move up or down, for the Player animation to always land on the Shadow line.
    Also, this allows for you to jump over objects or onto objects as well. The Player Shadow Line can be set to go through objects when the Player Animation is Jumping of Falling. Great for when you want to jump on a car.
    Obviously, if the Shadow is overlapping the Car ( Foreground Object Qualifier ). Set Shadow to Top of Foreground Object.

    Also, I never trust fusion so I add an extra event for the Collision of the Player and the Player Shadow line.
    If Player is Overlapping Player Shadow line, Always Force Player X to Top of Shadow line.
    This helps when Fusion Misses the Collision and you barely even notice the little push back up to where the Player should be.
    Typically it is 1 pixel of push. Which, when you are playing is not even noticeable.

    I made you a Quick .MFA to show what I was saying. Sorry, there is next to no animations in it.
    I only put Flashing animations for the Important parts. They allow you to jump on the SUBWAY Benches. X)

    Please login to see this attachment.

    LINK: Please login to see this link.

    Hope this helps

    What you have looks great!

    Edited 7 times, last by VBEinc (March 2, 2023 at 2:45 AM).

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!