Q: Expression creation

Discussion and feedback on Construct 2

Post » Sun Aug 28, 2011 9:40 pm

Is it possible in construct 2 to use expressions to create objects on the layouts? I want to use the for loop to create a series of tiled background repetitively in a row. Each tile graphic is slightly different. I want to use the for loop to cycle through a set of tile-background names. I can do this in Construct Classic but could not find a way to use an expression to do the same thing in version 2?
My Games on google play

ImageImage
B
30
S
6
G
4
Posts: 97
Reputation: 3,008

Post » Wed Aug 31, 2011 6:49 am

Anyone know the answer?
My Games on google play

ImageImage
B
30
S
6
G
4
Posts: 97
Reputation: 3,008

Post » Wed Aug 31, 2011 7:28 am

Add following action to your event -> System -> Create object.
B
23
S
4
G
7
Posts: 98
Reputation: 5,220

Post » Wed Aug 31, 2011 9:04 am

but how do you create an object using an expression statement. In construct classic you can right click System > Create Object and use an expression. In c2 I can't seem to do that?

thanks
My Games on google play

ImageImage
B
30
S
6
G
4
Posts: 97
Reputation: 3,008

Post » Wed Aug 31, 2011 3:15 pm

There's no 'use expression' for object names yet - for now you'll just have to have a set of subevents along the lines of "if string is 'TiledBg1', create 'TiledBg1', if string is 'TiledBg2', create 'TiledBg2'...". Maybe not ideal but possible.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,528

Post » Wed Aug 31, 2011 4:03 pm

ok thanks Ashley. I see if that will work. I a want to create a parallax scrolling effect using 3 layers of tiled backgrounds. Otherwise Ill wait for an update build :-)
My Games on google play

ImageImage
B
30
S
6
G
4
Posts: 97
Reputation: 3,008

Post » Tue Apr 17, 2012 2:57 am

I was searching to see if this question had been asked. It had been but a long while ago. So sorry for the necropost but is expressions to create objects still on the to do list. I know that list is huge, but it would be very useful. It's one of the small things in classic I look longingly at. onzephyr2012-04-17 04:28:17
B
84
S
12
G
9
Posts: 99
Reputation: 9,508

Post » Tue Apr 17, 2012 3:17 pm

It could be done, but it would help reverse-engineers because then C2 has to include a full list of all object names. Currently it obfuscates all object names to make it harder to understand the exported project. So are you sure you want it when it makes reverse-engineer's lives easier?
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,528

Post » Tue Apr 17, 2012 3:28 pm

I can see it bein a useful shortcut but I dont see it bein NEEDED specially with the project safety issue it would add.

What I would like to see tho is a better connection to creating objects and setting values for those objects.

I know you can create an object with an event and then use events to set values on it but theres no clear explanation of HOW to do that or that it even works (that Ive seen atleast) I had to just try it and hope it worked. Luckily it did =D
B
13
S
5
G
2
Posts: 306
Reputation: 3,262

Post » Tue Apr 17, 2012 4:06 pm

[QUOTE=Ashley] It could be done, but it would help reverse-engineers because then C2 has to include a full list of all object names. Currently it obfuscates all object names to make it harder to understand the exported project. So are you sure you want it when it makes reverse-engineer's lives easier?[/QUOTE]
hashmap the names, make the compiler ensure all existing names produce unique hashes.
you can use a fast one-way hashing that's not cryptographically safe (you could even use one of those ultra-fast XOR hashes, since the compiler will be doing the collision checking)Fimbul2012-04-17 16:11:20
B
35
S
8
G
8
Posts: 532
Reputation: 6,868

Next

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 13 guests