Cowdozer's Recent Forum Activity

  • Hi Ashley,

    I think it would be valuable to add a "Pinned to UID" condition for Pinned objects, so that you can easily pick all objects which are pinned to a specific object.

    I may have originally posted this in the wrong forum, which is why I'm posting here. The original topic is at the link below, and includes the code required to make the change (as of v1.14 I believe):

    scirra.com/forum/suggestion-pinned-to-uid-condition_topic63232.html

  • Hi rexrainbow, I think this Behavior is great and appreciate that you've made it public. I was playing with it today and noticed that if you have a Gravitation object that is both a source and target for the same source/target tag, the object will apply a force on itself. The result is that it accelerates to the right all on its own.

    I needed this to work properly, because I want to have objects that pull on each other, much like planets do. I updated your plugin with a simple change that fixed the problem for my needs:

    runtime.js, ~line 150-160, function behindstProto.tick:

    var sources = this.sources[this.target_tag];
    var this_uid = this.inst.uid;
    var uid, source_inst, inst, source_grange_pow2;
    for (uid in sources)
    {
        source_inst = sources[uid];
        inst = source_inst.inst;
        
        //We do not want an object to be exerting a gravitational force on itself
        if (this_uid === inst.uid)
            continue;
              
        source_grange_pow2 = source_inst.sensitivity_range_pow2;
        if (this._in_range(inst,  source_grange_pow2)) { ...
    

    If you agree with this change and can update the master copy of the Behavior to have this change, that would be great! Also, there is a typo in edittime.js: "Traget" should be "Target".

    I'm also interested in making the force applied dependent on the distance between objects as well as the mass of the objects. Maybe we could have a ForceMode parameter where the user can choose between Constant (what we have now), Linear, and Quadratic force. I'm very new to Construct 2 and yours is only the 2nd Behavior I've looked at in code, so I'll have to learn a bit more about Behaviors and Plugins before attempting this modification. I'll keep you up to date if I come up with anything interesting, though!

  • rexrainbow has made a "Gravitation" Behavior that allows for a similar effect. It will behave differently because the force is constant and not calculated based on the distance between objects or the mass of the objects. Heavier objects will not pull harder, but they will still resist being pulled as quickly due to inertia. Even though it behaves differently, it is similar and quite easy to try out.

    You can find the Gravitation Behavior here:

    scirra.com/forum/behavior-gravitation-for-physics-behavior_topic53035.html

  • From what I understand, if you use multiple layouts, you will have no way of overlaying the menus (if that is desired) or having a transition effect from one to the other in which they're temporarily both visible at the same time. Also, I think you could make a simple function that makes one layer visible and hides the others. Actually, why don't we just try that...

    dl.dropbox.com/u/117529592/Construct%202/Forum%20questions/LayerSwitchFunction.capx

  • If the plugins you find don't quite do what you want them to do, you should be able to make it work using the event system. I read about Functions in Construct 2 today and that they could be used recursively (which means that the Function can call itself) and thought that your particular problem would be a good exercise to work with it.

    Here is a capx that matches adjacent tiles of the same colour. Any tile to the left, right, top, or bottom is considered adjacent. I think this is the behaviour you're looking for, although this is not necessarily the best way to implement it. I was just having some fun, and wanted to show you that what you want to do is possible.

    dl.dropbox.com/u/117529592/Construct%202/Forum%20questions/MatcherPuzzleDemo.capx

    Left click to match, Right click to change colours. Enjoy!

  • Thanks Yann! It's still a little confusing, but your explanation really helps! That's a very good point about black being the colour of nothing in the editor. But if that is indeed the case, then why is the editor's colour of nothing typically light blue? If you make all layers invisible or make them (semi)transparent, you see that the background colour of the editor is light blue, not black. Do you think that maybe the Destination In effect is burning through the editor's background colour as well? If so, I'd consider that a small bug in the editor view.

    Another potential editor view bug is that I found you could set the light blend mode to XOR and get the same effect as Destination Out, but the editor view would show it opaque (as if blend mode were Normal). There seem to be some other weird things with XOR, such as it still having an effect on the overall image even if you make the layer Transparent. Either I am misunderstanding something (quite likely), or it's behaving incorrectly.

    I'll try to paraphrase and expand on your overall explanation:

    My understanding is that rendering is done starting with the lowest layer, and each layer renders objects using z-order from lowest to highest. Force Own Texture will render a layer on its own, independent of layers above and below it, and the visual effect of this is that blending modes on objects within that layer will only be applied to objects and the background of that layer, and not to anything rendered on lower layers. Once it's rendered to a texture, the layer will be rendered over the output of the layers below using the layer blend mode. This all seems to make sense and agree with my observations, EXCEPT:

    I found another way to do this lighting without Force Own Texture! This time, I have the lighting sprites blend mode Destination Out (same as demo), and the Lighting layer is Black, but instead of enabling Force Own Texture, I set Opacity to 99.999%. It seems that layer opacity has an effect as to whether a sprite's blend mode stops at the current layer or applies to all layers below it. If the layer is opaque, sprite blend modes apply to everything below it, but if the layer is semitransparent, sprite blend modes only apply to the current layer. Since Opacity is at 99.999%, it's enough to trigger this different behaviour, but 99.999% is visually opaque (it might indeed be opaque, although I'd have to screenshot and test pixel values).

    I wonder, is this method notably more efficient? From what I understand, it should be considerably more efficient. I also wonder if XOR is more or less efficient than Destination Out, because those two blend modes seem to be visually equivalent in this situation.

    I've updated the capx and html with a third layout. The third has settings:

    Lighting layer: background black and 99.999% opaque, blend Normal.

    Lighting sprites: XOR for mouse, Destination out for 8Direction.

    capx

    dl.dropbox.com/u/117529592/Construct%202/Forum%20questions/LightingAndBlendModes.capx

    html demo

    dl.dropbox.com/u/117529592/Construct%202/Forum%20questions/LightingAndBlendModes/index.html

    Aside (not really important):

    One thing that I could see value in is having a Force Own Texture mode that forces this layer and all above layers to a texture. I think this would allow for implementation of certain effects more easily (or maybe just conceptually more straightforward), but make other effects impossible. I think it's probably fine as it is, and you can probably get whatever effect you want with enough layers and the right settings.

    Thanks again for your help!

  • *bump* Is there anything I can do to make my question more clear, or is everyone else just as confused? :p

  • I think this is how Ashley was suggesting you select the items using the Pinned object's PinnedUID.

    System.For each [Family]

    System.Compare two values: [Family].Pin.PinnedUID = Heroes.UID

    Your way does work, but hopefully you can get this working, as it is a nicer solution not requiring extra variables.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hi, I ran into a scenario where I had multiple characters on screen with effect items pinned to them. Whenever a character dies, I need to destroy the effects associated with that character. My first solution was to add instance variables to all characters. When creating each effect, I would do something like:

    Effect1: Pin Pin to Character (position and angle)

    Character: Set Effect1UID to Effect1.UID

    And then when a character dies, choose effect instance by:

    Effect1: Pick instance with UID Character.Effect1UID

    It would be nicer if I didn't need to set and refer to the instance variable like that. It would be nicer if, on death, I could simply say:

    Effect1: Pinned to UID Character.UID

    I've included code to add that functionality to make it super easy for you if you think it's a good idea!

    edittime.js:44

    AddNumberParam("UID", "The UID of the object this object is pinned to.");
    AddCondition(1, cf_none, "Is pinned to UID", "", "{my}ned to UID <b>{0}</b>", "True if object is pinned to the object with given UID", "IsPinnedTo");

    runtime.js:139

    Cnds.prototype.IsPinnedTo = function (uid)
    {
         return !!this.pinObject && this.pinObject.uid === uid;
    };

    Also, if you do agree that this change is useful, it's probably worth removing the text "Pin " on this line since "Pin" is implicit in "{my}".

    edittime.js:65

    //results in "Pin Pin to obj (method)"
    AddAction(0, af_none, "Pin to object", "", "{my} Pin to {0} ({1})", "Pin the object to another object.", "Pin");
    //results in "Pin to obj (method)"
    AddAction(0, af_none, "Pin to object", "", "{my} to {0} ({1})", "Pin the object to another object.", "Pin");
    
  • GeometriX's example of how to select a clicked instance is good. If you can't open it, though, take this capx. It appears that GeometriX is using the latest beta version, so I just reverted it back to the release version of Construct 2, which you probably have.

    dl.dropbox.com/u/117529592/Construct%202/Forum%20questions/temp/bluegreen.capx

  • On Wikipedia's definition of "Programming Language":

    programming language is a notation for writing programs, which are specifications of a computation or algorithm. Some, but not all, authors restrict the term "programming language" to those languages that can express all possible algorithms.

    So yes, it is debatable as to whether RegEx is a language since it's not Turing complete (but neither is plain SQL). I agree that RegEx and SQL are not at all in the same category as the others we've listed, but I personally don't mind if someone calls them programming languages or something else. I did not intend to be misleading by using that term.

    Thanks, I see from your links that Oracle's databases have functions and in IBM DB2 you can add user-defined functions. Definitely worth using if you have a need for it and aren't worried about making your SQL queries slightly platform-dependent.

    I watched your Plugin tutorial and it was a nice intro. :) Construct 2 seems very easy to extend that way!

  • Yep and yep. It's certainly not a Turing complete language (you can't make it do everything), but it's a great example of a domain-specific language. For Regular Expressions, its domain is pattern matching and replacing text. I'm not sure if SQL has RegEx support... I know there is a LIKE clause, which uses a simple (but non-RegEx) syntax. But Javascript definitely has RegEx, and it makes parsing strings very easy compared to using nested for loops, if statements, and variables pointing to different indices. It's not going to blow your mind in the same way that Lisp might blow a Java programmer's mind, but it is a prime example of why learning more languages gives you more effective tools as a programmer.

    BTW, I see that you've done a plugin tutorial video! That's greatly appreciated, and I'm going to have to check it out soon. :)

Cowdozer's avatar

Cowdozer

Member since 6 Feb, 2013

None one is following Cowdozer yet!

Trophy Case

  • 11-Year Club
  • Email Verified

Progress

12/44
How to earn trophies