Access global variables (not instances)

For developers using the Construct 2 Javascript SDK

Post » Sat Jan 24, 2015 10:41 pm

I'm trying to write a plugin that can procedurally generate levels based on the position of sprites in the previous level. To do this I need to be able to access the relative positions of the sprites each time the level changes--in the SDK I've only seen examples of modifying the instance of the object that the behavior is applied to.

Is there a way to do this? Thanks.
B
3
Posts: 2
Reputation: 179

Post » Sat Jan 24, 2015 11:05 pm

you'll need to grab those positions before the layout changes. construct doesn't automatically save the previous object positions like that. Make a plugin with an action that has an object type param, and save the positions of all the objects picked into an array or js object, then process them in the next layout by making your object global or saving the array to some global js object.
B
75
S
13
G
8
Posts: 1,973
Reputation: 9,841

Post » Sat Jan 24, 2015 11:14 pm

Alright, thanks.

What exactly would the code be to store all the instances currently on the screen into an array? I still can't figure out the code to grab all of the objects.
B
3
Posts: 2
Reputation: 179

Post » Sun Jan 25, 2015 12:27 am

i don't know off the top of my head, but theres a list of instances which you can get from the js object for a particular type which is passed in from the object param.
B
75
S
13
G
8
Posts: 1,973
Reputation: 9,841


Return to Javascript SDK

Who is online

Users browsing this forum: No registered users and 0 guests