Multiple objects of similar type or all in one?

Discussion and feedback on Construct 2

Post » Fri Aug 16, 2013 2:14 pm

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!   
B
31
S
4
G
4
Posts: 110
Reputation: 4,593

Post » Sun Aug 18, 2013 4:48 pm

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"
[URL=]https://www.dropbox.com/s/zmfsdpgh926nmu8/myMiniRPG.capx[/URL]

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)
B
31
S
4
G
4
Posts: 110
Reputation: 4,593

Post » Sun Aug 18, 2013 4:52 pm

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.
Image
B
243
S
30
G
13
Posts: 1,787
Reputation: 18,770

Post » Mon Aug 19, 2013 11:39 pm

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?
B
31
S
4
G
4
Posts: 110
Reputation: 4,593


Return to Construct 2 General

Who is online

Users browsing this forum: LaDestitute and 28 guests