...work with many objects having same behaviour?

0 favourites
  • 11 posts
From the Asset Store
_______ Huge collection of metal fixtures ________
  • With this example you guys shall understand my doubt:

    Consider i have a platform with enemies. So, i have the main char and about 10 monters. I'll have some events to lower monster's hp, increase strenght, change abnorminal conditions, move it, etc etc. How to add this same behaviour to all monsters?

    To who is a programmer, what i want to know is how to have some inheritance here. I want to have a "Monster" object which will have all standard behaviour, but for each instante created, i want to change it's image, hp, etc etc...

  • This is nothing more or less than a picking issue. You can pick either one instance of you sprite, or the sprite as is; ie. all instances at once.

    If you have an event, that has not picked one of your monsters and then you refer to the monster sprite, the changes will apply to all instances.

    Pick a single instance by UID or IID or by an event like "on collision with" and the changes will only apply to this instance.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • No it's not Weis (unless i understood wrong): my point is having many different objects (sprites) but all of them having the same behaviour.

    The picking all/random etc, doesn't help the poblem of having X events for every object type i have... you see?

    Edit;

    By the way, i just tought in some workaround... will try soon.

  • o it's not Weis (unless i understood wrong): my point is having many different objects (sprites) but all of them having the same behaviour.

    sound's like a job for a family behaviors.

    In meantime you could use variables to store some values and then apply them when needed to your behaviors - can take some events tohugh.

  • shinkan, thanks for pointing out some directions... i'll read about families.

    As i'm still testing the tool, i don't have this option enabled :P

  • So, what is the difference between your sprites if they all have the same behaviour?

  • So, what is the difference between your sprites if they all have the same behaviour?

    Basically, the atributes...

    Imagine my example: the "Monster" object have events for losing hp, destroy the object when hp <= 0, walk, run, flee, attack, etc.

    All those elements should be the same for all monsters, considering it's speed, size, hp, strenght, image/animations, etc etc. You see?

    The "solution" so far that i tought is to have a monster object, with all monsters i have on single frames and an array containing it's default attributes, indexed by monsters image frame.

    So on frame 1 have a turtle? on arrayMonstersInfo[1] i have turtle's data;

    On frame 2 a dragon? arrayMonstersInfo[2] contains dragon's data, etc etc.

    The problem here would be only the animations =/

  • to me, they are still all the same sprite, just with different values on their instance variables and different animations...

  • I still don't see weis... hehe maybe i need a bit more practice with the tool.

    Anyway, i think families are what i'm looking for: http://www.scirra.com/tutorials/46/introduction-to-families-for-construct-classic

    What i couldn't find was a manual entrey for C2's families :X

  • Families are very new to c2

  • Sprites can have different animations, different values in variables, different positions, and of course all would have the same behavior.

    You just need to learn about how to set that up, and pick as Weishaupt suggested.

    Families will eventually be able to do all that, but behaviors aren't available yet.

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