Construct 2 Default Instances Possible Bug

Discussion and feedback on Construct 2

Post » Wed Jan 21, 2015 6:13 pm

The default values for an object's instance variables don't work as expected.

Repro Steps
Create a new project with two layouts, Layout 1 and Layout 2. Create a new object type called Block.

1. Create first Sprite Block "Instance A" on top-level layout Layout 1
2. Add new instance variable, "PropValue", set to 10 for Block.
2. Create a second Block "Instance B" in Layout 2 (PropValue correctly initialized to 10 from "Instance A")
3. Delete top-level instance "Instance A" from Layout 1.
4. Set PropValue on Instance B to 20.
5. Drag new instance of Block onto editor from Project Object Type List (into either Layout)
6. New instance is incorrectly initialized with value 10 from previously deleted instance.

Expected Behavior:
New instance should have property values equivalent to only remaining instance since it is now the archetype template for Object Type Block.

Workaround:
Completely reload the project file in Construct 2. This will reset the "in-memory" prototype of Block and its associated instance variable's values.

See 1 minute video demonstration:
https://www.youtube.com/watch?v=WxstxtxCJIg


Not a huge deal, but if you're dealing with a lot of object types and lots of instance variables, you can easily make mistakes because of this.
B
31
S
7
G
8
Posts: 232
Reputation: 6,274

Post » Wed Jan 21, 2015 6:41 pm

I don't agree. The root instance is the one in the Project Object Type List, which is what I expect.
If your vision so exceeds your ability, then look to something closer.
Moderator
B
136
S
31
G
87
Posts: 5,498
Reputation: 60,282

Post » Wed Jan 21, 2015 6:56 pm

I always hated default instances. Instead there should just be the 'default object' stored in the object bar. Not only do you NEED an instance in a layout, but you can't change which instance is the default one that future instances inherit their properties from. This can cause issues down the road, especially if you forgot to create a default instance in an object-bank layout.

Also the issue you brought up seems like a bug to me.
Image
B
243
S
30
G
13
Posts: 1,787
Reputation: 18,770

Post » Wed Jan 21, 2015 7:52 pm

zenox98 wrote:I don't agree. The root instance is the one in the Project Object Type List, which is what I expect.


@zenox98
I think you might be misunderstanding the issue. The Project Object Type List is not an actual instance, it is just the Object Type. As an example, remove all the instances of an Object Type off all layouts. Now click on the Object under the Project Object Type List. Notice that it doesn't show any actual properties? (No position, no instance variables, etc)
B
31
S
7
G
8
Posts: 232
Reputation: 6,274

Post » Wed Jan 21, 2015 8:12 pm

Did you try right click copy, and then paste?
That would give you a copy of that instance.
There is a bug with that, in that its still not a perfect copy, not all behaviors, params set, etc.
Image ImageImage
B
171
S
50
G
180
Posts: 8,397
Reputation: 113,988

Post » Fri Jan 20, 2017 8:01 am

it seems like this is still an issue. i am currently working in a game and this bug is a roadblock for me.
B
18
S
2
Posts: 13
Reputation: 794

Post » Fri Jan 20, 2017 11:04 am

Workaround:
Completely reload the project file in Construct 2. This will reset the "in-memory" prototype of Block and its associated instance variable's values.


I hate what that 'workarround' implies. Because. Well, if you are not carefull, the copys that you make tomorrow will have their instance variables set to different values as the copys that you made today.

Rather:
create a default instance in an object-bank layout.

Better:
Hope it gets fixes one day.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Sun Jan 22, 2017 12:39 am

I see what you are saying it is the one from last instance deleted that sets the default value instead of the very last instance deleted

although I would much prefer that the original set value remained and only changes if you change the main object IV not inheriting any values from those in layout

I cant really see how this would be in issue though.....interested to know why it is a blocker for @kururugi66

maybe it would be better to spawn instances at runtime from spawn objects or by system at co-ordinates. And then set the instance variables in game in a different way eg from an array.
...
B
46
S
24
G
7
Posts: 339
Reputation: 8,243

Post » Sun Jan 22, 2017 6:54 am

@NetOne it is like this:
on layout 1, i made a sprite with instance variable with a value "testValue"

on layout 2, i used the same sprite but without value
then on layout 2 event sheet, i destroyed the sprite then recreate it again. the result is that the sprite i recreated on layout 2 style sheet still have the "testValue" value.

this happened when i tried to duplicate the GUI of my game to another layout with different use
B
18
S
2
Posts: 13
Reputation: 794

Post » Sun Jan 22, 2017 10:41 am

Tokinsom wrote:I always hated default instances. Instead there should just be the 'default object' stored in the object bar. Not only do you NEED an instance in a layout, but you can't change which instance is the default one that future instances inherit their properties from. This can cause issues down the road, especially if you forgot to create a default instance in an object-bank layout.

True. I hope Scirra works on a solution for this in C3.
B
135
S
33
G
17
Posts: 1,560
Reputation: 20,734


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 5 guests