someObject = someObject = Impossible?

Discussion and feedback on Construct 2

Post » Fri Sep 05, 2014 6:38 pm

Hey everyone!

I think the title says it all... Construct2 needs to be able to copy objects. Further It should also be able to copy shared instance variable through families. For ex:

Bat (of family FlyingAnimals) = Eagle (of the same family)

Behavior copying should aslo be allowed... ie:

SomeObject.physics settings = someObject.physics settings.

Construct 2 also needs to be able to pick any object and then test its type. With only 1 family (and since families are abstract you always need to refer to objects) things get difficult with complex objects.

anyway...
Last edited by ruskul on Thu Sep 11, 2014 8:04 pm, edited 1 time in total.
Image
B
33
S
11
G
2
Posts: 564
Reputation: 5,163

Post » Thu Sep 11, 2014 8:02 pm

I don't normally bump...

but seriously - nobody has ever wanted a copy of an object instance during runtime... Nobody has wanted to copy behavior settings at runtime?

If you have 30 variables on an object and you want a new instance to be the same you have to:

1. create the new object, and store its uid
2. store the UID of the object you want to copy
then...

then ignoring the mess of trying to pick the same object type and setting the correct one to the other correct one...

Self.variable_A = Object.Variable_A
Self.variable_B = Object.Variable_B
Self.variable_C = Object.Variable_C
Self.variable_D = Object.Variable_D
Self.variable_E = Object.Variable_E
Self.variable_F = Object.Variable_F
Self.variable_G = Object.Variable_G
Self.variable_H = Object.Variable_H

... and so one.... if you have complex objects, or compound objects, get ready to have a nightmare and no way around it...
Image
B
33
S
11
G
2
Posts: 564
Reputation: 5,163

Post » Thu Sep 11, 2014 9:48 pm

Have you looked at all the 3rd party plugins? Maybe there's some there that can help. I'm an OO guy too, but C2 just isn't.. But something like 'clone' would have its uses for sure. In the meantime use family instance variables a lot (I'm thinking that for flexibility, they are the only type of instance variables that should be used) and have a clone() function for each family type. Just some ramblings before my first coffee.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Fri Sep 12, 2014 1:51 am

From the manual a common expression is .asjson and there is also the common action "set from json".
I haven't used it myself yet but I believe it can be used to clone object state.
B
94
S
33
G
113
Posts: 5,356
Reputation: 73,273

Post » Fri Sep 12, 2014 1:59 am

There are times when you very well may want to clone an instance and its much faster and safer to do it in the engine that through the event sheet. With that said check out this plugin i found on github for you. If it does not do exactly as you want you can modify the plugin to get your desired effect.

Search for "arcturial/sprite-factory" on GitHub
[b]Andrew Donelson[b]
Nlaak Studios, LLC
https://www.nlaak.com/
[email protected]
B
15
S
3
Posts: 66
Reputation: 1,136

Post » Fri Sep 12, 2014 5:26 am

I had the same issue. The only solution I found is to create a helper family with the object in it.

Object.Variable = Family.Variable
B
14
S
3
G
1
Posts: 255
Reputation: 2,027

Post » Mon Sep 15, 2014 9:43 pm

R0J0hound wrote:From the manual a common expression is .asjson and there is also the common action "set from json".
I haven't used it myself yet but I believe it can be used to clone object state.


I'll check that out - If not, I didn't consider 3rd party plugins, but I'll check out the gthub example.

Its a bit weird, but I have shyed away from working with custom plugins and behaviors (I don't even write them myself) - part of this is because If I am going to code I bust out unity, which I find more user friendly in that aspect. Perhaps I have not given construct 2 enough time. But Given there is very little documentation on writing plugins and or behaviors... idk.
Image
B
33
S
11
G
2
Posts: 564
Reputation: 5,163


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 7 guests