Objects with the same actions, how to not repeat

0 favourites
  • 6 posts
From the Asset Store
2D fighting template based in the game that defined the fighting games genre.
  • Hello Everyone,

    I am making a some style of fighting game, where at the initial screen you can select one of the 3 characters.

    Then in the second screen I have a problem with the events, which basically consist that I am repeting every time the same actions.

    For example:

    If the character 1 is selected I have this:

    Keyboard D is down---> sprite1: Simulate platform pressing right

    Sprite1 have all the animations for the character selected.

    But, the problem is if the user selected another character I will need to repeat the same code changing only the object:

    Keyboard D is down --> sprite2: Simulate platform pressing right

    This is because, the sprite2 have all the animations for that character.

    So I am wondering if exist a way to reduce the events, and put the same in less events, and not repeating all this.

    Because -for example - if I have 40 characters I will need to repeat again 40 times the same event, due the 40 sprite objetcs are different.

    Any solution?

    Thanks for your help

    Best Regards,

  • put all your character objects under a family "Player" for example,

    and then create all actions and events on this family, all character objects will inherit the events

  • hmm as i remember you can do all these with some tricks like make 1 sprite with all these animations like this :

    player1_attack,

    player2_attack,

    player3_attack,

    player1_moveleft,

    .

    .

    .

    .

    and put a global variable that will help you to choose between 1,2,3...

  • EDIT: Sorry, didn't see the previous post. Consider this just further explanation!

    If you have the paid version, families sound like the way to go. If not,

    you could have one character sprite with 3 times the animations, and swap the animations based on both the character number and the activity the character is performing. So the run animation for character 1 might be: run_1, while the run animation for character 2 might be run_2, and for character 3 it would be run_3. The idle animations would be idle_1, idle_2, idle_3, etc. Easy to implement since you'd just append the character number on to the end of the animation each time you switch animations.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hello,

    I just bought the Standard Edition, so yes, I have access to the families.

    I was looking this, but I cannot figure how to inherit the actions and all stuff.

    I'm referring specifically to what vtrix mentioned:

    "put all your character objects under a family "Player" for example,

    and then create all actions and events on this family, all character objects will inherit the events "

    I don't know how to do it, can someone give me an example of this?

    Thanks in advance.

  • On the right, in the "Projects" window, scroll down until you get to the "Families" folder. Right click it and select "Add family". Now you just add the objects you want in that family, and you choose the new family object when making the events in the event sheet.

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