Behavior inheritance?

Discussion and feedback on Construct 2

Post » Wed Sep 07, 2011 11:52 am

This question is aimed at plugin / behavior developers.

Is it possible to have an object Action such as "Inherit from object" which takes the internal values/properties of a specific behavior of the chosen object and add/update these to the original object the Action is based on? (basically a way to inherit)

The idea is for an item system. E.g. have a base "generic" type then create a "weapon" type and inherit the original values/features from the generic type.

Haven't spent much time thinking about this so I could be missing something alot simpler, just wanted some feedback and advice! (and maybe some specific functions for the runtime)

Thanks for your time,

Rez

P.S. I've been working on an inventory behavior which turns any object into a "container" and will use the web storage to save the container. Combining the above item behavior and this container behavior should provide a very robust item system. Well that's the plan!

Lastly, to all the Scirra team thanks for producing such an amazing piece of software!!
B
21
S
7
G
2
Posts: 185
Reputation: 3,280

Post » Wed Sep 07, 2011 2:11 pm

Have you tried Construct Classic and its 'families' system? That allows you to create a family like 'weapons', add three different kinds of 'weapon' sprite to the family, then make your events around the 'weapon' family (which appears like another object). Then, the events apply to all those objects.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,528

Post » Wed Sep 07, 2011 4:03 pm

Thanks for the reply Ashley. I've worked with families in Construct which would work. The idea is based on this article:

Generic item system

The item system works like a tree and starts from a few generic item types. My idea is to have an "item" behavior which is attached to a Sprite then you can create/add "features" e.g. "light" (item produces light) which are controlled by "conditions".

The conditions determine the effect e.g. the "onoff" condition when true turns the light on, etc. The dynamic properties are set using object variables such as radius, etc. The conditions can be checked through an event in C2 to see if it is true or false.

To me it would make programming complex items and effects using the C2 event sheet a lot easier although I might be wrong. The only problem I'm having is I can't copy the features and conditions to a new object. I have a generic light set up and I want to create a "Sunrod" (an exceptionally strong light) like the article but I don't want to redo all the events in C2 rather just have an action "Inherit" which takes all the information stored in the generic light.

I could just program this myself in the runtime but I was wondering if there's a way to access another objects specific behavior data within another behavior runtime?

Hmm, this is quite difficult to explain I'll do a bit more work and see if I can upload an example :/00Rez2011-09-07 16:05:30
B
21
S
7
G
2
Posts: 185
Reputation: 3,280


Return to Construct 2 General

Who is online

Users browsing this forum: alextro, MinecraftM153 and 18 guests