How do I code skins efficiently?

0 favourites
  • 7 posts
From the Asset Store
This is a code so you can see the same skin on all screens (peers). Each peer gets a skin, in addition to 4 directions t
  • Hello!

    First off, I already searched a bit in this Forum but didn't get the answer I was looking for.

    I am working on a 2D moba and adding some skins. For now I just copy / paste the complete coding block of 1 character and replace every "classic" character with a new sprite which is his skin.

    Is there a better way to implement skins in my game? For example a condition where you just replace all objects of a projects with an other. So character "Blue skin" is chosen, replace every classic sprite with the sprite of the blue skin or something like that.

    Making different animation is also kind of odd. And I guess I still would have the same amount of code as I got now.

    So is there any good solution for adding chooseable skins in a game?

  • Well with the different animations you could just keep the same sprite object and 'play' the different skins? Having each character separated isn't a bad thing either but to minimize it I guess you would do it with animations so the character object is the same but they 'look different'. If you're changing all characters to blue when blue is chosen (just trying to picture the game) I guess you could set each blue animation to be called 'blueskin' and then make all characters set the 'blueskin' animation when blue is selected.

    When you say making animations is kind of odd, what do you mean? Surely the animations need to exist already to display the skin?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I also thought that but I would need new animations for walking, jumping etc too...

    Right now when I swap a skin, the skin has the same named animations, that's why I don't have to change it in the coding.

    So I had to change everything to "set Player1 Animation to blue_walk", "blue_jump" etc.

    Maybe you have a better overview when I show you my game...At the beginning you can chose a skin.

    kingdanius.itch.io/league-of-pixels-2d-moba

  • From looking at the game, because you are spawning a new character in I guess I would spawn whichever object is required, where each character is a separate sprite object. You can group all of the character stuff in a family. If you create the characters as separate objects including blue variants then add them all into a family, you can assign the movement controls to the family just the one time. Each object will have its own animations that correspond with the default names, so archer has jump and equally blue archer has jump. In terms of code it'll be a few events, the work will come with the separate objects.

  • The free edition doesn't have families, though. But with something as big as a MOBA, I would start to look into some serious data structures. Just looking at what you need, here's an idea:

    -Make all your characters one object with a bunch of different animations.

    -Make an array with the names of all the different animations (e.g., P1Walk, P1Idle, P2Walk...). Put different character types along the X axis and different actions (walk, idle, etc) along the Y.

    -Give the character a number variable for which character it is and another for what it's doing.

    -When you want a character to do an action, have the events change the value of the action variable.

    -Finally, add an event like this one:

    Every Tick - Characters play animation array.at(Characters.identity, Characters.action) from current frame

  • calebbennetts

    Thank you for the tip, I will try something of it (if I am able to xD )

  • Hmm I didn't see any mention of free version only. Making a MOBA with the free version, restricted layers, 100 events and no families seems like a bit of a challenge, you would just be tying your hands behind your back. Your game is showing some promise so I would suggest purchasing a C2 license rather than creating a load of workarounds for what I explained can be only a few events. The workarounds themselves are going to make you start pushing toward that 100 event cap anyway.

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