How do I store a player selected var and retrieve it for the rest of the game ?

0 favourites
  • 5 posts
From the Asset Store
290 static tiles (32x32 in size) + 2 animations for use in your project!
  • Hi guys,

    Im relatively new to Construct (have made some simple collision games with scoreboard).

    At present, I am creating a game for my son which requires the player at the start of the game to select their character. Let's say the character choices are; dog, cat, chicken etc

    When the character is selected, I need the choice to be stored and retrieved in my event sheets for the rest of the game.

    eg. if a dog is selected at the start of the game, then how do retrieve that selection in actions like sprite set animations. If i make a family with the 6 character options, I need to ensure the correct animal animations are used based on the stored players selection. I played around with arrays, but couldnt figure out a solution. If I use families, I dont know how to uniquely reference the correct animal.

    Even though I have standardised each animal's animations to have the same animation name (IDLE, RUN and JUMP), they all look different of course as.... they are different animals :P

    I guess another way of explaining it is that it would be great to be able to select the VARIABLE content instead of a SPRITE OBJECT when adding an action. So, every incidence where the player character has an action, the variable substitutes the correct animal character's sprite name.

    Apologies, if this is not clear - I'm not familiar with correct terminology. I have looked extensively on youtube and the forum, but could not find anything that appeared to help.

    Any assistance would greatly be appreciated :)

    Kind regards,

    Frustrated dad programmer (Ronnie)

  • One way is to use a group of events for each selectable character. On character selected, activate the relevant group.

    Each group will have the proper unique events for each character. Anything that is common to all characters can simply reference the family instead.

  • Thank you kindly oosyrag - im not familiar a group event function. Do you perhaps mean writing 6 lines of duplicate code - one for each of the possible character selections? I f so, I thought of this but as the game is going to be massive, with 20 levels, all with different event sheet characteristics - I thought it may not be the best way as it will be a lot of coding which may make the game a lil slow and inefficient? Maybe I misunderstood, your solution. I will look into it. thx :)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • An inactive group is no different than no group. It's also not duplicate code. Like I mentioned early, if it's the same, just use a family. You only need to make events for the differences between characters.

    Your character animations should have nothing to do with how many levels you have.

  • thanks again for your reply - i think i understand better now. still trying to get my head around concepts. i'll look into it further based on your suggestion and have a play around. thank you :)

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