Reuesing code for multiple objects

This forum is currently in read-only mode.
From the Asset Store
Two levels with two sistem Wave. with Source-code (.c3p) + HTML5 Exported.
  • Ok,I'm working on a turn based strategy game. I have the movement down, turns down, combat somewhat down, and I'm pretty positive I can get switching from unit to unit.

    Here's my question: Is there anyway I could have it to where all of player 1's units use this group of code when they move/attack/spell etc. and they just call the code when they need it? i.e. archer finished moving. I press Q to switch to my swordsman. I then use the arrow keys to move him next to the enemy and then press shift to attack the enemy. is there a way that he archer and the swordsman, and all of player 1's units use the same code and they just call it when needed?

    Thanks for the help.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Sounds like you'd like to use families, as long as all the objects have similar variables and are sprites in that family then they can share code <img src="smileys/smiley1.gif" border="0" align="middle" />

  • Ok awesome that helped, thanks.

    Now, how would I go about detecting which unit I attacked with my unit? I was thinking of some how either "getting" the unit itself (easier) or a value that has been assigned to the enemy unit and then going from there?

    Thanks for the help.

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