How do I efficiently make multiple characters to select from

Just started using Construct 2? Post your questions here

Post » Thu Mar 20, 2014 9:30 pm

Should I make one object that has animations for all the different character types and change animations based on which character the player selects? Or should I make an object for each character and destroy the rest when the player chooses one of the characters? Or does it matter?

Also, is it better to make character stats a global variable or incorporate it as an instance variable for that object?
B
4
S
1
Posts: 18
Reputation: 388

Post » Fri Mar 21, 2014 6:25 am

This depends on a few things:

Can the player change his character during game?
Does a character have several animations (like jump etc.)?

And I always prefer instance variables over global variables. Your project is more clear than using too many global variables. (Image you put everything in a global variable and later in the game you have hundreds of them... wow...)
B
14
S
3
G
1
Posts: 255
Reputation: 2,027

Post » Fri Mar 21, 2014 5:19 pm

The player will not be able to change characters during the game. It will be a Diablo-like system in which each character has different skills.

My question is, is performance impacted if one object stores all that information? It just feels easier to make one object and switch animations based on a variable like characterChoice.
B
4
S
1
Posts: 18
Reputation: 388

Post » Fri Mar 21, 2014 9:08 pm

I haven't tried it yet, though I intend to. But the way I would do it is that I would add a global variable called "character_choice" or something like that, then check for that in the game. So when the player picks a character, the game will update the variable accordingly. The character itself can have local variables and all that, so the global variable is just to see which one is picked.

Or a really, really simplified version:

What character is picked? If character A, spawn character A and give the controls to him/her. If character B is picked, spawn that one instead, and give the controls to him/her.
B
5
S
1
Posts: 43
Reputation: 655

Post » Fri Mar 21, 2014 9:19 pm

You could have a "spawner" object spawn the correct sprite at the correct position based on the player choise. (or enter frame depending on what effect you want. (so yes this is destroy/create method)

You could have one sprite have everything but be used only for the "character select screen" and just swap "animations"

Depends on what you want to achieve. I have used both methods so far its a bit more dependent on need than on actual performance.

If you use something like spriter which has a plugin for c2 you can setup your animations and a set of "skins" check their stuff maybe you get some ideas too. I'm planning on using that as soon as I'm done with the current projects I'm working on.
Freefall Bird
B
47
S
9
G
5
Posts: 280
Reputation: 5,796

Post » Mon Mar 24, 2014 8:14 pm

Thanks for the input everyone!
B
4
S
1
Posts: 18
Reputation: 388

Post » Thu May 08, 2014 10:07 pm

I've been dealing with a character swapping issue for several months now, and I was wondering if we could examine methods for doing so in-game during play without pausing. My specific scenario is as follows:

I have three character containers at all times. At any moment, however, these can be switched to any one of four character designs (which involves several sprites being swapped out). To give a drastically oversimplified example: Mario gets replaced by Luigi, Peach, or Toad on queue, and each character involves a unique set of costume accessories in child sprites which also have to get swapped out.

The amount of animations involved and the possibility of adding more in later makes simply stacking everything into one sprite's animations unwieldy and inextensible. (As was the suggestion here).

The fact that UID's can't be predicted and IIDs can be dynamically updated makes these unreliable, as I cannot talk to any of my objects once I destroy one instance and replace it with another. I've managed to use a Local variable number to refer to the characters with limited success, but I can't figure out how to reassign the number to an object after swapping. For example:

Character IID 3 is assigned localVar value 2.
Character IID 3 needs to be swapped out, and so is destroyed.
New character is immediately swapped back in, but the IIDs are all wrong now and I can't figure out how to specify the new instance to reassign localVar value 2.

I've also seen this tutorial, but that scenario seems to involve switching between objects which never get removed or added back to the layout, and all exist simultaneously.

I'm starting to think in circles. Am I simply approaching this from the wrong mindset?

I've tried making use of Families and Containers. Unless I'm mistaken, containers don't allow you to selectively destroy/spawn one single child sprite. Families, meanwhile, suffer the same UID/IID limitations as their Sprite children.
B
4
Posts: 8
Reputation: 241

Post » Sat May 10, 2014 1:30 pm

Bumping. Not sure this topic ever updated in the forum list.
B
4
Posts: 8
Reputation: 241


Return to Beginner's Questions

Who is online

Users browsing this forum: FartsLolz and 1 guest