https://linen.dev logo
Join Discord
Powered by
# flixel
  • e

    echoing-rainbow-13896

    02/19/2023, 1:00 PM
    what if I wanna change the ordering of two seperate sprite groups towards one another?
  • c

    colossal-match-5265

    02/19/2023, 1:41 PM
    It is up to you to write the logic for how to change the order via a sort function as i mentioned above. Start small with your thinking of a solution. ie, if you had only 2 sprites in a group [a, b], and you wanted to flip the order to [b, a].
  • c

    colossal-match-5265

    02/19/2023, 1:43 PM
    How might that work? Then account for other sprites in the group too by leaving their relative positions untouched.
  • c

    colossal-match-5265

    02/19/2023, 1:43 PM
    Try first, post your issues/results 😇
  • e

    echoing-rainbow-13896

    02/19/2023, 1:53 PM
    im working with someone elses source code
  • c

    colossal-match-5265

    02/19/2023, 1:54 PM
    Sounds good! The solution is the same. Go ahead and try it.
  • e

    echoing-rainbow-13896

    02/19/2023, 2:05 PM
    its not that I want to change the ordering of sprites in a group
  • e

    echoing-rainbow-13896

    02/19/2023, 2:05 PM
    I want to change the ordering of two groups
  • c

    colossal-match-5265

    02/19/2023, 2:06 PM
    You're missing the point. Change my example to be 2 sprite groups, a and b. The answer is the same. I am not going to provide you with a code solution. You need to try to help yourself first. Take a whack at writing some code and understanding. Post your results, get help debugging.
  • c

    colossal-match-5265

    02/19/2023, 2:08 PM
    If I have a list, [groupA, groupB, groupC], and group C needs to be drawn under group A now, I need the list to look like [groupC, groupB, groupA]. you can use sort to do that. https://ashes999.github.io/learnhaxe/sorting-an-array-of-strings-in-haxe.html#:~:text=To%20sort%20the%20array%2C%20you,toUpperCase()%3B%20b%20%3D%20b.
  • c

    colossal-match-5265

    02/19/2023, 2:08 PM
    Heres more examples of sort
  • e

    echoing-rainbow-13896

    02/19/2023, 2:09 PM
    wait, is it possible to put sprite groups into a group or no?
  • c

    colossal-match-5265

    02/19/2023, 2:09 PM
    Try it and see (The answer is yes. FlxGroup can contain any FlxBasic, including other groups.)
  • c

    colossal-match-5265

    02/19/2023, 2:09 PM
    a state is a group.
  • c

    colossal-match-5265

    02/19/2023, 2:09 PM
    so if you have them in your state, then sort the state's members.
  • e

    echoing-rainbow-13896

    02/19/2023, 2:13 PM
    just tried and apparently I cant put a FlxSpriteGroup into a FlxSpriteGroup
  • e

    echoing-rainbow-13896

    02/19/2023, 2:14 PM
    so I dont know where to go from here
  • c

    colossal-match-5265

    02/19/2023, 2:15 PM
    Why do you need to put it in a FlxSpriteGroup?
  • c

    colossal-match-5265

    02/19/2023, 2:15 PM
    presumably, you already have 2 groups
  • c

    colossal-match-5265

    02/19/2023, 2:15 PM
    in a state or a group somewhere
  • c

    colossal-match-5265

    02/19/2023, 2:15 PM
    and you want to change their draw order
  • e

    echoing-rainbow-13896

    02/19/2023, 2:15 PM
    yea
  • c

    colossal-match-5265

    02/19/2023, 2:16 PM
    Then everything i said is the same
  • c

    colossal-match-5265

    02/19/2023, 2:16 PM
    there is no need to add a group to a FlxSpriteGroup
  • c

    colossal-match-5265

    02/19/2023, 2:16 PM
    that was not part of the solution I proposed
  • e

    echoing-rainbow-13896

    02/19/2023, 2:17 PM
    I do know how to change their drawing order when they are created
  • e

    echoing-rainbow-13896

    02/19/2023, 2:17 PM
    I just have no clue on how to change it later
  • c

    colossal-match-5265

    02/19/2023, 2:17 PM
    I specifically gave you the answer on how to go about it. use sort
  • e

    echoing-rainbow-13896

    02/19/2023, 2:18 PM
    ive tried sort already but that only works for sprites within groups as I understand it
  • c

    colossal-match-5265

    02/19/2023, 2:18 PM
    No it doesnt. sort works with literally any array
1...945694579458...9809Latest