Layout Instance Variables

Get help using Construct 2

Post » Sun Jan 20, 2013 1:23 pm

Hi all,

I don't know if this has been talked about at all, but has there been any discussions around layout variables/properties/metadata?

At the moment I'm defining per-layout properties with some nasty string manipulation based on the layoutname, then affecting global variables in the logic.

I'm guessing this would be beyond the scope of a plugin?
Moderator
B
72
S
13
G
11
Posts: 900
Reputation: 11,783

Post » Sun Jan 20, 2013 3:02 pm

I dont think its a big issue, each layout needs to be linked with an event. There a workaround you can make an event "compare two values" first layoutname is equal to string of current layout name, then make subevents and do whatever.
B
95
S
25
G
20
Posts: 3,052
Reputation: 22,613

Post » Sun Jan 20, 2013 3:05 pm

Yeah that's what I'm doing at the moment, however when you have 50+ levels, and the design process often demands reordering/sorting/renaming, it becomes quite unmanageable.
Moderator
B
72
S
13
G
11
Posts: 900
Reputation: 11,783

Post » Sun Jan 20, 2013 3:19 pm

Whats game genre are you making?
B
95
S
25
G
20
Posts: 3,052
Reputation: 22,613

Post » Sun Jan 20, 2013 3:37 pm

This is still Mortar Melon - simple physics puzzler.
Moderator
B
72
S
13
G
11
Posts: 900
Reputation: 11,783

Post » Sun Jan 20, 2013 3:56 pm

Well, the best solution when you include the separated events for one layout, it is up to your codebase design.
B
95
S
25
G
20
Posts: 3,052
Reputation: 22,613

Post » Sun Jan 20, 2013 4:35 pm

I got around this by using Group local variables. I will often end up creating a group/event sheet for the level. Then define all the variables on the startup event. That way EVERYTHIGN in that group get's it. Even sub groups.

Otherwise I tend to use level loaders, but mortar melon looks easier to do per level. good looking game btw :)
B
87
S
18
G
9
Posts: 2,455
Reputation: 14,834

Post » Sun Jan 20, 2013 5:09 pm

I found the simplest solution is to just use instance variables on arrays/dictionaries as they don't seem to reset when you change layouts. Lets you name and sort your groups of variables too, a big plus!

So if you want to access variables that are just for that level, you just compare to the corresponding array. Downside is you can't clone them for some reason, so if you have heaps of variables to add it becomes very tedious.Tobye2013-01-20 17:12:03
B
27
S
8
G
5
Posts: 429
Reputation: 6,902

Post » Mon Jan 21, 2013 6:17 pm

Something I not checked yet - I'm at work - but, could you create a Group in the event sheet for that layout and then have the variables be in that group? They would then be local to the group.

Of course this would not work if you were using a lot of groups in each event sheet.
B
13
S
4
G
3
Posts: 75
Reputation: 3,425

Post » Mon Jan 21, 2013 7:03 pm

A few people have mentioned this, but my event sheets are shared between all the layouts. I can't understand why you'd have a per-layout event sheet unless you had logic that you were not going to reuse.

I think the closest I can get to what I want to achieve is by having a dummy sprite in every level with various instance variables. It's pretty messy but at least then when I duplicate/rename levels it doesn't change.
Moderator
B
72
S
13
G
11
Posts: 900
Reputation: 11,783

Next

Return to How do I....?

Who is online

Users browsing this forum: 99Instances2Go, jeffige, LeFuji, plinkie, Radulepy and 0 guests