Reuesing code for multiple objects

For questions about using Classic.

Post » Fri Aug 02, 2013 12:45 am

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.

B
2
Posts: 8
Reputation: 166

Post » Fri Aug 02, 2013 12:57 am

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
"Construct 4 lets YOU make advanced games! (but not play them)" Construct Classic - Examples Kit
B
108
S
38
G
17
Posts: 2,172
Reputation: 18,964

Post » Tue Aug 06, 2013 12:29 am

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.
B
2
Posts: 8
Reputation: 166


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 0 guests