Functions and families... oh how I love how you interact

0 favourites
From the Asset Store
A collection of various zombie characters sprites for creating a 2D platformer or sidescroller game
  • newt - Events run, scene is rendered. Repeat. A function will always occur before the scene is drawn if it is called during the events. And... I'm still confused, what do you mean a variable can be used in the same ways as a function? You mean you set a variable to something and then if it is something you do do something, rather than calling a function?

  • Yep.

    As a trigger.

  • newt interesting. Though, that would n't work like a function in the sense that the function runs right away, but the triggering variable would have to wait till it was polled. And that could involve alot of polling in a big project.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The end result of your code is fine, assuming I understand the context, but I would say it falls under a simple use case scenario.

    Yeah... there are a number of simple use cases that C2 makes you work pretty hard for

    [quote:2csdt82w]In general it has been my experience that if you are using prebuilt behaviors and common use case scenarios, nothing is wrong. But the moment you need more, construct is an inflexible quagmire stuck in its own assumption about what the game creator needs.

    I have spent as much time searching for plugins and behaviors and writing javascript as I have actually using C2. I think that C2, flexible as it is, has taught me that real gamedevs actually do need to write code, or else loosen up and let the game be "not quite right". I've chosen the former.

  • Carrying over the SOL would have quite a high performance cost. Since the function can go on to modify the SOL, but then has to be able to restore the state when the function returns, the SOL lists must be copied before the function is called. If you have picked say 1000 instances with some event before calling a function, then every time the function is called with "carry SOL" it must duplicate an array with 1000 items. Used naively (on-by-default, or if there is a checkbox and you just get in to the habit of always checking it) you could end up with a very high CPU cost for this feature.

    Passing a UID and picking it in the function is a good technique: the "pick by UID" condition works in constant time (it just directly picks the instance without having to check every instance like normal conditions) so this is an efficient pattern. If you need multiple instances, just putting the picking conditions back in the function is probably not much less efficient than any kind of "carry SOL" feature, and could actually be more efficient since you can make sure you don't carry the SOL for any unrelated objects the function doesn't actually need.

    Functions are generally supposed to be some kind of independent, re-usable bit of work, and I'm not entirely convinced how sensible it is to design them to use the SOL of the caller, since that seems to mix together the responsibilities of the calling event and the function. There's not really a way it "should" work, since programming languages don't use SOLs so there's no good analogy looking at traditional programming languages. This type of question is, as far as I'm aware, totally unique to C2.

  • Ashley , well , that all makes sense. In a way, it's cool that it is uniquely a construct 2 problem, it makes you a pioneer (:

    I want to compile a list of all the forum topics you have entered and given particularly good insight into why something is the way it is with construct. A lot of your posts are pretty much manual worthy, needing to be summed up in a question/answer format.

    Just out of curiosity, is there going to be a c3 feature that allows us to make instance functions? Kind of how you would in programing when you make a class and have methods. It would be useful to have a bit more oop in construct, though sometimes, I realize a coding background can make me not see some obvious c2 unique solutions.

  • bladedpenguin - I think we are of similar dispositions then. I remember at one point being smitten with constructs speed. I was blazing through prototypes. Then when the time came to actually fix bugs, polish, and begin the actual game... I quickly realized, if you want it your way, there is no substitute for coding it yourself. One year ago, I thought I was a few months from release for a wii-u game... ... ... Well, nothing like telling people your almost done and then finally admitting to yourself that you've barely begun

    I like coding though... It just gets old after programing for a month straight on frame work and other stuff you can't readily see the progress in. Prototypes are fun to make. The actual game... sigh...

  • Ashley Thanks for the detailed response! It's always great to learn more about C2 internals. It feels good to know about whats behind the things we are seeing

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