Multiple objects of similar type or all in one?

0 favourites
  • 4 posts
From the Asset Store
Be quick and choose the right answer for the shown equation.
  • Hello All!

    I have a long inching doubt about certain way to deal with objects.

    Basicly there's two views and ways to deal with multiple objects of similar type:

    1) you make a "goblin" object, another "panthom" object, "your char" object and "companion char" object. Then you use instance variables, families, containers and each object deals with it's own animations.

    2) you make one "enemy" object wich contains all the different animations for all your enemies and then you spawn instances of this object with a starting animation frame related to the enemy you want.

    Road 1 feels easier but you end up having many object types too similar and i heard that, for some reason, having many object types even if they are not active as instance slow down the game.

    Road 2 feels better to avoid objects population, a little more counter intuitive in a graphical environment like c2 is buut this is the thing:

    How much can hit an instance (and many instance) of this kind of object vs instance of individual object types? I feel like having 50 enemies in one object type will kill fps.

    But i see this approach being used by many developers and i want to know how well it went against using multiple object types.

    I will try to make a version of one protoype in method 2, using arrays like Kyatric did in one of his examples. But if you can tell me how it was for you it would help me a lot.

    Thanks people!

  • Below you will see Kyatric's example using one object type "monster" containing every monster type. So it uses "way 2". With an array and clever use of instance control he can spawn many monsters instances, each different in a random fashion.

    Kyatric's Example "myMiniRPG"

    https://www.dropbox.com/s/zmfsdpgh926nmu8/myMiniRPG.capx

    Now, with this example in mind, if i add all animations for all the monsters to this single object. It won't kill performance more than using different object types within a family and then reference each instance with an array or whatever method for each of them?

    What did you people found in your test? One big object or many to spawn different kind of enemies? (just to keep with the example above)

  • I think the only drawback to having all-in-one objects is all the animations are loaded when only a single instance is created, which affects loading times a bit.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • That's mostly my concern about that metod. But maybe C2 keeps 1 instance of each object type (with all it's animation) on memory even if there's no instance spawned at run time. Then it would be the same having everything in one object or divided in different object types.

    I like having single-frame static object as one object (trees, rocks, walls, etc). But once i have more complex, dynamic objects i don't know if the burden of referencing each on one object has some real advantage.

    In the same way, i don't know witch method is better on memory and loading times. Then there's differences in how this appears to work if you use, for example, CocoojJS.

    I'm a little in the dark about this and is central once a project start to grow in assets and objects.

    Someone else know more?

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