Gumball's Forum Posts

  • It resets as soon as we leave the sub-event we've placed it in. (Or rather, it doesn't reset at all. But the variable is only valid in that specific sub-event and its children, any new sub-event of the sort will create a brand new variable. What we see in the UI does not equate to what happens on the internals of a programming/scripting language. The unused ones will eventually be picked up by the garbage collector and cleaned up as they're no longer in use.)

    The beauty of a scope, anything inside of it is valid while you're in the scope. Any time said scope is encountered the values start out completely unaware of the last time the code was run. (Unless specifically stated otherwise, but if we start including that now things will get really confusing.)

    If you're interested, there's some decent information regarding scopes and the reach of variables around the web. One such example would be this: http://people.cs.clemson.edu/~turner/co ... ch8_5.html

  • As soon as you speak of wanting an example *.capx for download and upload images to show stuff I really don't think your internet's too poor to give us an example.. But instead of going on about that over and over.. It's not important right now.

    Anyway, if you took offense to what I said then I apologise. Years of spending time on various ''help'' forums has made me see all sorts of people, from the folks that just want others to basically create their entire game for them to people that just need help with that tiny little speck they keep glancing over. I try to stick in the middle with my responses, although sometimes my lack of tact and knowledge of the English language makes things come out a lot less pleasant than intended.

    Anyhow, glad it solved your problem. That's the main thing that matters here.

  • Giving someone an idea on how to fix something over a straight up solution they can copy/paste can teach them more.. At least that's what helps for me, so I pass ideas on the same way. Hardly anything to do with being elitist.

    (But if we're being honest, with your post's content screaming "I'm too lazy, make this for me so I can copy it" I must admit I am much less inclined to take the effort in the first place. Whether you intended it to sound as such or not.)

    ---- EDIT -----

    I see you responded again, it'd really really help if you provided a file for us to tinker with here.

    Anyhow, your third condition isn't really necessary, as the wait 2 seconds could be under the event where it's not overlapping as well. You should probably also remove Trigger Once.

  • If you had provided a *.capx file I would have looked at it, possibly corrected it and posted it back in the first place.

    But I digress, here's how I use it to deal with cutting grass objects:

  • I'm thinking part of your issue lays in addressing all the pressure plate objects at the same time, but I can't confirm this as I don't have anything to test it with. You could try and For Each through the PressureSpikes, which takes them all into a separate scope and lets them behave individually.

  • Wouldn't it be easier if you provided a basic *.capx with what you tried (only with the bare minimum) and people can look at what you did, then offer you pointers on it?

  • -snip-

    on event sheet 1 and 2 include event sheet (score)

    I feel incredibly dumb, because I only just realized this was possible.. It's not my topic, but I'd like to thank you for pointing that out to me anyhow.

  • there is a 3d plugin, but don't know the name nor the price for it.

    I think you may have misread the question.

  • If it were to reset every tick it would still affect other instances, but it doesn't. It only affects whatever is in the scope of the variable. Outside of the scope, the variable is moot. In another scope, when another object collides the variable is initialized again as we're outside the scope of the last event. (Any ''condition'' that has a little green arrow by it is also an event, they are triggered by the system, rather than constantly being checked for. So they're a bit more efficient than looking through all your conditions every tick when there's no need to do so.)

  • What he wants to say is local variables are only used in their event (and subevents below it) and reset them self every tick.

    So no it will not stay at 1 and cause the event to never run again.

    Not entirely correct, as it is not on every tick.. (Scopes! A very important concept in OO behaviour!) but that is the general idea.

    And yes, I understand I turned this into a complex story right away.. But once you get what a scope does it'll make your life so much easier. (Alternatively, you could take my *.capx I posted and accept it works, and come back to the subject at a later day. I won't judge.. At least not harshly. )

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Make sure it is a local variable, basically despite the fact that this is not code we're dealing with Object Oriented behaviour and scopes.

    The -> Enemy On Collision with Brick event opens a new scope for the objects in question. (Thus, our current instances of Enemy and Brick) as triggers do. As long as you stay in this event (as my sub-events did) when you address the objects you're ONLY changing the ones within that scope. In code it'd more or less look as follows:

    internal static void OnCollision(Enemy instEnemy, Brick instBrick) {
        var Shifted = 0;
        if (instEnemy.Direction == "right" && Shifted == 0) {
            instEnemy.Direction = "left";
            Shifted = 1;
        }
        if (instEnemy.Direction == "left" && Shifted == 0) {
            instEnemy.Direction = "right";
            Shifted = 1;
        }
    }[/code:2z089kcj]
    
    Although that might not mean much to you, I suppose. We are still staying within a scope. <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile"> (e.g. anything surrounded by { } is a scope, and variables initialized within one are usable inside said scope and any scopes created within said scopes but not outside of the scope they were created in. When a new scope begins, new variables are initialized and the old ones are NOT re-used.) If you want to know more about how Object Oriented languages deal with scopes, I would advice you to search around a bit on google. It might be helpful.
    
    But I digress, technical mumbo-jumbo. Basically, because I turned the conditions and variable into children of the collision trigger they only count for anything in that little block. The variable is not accessible globally, but only in that block and the conditions and actions trigger only on the items relevant to the trigger.
    
    But instead of trying to explain scopes and programming logic (at which I stink, I can write it just fine but explaining things without writing an essay full of examples and pictures won't be easy. <img src="{SMILIES_PATH}/icon_razz.gif" alt=":P" title="Razz">) here's the *.capx where I fixed it for you to play around with: [url=https://www.dropbox.com/s/crrauxq4wt0bnqx/Project.capx?dl=1]https://www.dropbox.com/s/crrauxq4wt0bn ... .capx?dl=1[/url]
    
    Just remember that positioning of variables, triggers, conditions and actions can be VERY important to the flow of your game.
    
    EDIT: Come to think of it, how did you copy it? With the indentation or without it? (I'll be heading off to bed in a moment, but I imagine other folks around could help you if you get stuck on this as well. <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">)
    
    (Of course you could be more efficient in code, and write something as follows:
    
    [code:2z089kcj]
    internal static void OnCollision(Enemy instEnemy, Brick instBrick) {
        instEnemy.Direction = instEnemy.Direction == "right" ? "left" : "right";
    }
    [/code:2z089kcj]
    But unfortunately we don't have the luxury of such operators in Construct. <img src="{SMILIES_PATH}/icon_e_sad.gif" alt=":(" title="Sad">)
  • There it is thats why you need triggers in construct 2 or an "or" function!

    I don't see how or is applicable here, since that'd still execute the same events. An ELSE function that works with any and all conditions and triggers would be nice though, and definitely useful in this case.

    (Also, there is an OR block, if you have multiple conditions you can turn your block into one.)

  • I believe it's because the instant you change it from going left to right, the next event in line triggers.. While still colliding with the Brick, so it simply moves left again. (following the Event sheet top to bottom). If you flip the Direction changing events around, you'll see what I mean.

    EDIT: A quick dirty fix:

    What I changed is fairly simple, we just need something to tell us that we've already changed direction so the next conditional event in line does not trigger.

  • Thanks for the replies Guys.

    > You could also use the Is Overlapping condition (...)

    >

    Is Overlapping is not an observer condition, so with the number of my enemies that would be probably way to much CPU consuming...

    -SNIP-

    Fair enough, I had not considered that to be honest. My current fidget projects are all PC based prototypes.

  • A quick glance at the list of supported platforms would tell you that the Nintendo 3DS is not currently supported as a native export. But perhaps someone has a method of doing so somewhere?