0 Favourites

Q: Expression creation

  • 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?

  • Anyone know the answer?

  • Add following action to your event -> System -> Create object.

  • 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

  • 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.

  • 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 I�ll wait for an update build :-)

  • 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. <img src="smileys/smiley20.gif" border="0" align="middle" />

  • 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?

  • 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

  • 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?

    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)

  • I don't think this is that neccesary at the moment. The he was in is quite unique as he was using tiledbackgrounds, usually you can just use animation frames.

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • Personally I would find it incredibly useful, to create objects through an expression.

    but if the only way to do so would be to compromise the security of an exported project I understand not doing it.

    Thanks Ashley for taking the time to explain the reasons behind the exclusion.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)