Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by fugufish

My initial thought would be to create a menu, which allows the player to select one from N different characters. And then load the corresponding entity.

This means that N different entities have to be coded.

Any shorter way to do this? (i.e swap the animSheets) ?

1 decade ago by MikeH

The "right" way to do it is to code the different entities (if they're different characters, you may find you want them to run at different speeds, or whatever, later on down the line).

However, it's much less work than it seems.

Your main character entity:

EntityCharacter = ig.Entity.extend({
    // ... entity code goes here ...
    animSheet: new ig.AnimationSheet( 'media/characters/default.png', 32,32),
    // rest of code goes here
});

Now the rest of your characters can just be:

EntityCharacterA = EntityCharacter.extend({
    animSheet: new ig.AnimationSheet( 'media/characters/A.png', 32,32),
});


EntityCharacterB = EntityCharacter.extend({
    animSheet: new ig.AnimationSheet( 'media/characters/B.png', 32,32),
});


EntityCharacterC = EntityCharacter.extend({
    animSheet: new ig.AnimationSheet( 'media/characters/C.png', 32,32),
});

So you define a new character with just three lines of code, and you have the advantage of being able to assign different characteristics, health values, etc. based on which one the player chooses.
Page 1 of 1
« first « previous next › last »