Set Object to Global at RUNTIME?

Get help using Construct 2

Post » Fri Feb 15, 2013 7:15 pm

Well... i'm working on a little something and my player (set to global) can pick up boxes and carry them around...

i want him to be able to carry the boxes over to the next layout...

this works if i set the property of a box to global in the editor but i need this to be dynamic... if i set the global property of my boxes family to true it ofcourse fucks up everything because each box is on each layout basically :D

i saw that the global property is not exposed in the events but i don't want to do it via events :/

wouldn't be much more work (check variable, is carrying box? yes -> spawn box and set to player xy) but maybe someone else has a better idea :)
B
33
S
6
G
7
Posts: 338
Reputation: 7,424

Post » Fri Feb 15, 2013 8:40 pm

[QUOTE=Ize] fucks up [/QUOTE]
I just needed to quote this one :P
...
Now , enough time wasted , let's carry on

That's why I dislike families , unstable for the moment

Oh well , If all the boxes have the same events and only the art differs , you can put all the frames in 1 object an manually set the frame number on the start of the layout ...

That way , all the boxes are one object
B
34
S
16
G
16
Posts: 2,222
Reputation: 16,564

Post » Fri Feb 15, 2013 9:32 pm

[quote]wouldn't be much more work (check variable, is carrying box? yes -> spawn box and set to player xy) but maybe someone else has a better idea :) [/quote]
You could also leave the boxes as global and destroy all the boxes not being carried at the end of the layout. This would work since all global means is the object won't be destroyed at the end of the layout.
B
79
S
24
G
52
Posts: 4,724
Reputation: 39,711

Post » Fri Feb 15, 2013 9:38 pm

Store the value in web storage then load it on the load layout?
B
49
S
11
G
10
Posts: 1,833
Reputation: 14,418

Post » Fri Feb 15, 2013 10:55 pm

@R0J0hound that would work... but i forgot to say that you can reenter a layout after you left it... so all boxes there would be destroyed if you return xD
B
33
S
6
G
7
Posts: 338
Reputation: 7,424

Post » Sat Feb 16, 2013 12:59 am

Why would all global boxes be destroyed if you reenter the layout? Are you destroying them on start of layout?
B
49
S
11
G
10
Posts: 1,833
Reputation: 14,418

Post » Sat Feb 16, 2013 11:28 am

no, i've tried @R0J0hound's approach by deleting all "uncarried" crates on exit of the layout and since they are global they won't reappear that way :)

anyway... gameplay wise i found out that it's actually good that my player can't carry boxes to the next layout... heh :D

but im still interested in setting objects to global at runtime... could be usefull in the future
B
33
S
6
G
7
Posts: 338
Reputation: 7,424


Return to How do I....?

Who is online

Users browsing this forum: imnotspecial, tomi71, totoe, Yahoo [Bot] and 10 guests